diff --git a/demo-repository/exercises/demo2/descr.md b/demo-repository/exercises/demo2/descr.md index 3b7c6f0ca..13c15704a 100644 --- a/demo-repository/exercises/demo2/descr.md +++ b/demo-repository/exercises/demo2/descr.md @@ -1,5 +1,5 @@ - -This exercise is just another demo for the exercise environment. +The following example link will open another tab/window: [OCaml](https://ocaml.org "External link") +This exercise is just another demo for the exercise environment. Test
diff --git a/dune b/dune index 0f95c3a97..1a22f2d2a 100644 --- a/dune +++ b/dune @@ -3,7 +3,7 @@ (rule (targets VERSION) (action (with-stdout-to %{targets} - (run opam show ./%{dep:./learn-ocaml.opam} -f version --normalise))) + (run opam show --color=never ./%{dep:./learn-ocaml.opam} -f version --normalise))) ) (env diff --git a/learn-ocaml-client.opam b/learn-ocaml-client.opam index e3c1a8a61..fe0f001e7 100644 --- a/learn-ocaml-client.opam +++ b/learn-ocaml-client.opam @@ -17,7 +17,7 @@ depends: [ "base" {>= "v0.9.4"} "base64" "cmdliner" - "omd" + "omd" {<= "1.3.1"} "asak" "cohttp" {>= "1.0.0" & < "2.0.0"} "cohttp-lwt-unix" {>= "1.0.0" & < "2.0.0"} diff --git a/learn-ocaml.opam b/learn-ocaml.opam index d49eaee5d..6ea653302 100644 --- a/learn-ocaml.opam +++ b/learn-ocaml.opam @@ -48,7 +48,7 @@ depends: [ "ocp-ocamlres" {>= "0.4"} "ocplib-json-typed" {= "0.6"} "odoc" {build & >= "1.3.0"} - "omd" + "omd" {<= "1.3.1"} "pprint" "ppx_cstruct" "ppx_tools" diff --git a/src/repo/learnocaml_exercise.ml b/src/repo/learnocaml_exercise.ml index 5157b05e0..ffb7215e2 100644 --- a/src/repo/learnocaml_exercise.ml +++ b/src/repo/learnocaml_exercise.ml @@ -317,8 +317,25 @@ module File = struct descrs := (lang, f raw) :: !descrs; return () in + let override_url = function + | Omd_representation.Url(href,s,title) -> + if String.length href > 0 then + if Char.equal (String.get href 0) '#' then + None + else + let title_url = + if title <> "" then Printf.sprintf {| title="%s"|} + (Omd_utils.htmlentities ~md:true title) else "" in + let html = + Printf.sprintf + {|%s|} + (Omd_utils.htmlentities ~md:true href) title_url + (Omd_backend.html_of_md s) in + Some html + else None + | _ -> None in let markdown_to_html md = - Omd.(md |> of_string |> to_html) + Omd.(md |> of_string |> to_html ~override:override_url) in let read_descrs () = let langs = [] in