open-resources / scripts

Repo of converter scripts to and from MD files to various platform file formats.
3 stars 0 forks source link

Script/functions to convert from PrairieLearn format to Markdown format #33

Open firasm opened 3 years ago

firasm commented 3 years ago

The task is to write some functions that take in the path to a directory, reads in the files, and then creates the MD version of the question.

I have created a jupyter notebook for you to write and test your code, as well as some examples in the examples folder.

The output md files should go into the output folder.

You can also find the "source" md files that you will be trying to replicate here.

akshatpoddar commented 3 years ago

We parse the pl files and then come up with the markdown. So I can just use yaml for this as well and then rename the file to md?

I would break it down a bit more. One part deals with creating the yaml text, another part deals with the python functions, another part deals with images, etc….

akshatpoddar commented 3 years ago

Here, the exploding_asteroid server.py seems to have a function in the import statements area as a lambda function. This is an exception I am assuming because I have never seen this format before.

firasm commented 3 years ago

Here, the exploding_asteroid server.py seems to have a function in the import statements area as a lambda function. This is an exception I am assuming because I have never seen this format before.

You can ignore that for now, it is now replaced with: data2 = pbh.create_data2()

akshatpoddar commented 3 years ago

Here, the exploding_asteroid server.py seems to have a function in the import statements area as a lambda function. This is an exception I am assuming because I have never seen this format before.

You can ignore that for now, it is now replaced with: data2 = pbh.create_data2()

I think this is important since all the other markdown files have data2 = pbh.create_data2() as the last line in the generate function and I was going to use that to identify the end of the function. Would it be okay to use a strict algorithm as such to depend on the position of the code at certain places to parse them?

firasm commented 3 years ago

No, I don't think you can rely on the positioning of specific code strings to parse the file. You can however rely on def generate(): function to always be there.