package forester
A tool for tending mathematical forests
Install
Dune Dependency
Authors
Maintainers
Sources
2.5.1.tar.gz
md5=b26b6f4e3d14b976c3d5018c97b81b94
sha512=f0c794ed4330485b5255639720ad7201488b77ef947b0736a847fa4f56f93d3f03a22fd2a3319bbe867bab827a4b5ae73b2426a1067911b29fe178d21dd99e73
doc/src/forester.core/Sem.ml.html
Source file Sem.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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
open Base open Prelude type attr = string * string [@@deriving show] type node = | Text of string | Transclude of transclusion_opts * addr | Query of transclusion_opts * t Query.t | Link of {dest : string; title : t option} | Tag of string * attr list * t | Math of math_mode * t | Embed_tex of {packages : string list; source : t} | Block of t * t | If_tex of t * t [@@deriving show] and transclusion_opts = {toc : bool; show_heading : bool; show_metadata : bool; title_override : t option; taxon_override : string option; expanded : bool; numbered : bool} [@@deriving show] and t = node list and env = t Env.t [@@deriving show] let sentence_case = function | Text str :: xs -> Text (String_util.sentence_case str) :: xs | xs -> xs type doc = {title : t option; taxon : string option; authors : addr list; date: Date.t option; addr : addr option; metas : (string * t) list; tags: string list; body : t} [@@deriving show] (** Best-effort rendering of a nodes as a string, to use in text-only contexts.*) let string_of_nodes = let rec render nodes = String.concat "" @@ List.filter_map render_node nodes and render_node = function | Text s -> Some s | Link {title = Some title; _} -> Some (render title) | Link {title = None; dest} -> Some dest | Tag (_, _, bdy) | Math (_, bdy) -> Some (render bdy) | Embed_tex {source; _} -> Some (render source) | If_tex (_, x) -> Some (render x) | Transclude _ | Query _ | Block _ -> None in render module Doc = struct let peek_title (doc : doc) = match doc.title with | Some (Text txt :: _) -> Some txt | _ -> None let sort = let by_date = Fun.flip @@ Compare.under (fun x -> x.date) @@ Compare.option Date.compare in let by_title = Compare.under peek_title @@ Compare.option String.compare in let by_addr = Compare.under (fun x -> x.addr) @@ Compare.option String.compare in List.sort @@ Compare.cascade by_date @@ Compare.cascade by_title by_addr end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>