-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Markdown in exercises #135
Conversation
let key = | ||
Filename.remove_extension descr.key | ||
^ "." ^ lang ^ "." ^ | ||
Filename.extension descr.key in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filename.extension
already contains the dot. This is fixed in this PR. If the PR is not merged, this should be fixed anyway.
return () | ||
in | ||
let markdown_to_html md = | ||
Omd.(md |> of_string |> to_html) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should probably go in a module that implements learn-ocaml's flavour of Markdown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Do it if you want.
let exts = [ | ||
(Filename.extension descr.key, fun h -> h) ; | ||
(".md", markdown_to_html) | ||
] in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lists should probably move at some point. Maybe the optionnal extensions should go in the descr
record?
This PR is fine to me. @OCamlPro-Couderc I let you review it since you are the expert of this piece of code. |
This is great, thanks! Did'nt have time to get around to it yet :) |
This PR seems nice to me. |
@AltGr I do agree. There are a lot of things that could be extracted from https://github.com/ocaml-sf/learn-ocaml/blob/master/src/repo/learnocaml_tutorial_parser.ml. But the
@OCamlPro-Couderc I do agree too. The type |
There was a problem with the merge. It's because the PR was anterior to the "dunification" of learn-ocaml. And the Omd dependency lacks in this PR. One has to change https://github.com/ocaml-sf/learn-ocaml/blob/master/src/repo/dune#L6 and add "omd" as a dependency. |
This PR is a small modification of the
learnocaml_exercise.ml
file that allows for support for Markdown in exercises description. It modifies the functionsread_descr
andread_descrs
in such a way that:read_descr
now has a new argument that is the list of extensions to try in order. I also fixed a bug that whould have happened ifland
was not empty inread_descrs
.read_descrs
now has a list of extensions to try that it can give toread_descr
. I believe this list should at some point move somewhere else. Maybe in thedescr
record?I had to add a small
markdown_to_html
function. I used the basic functions from Omd, which means that it might not support other features that you want to have in your flavour of Markdown. I believe there should be a module (Markdown
?) that implements this flavour with an interface containing at leastfrom_string
andto_html
.