package markdown
Markdown processor for Ocsigen
Install
Dune Dependency
Authors
Maintainers
Sources
markdown-v0.2.1.tbz
sha256=9c575b74ad14229ab089819a348a1a8f453023bfcf1c20ebc5fc47343623de5e
sha512=98e42acfb09026670adad6cf4efb531f06854a9b2035cbac2c4a824037a0b08d4fe4fe3b661759983bb202882d3acd73bac0c6631ed34ac35f588f0a4817341e
doc/src/markdown.html/MarkdownHTML.ml.html
Source file MarkdownHTML.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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
(* Copyright (C) 2009 Mauricio Fernandez <mfp@acm.org> *) open Markdown open Tyxml.Html let rec elm_to_html ~render_pre ~render_link ~render_img elm = let self = elm_to_html ~render_pre ~render_link ~render_img in let item l = li (List.map self l) in match elm with | Normal text -> p (par_text_to_html ~render_link ~render_img text) | Pre (s, kind) -> ( match kind with Some k -> render_pre ~kind:k s | None -> pre [ txt s ] ) | Heading (l, text) -> let f = match l with | 1 -> h1 | 2 -> h2 | 3 -> h3 | 4 -> h4 | 5 -> h5 | _ -> h6 in f (par_text_to_html ~render_link ~render_img text) | Quote ps -> blockquote (List.map self ps) | Ulist (fst, others) -> ul (List.map item (fst :: others)) | Olist (fst, others) -> let item l = li (List.map self l) in ol (List.map item (fst :: others)) and par_text_to_html ~render_link ~render_img = List.map (text_to_html ~render_link ~render_img) and text_to_html ~render_link ~render_img = function | Text s -> txt s | Emph s -> em [ txt s ] | Bold s -> b [ txt s ] | Struck l -> del (List.map (text_to_html ~render_link ~render_img) l) | Code s -> code [ txt s ] | Anchor id -> (* would like to do a ~a:[XHTML.M_01_00.a_name_01_00 id] [] but that'd require switching to M_01_00 everywhere, so cheap hack *) b ~a:[ a_id id ] [] | Link href -> ( match href.href_target with | s when String.length s >= 1 && s.[0] = '#' -> a ~a:[ a_href (uri_of_string s) ] [ txt href.href_desc ] | _ -> render_link href ) | Image href -> render_img href let to_html ~render_pre ~render_link ~render_img l = List.map (elm_to_html ~render_pre ~render_link ~render_img) l
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>