package hilite
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Build time syntax highlighting
Install
dune-project
Dependency
Authors
Maintainers
Sources
hilite-0.5.0.tbz
sha256=550c01abe4a95808553693499dcb75ef87bd86127db8f3db1f94a81689e13a15
sha512=b42375e1dd288fc3795c570be2b94486aa91c499c5b6a2cff936d530d6864b57f0269deb73a7f333339e41e89b4cd0452655ff7c40f58360cea13efaee645115
doc/src/hilite.markdown/hilite_markdown.ml.html
Source file hilite_markdown.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29let transform ?(skip_unknown_languages = true) ?lookup_method ?tm (doc : Cmarkit.Doc.t) = let block _mapper (b : Cmarkit.Block.t) = match b with | Cmarkit.Block.Code_block (node, meta) -> ( let info = Cmarkit.Block.Code_block.info_string node |> Option.map fst in let code = Cmarkit.Block.Code_block.code node |> List.map Cmarkit.Block_line.to_string |> String.concat "\n" in match Option.bind info Cmarkit.Block.Code_block.language_of_info_string with | Some (lang, _) -> ( match Hilite.src_code_to_html ?lookup_method ?tm ~lang code with | Ok html -> let h = Cmarkit.Block_line.list_of_string html in `Map (Some (Cmarkit.Block.Html_block (h, meta))) | Error (`Unknown_lang s) -> if skip_unknown_languages then `Map (Some b) else failwith ("Unknown language: " ^ s)) | _ -> `Map (Some b)) | _ -> `Default in let mapper = Cmarkit.Mapper.make ~block () in Cmarkit.Mapper.map_doc mapper doc
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>