package kkmarkdown
A safe markdown engine
Install
Dune Dependency
Authors
Maintainers
Sources
1.1.0.tar.gz
md5=a20517d95590d03ff5b7670323b8b0dd
sha512=97b3faa09e23ab88c5b4dcabe88f29e5c675b6bb4b0c9230ec105a70b01b37b54274cc0ab4a5eed84a754a99e3664e116a7aba6c9697e3669229985f1bf749be
doc/src/kkmarkdown.lib/RuleBr.ml.html
Source file RuleBr.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 53 54 55 56 57 58
let re = Str.regexp ".* +$" (** Separate lines by {!re} *) let separate lines = List.fold_left (fun acc line -> match acc with | [] -> assert false | hd :: tl -> if Str.string_match re line 0 then let line = Utils.remove_trailing_spaces line in [] :: (line :: hd) :: tl else (line :: hd) :: tl) [ [] ] lines (** Merge lines with space as a separator *) let merge_lines lines = let rec length lines acc = match lines with | [] -> 0 | [ last ] -> String.length last | hd :: tl -> length tl (String.length hd + 1) in let buffer = Buffer.create (length lines 0) in let rec write_buffer lines = match lines with | [] -> () | [ last ] -> Buffer.add_string buffer last | hd :: tl -> Buffer.add_string buffer hd; Buffer.add_char buffer ' '; write_buffer tl in write_buffer lines; Buffer.contents buffer (** Merge spans with {!Typ.Br} as a separator *) let merge_spans spans_list = let res = Queue.create () in let push_spans spans = List.iter (fun span -> Queue.push span res) spans in let rec push spans_list = match spans_list with | [] -> () | [ last ] -> push_spans last | hd :: tl -> push_spans hd; Queue.push Typ.Br res; push tl in push spans_list; List.of_seq (Queue.to_seq res) let construct trans_spans lines = separate lines |> List.rev_map (fun rev_lines -> let lines = List.rev rev_lines in trans_spans (merge_lines lines)) |> merge_spans
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>