package htmlfromtexbooks
From TeX To Human-Readable HTML
Install
Dune Dependency
Authors
Maintainers
Sources
v3.3.2.tar.gz
md5=8eafd939e9dbcb31919c5be0ed144840
sha512=4e7d13452e0a6b358e013711085500d82faf034eb03845be7de86a631fbc7b66a9aede7eba63cfd35460992c16e74de6c7db9aa152234f7dbc3acf9ab31c12ee
doc/src/htmlfromtexbooks.lib/mathgen.ml.html
Source file mathgen.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
(**Unparsing to generate math latex to be interpreted on the web*) open Parser (**Generate a command with its name and list of parameters*) let generate_latex_command s l = let line = "\\"^s in let args = String.concat "," l in let line = if args="" then line else Printf.sprintf "%s[%s]" line args in line;; (**Generate latex again for commands*) let generate_latex l = let rec unparse acc l = match l with | [] -> String.concat " " acc | Line s::q -> unparse (s::acc) q | AtomicCmd (s,l)::q -> let line = generate_latex_command s l in unparse (line::acc) q | OneArgCmd (s,l,l2)::q -> let line = generate_latex_command s l in let line = Printf.sprintf "%s{%s}" line (unparse [] l2) in unparse (line::acc) q | MultipleArgCmd (s,l,l2)::q -> let line = generate_latex_command s l in let l = List.map (unparse []) l2 in let line = Printf.sprintf "%s{%s}" line (String.concat "\n" l) in unparse (line::acc) q | _::q -> unparse acc q in unparse [] l;; (**Recalculate the environments accounting align,align*,equation,equation* *) let re_calculate_env ast = let rec aux acc ast = match ast with | [] -> acc | Env (s,n)::q when s="align" -> aux (Math(Printf.sprintf "\\begin{align}%s\\end{align}" (generate_latex n))::acc) q | Env (s,n)::q when s="align*" -> aux (Math(Printf.sprintf "\\begin{align*}%s\\end{align*}" (generate_latex n))::acc) q | Env (s,n)::q when s="equation" -> aux (Math(Printf.sprintf "\\begin{equation}%s\\end{equation}" (generate_latex n))::acc) q | Env (s,n)::q when s="equation*" -> aux (Math(Printf.sprintf "\\begin{equation*}%s\\end{equation*}" (generate_latex n))::acc) q | Env(s,n)::q -> let ast = aux [] n in let ast = List.rev ast in let env = Env(s,ast) in aux (env::acc) q | Chapter (s,l)::q -> let ast = aux [] l in let ast = List.rev ast in let c = Chapter(s,ast) in aux (c::acc) q | Section (s,l)::q -> let ast = aux [] l in let ast = List.rev ast in let c = Section(s,ast) in aux (c::acc) q | Subsection (s,l)::q -> let ast = aux [] l in let ast = List.rev ast in let c = Subsection(s,ast) in aux (c::acc) q | Subsubsection (s,l)::q -> let ast = aux [] l in let ast = List.rev ast in let c = Subsubsection(s,ast) in aux (c::acc) q | e::q -> aux (e::acc) q in List.rev (aux [] ast);;
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>