Exemple #1
0
#!/usr/bin/env python3

import sys

from cc_pathlib import Path

import oaktree
import marccup

section_name = sys.argv[1]
section_pth = Path("document") / f"{section_name}.bkt"
section_txt = section_pth.read_text()

u = marccup.Parser(debug_dir=Path("tmp"))
p = oaktree.Leaf("section")
u.parse_section(p, section_txt)

v = marccup.Composer(p, Path("tmp/result.html"))


Exemple #2
0
	s = s.replace('<', '&lt;')
	s = s.replace('>', '&gt;')
	s = s.replace('\|', '&vert;')
	return s

for fnm in sys.argv[1:] :

	print(f"\x1b[31m{fnm}\x1b[0m")

	pth = Path(fnm).resolve()
	
	debug_dir = Path(f'./tmp-{pth.fname}')
	debug_dir.delete()

	u = marccup.parser.generic.GenericParser(debug_dir)
	m = pth.read_text()
	p = u.parse_auto(m)
	b.save(p, pth.with_suffix('.bkt'))

	v = marccup.composer.html5.Html5Composer()
	q = oaktree.Leaf('div')
	v.compose(p, q)

	g = oaktree.proxy.braket.BraketProxy()
	g.save(q.sub[0], debug_dir / "result.bkt")

	f = oaktree.proxy.html5.Html5Proxy(indent='', fragment=True)
	(debug_dir / 'result.mathjax.html').write_text(h_mathjax.format(
		protect(m), protect(g.save(p)), protect(g.save(q.sub[0])), f.save(q)
	))
	(debug_dir / 'result.katex.html').write_text(h_katex.format(