Skip to content

Commit

Permalink
feat: render cookbook task description as markdown to allow links (#2832
Browse files Browse the repository at this point in the history
)
  • Loading branch information
sabine authored Nov 25, 2024
1 parent d65621e commit 93a4ebd
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions tool/ood-gen/lib/cookbook.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ type metadata = { packages : package list; discussion : string option }
~remove:[ discussion ],
show]

let render_markdown str =
str |> String.trim
|> Cmarkit.Doc.of_string ~strict:true
|> Hilite.Md.transform
|> Cmarkit_html.of_doc ~safe:false

let decode (tasks : task list) (fpath, (head, body)) =
let ( let* ) = Result.bind in
let name = Filename.basename (Filename.remove_extension fpath) in
Expand All @@ -35,13 +41,6 @@ let decode (tasks : task list) (fpath, (head, body)) =
let slug = String.sub name 3 (String.length name - 3) in
let metadata = metadata_of_yaml head in

let render_markdown str =
str |> String.trim
|> Cmarkit.Doc.of_string ~strict:true
|> Hilite.Md.transform
|> Cmarkit_html.of_doc ~safe:false
in

let code_blocks =
let rec extract_explanation_code_pairs split_result =
match split_result with
Expand Down Expand Up @@ -97,7 +96,7 @@ let all_categories_and_tasks () =
title = t.title;
slug = t.slug;
category_path = List.rev (cat_slug :: path);
description = t.description;
description = t.description |> Option.map render_markdown;
})
in
let subcategories_tasks, subcategories =
Expand Down

0 comments on commit 93a4ebd

Please sign in to comment.