mirror of
https://github.com/reanimate/reanimate.git
synced 2026-09-12 08:32:20 +00:00
add latexCfgChunks
This commit is contained in:
parent
e266f5454c
commit
9944af167e
1 changed files with 14 additions and 8 deletions
|
|
@ -109,17 +109,23 @@ someTexWithHeaders engine exec dvi args headers postscript tex =
|
||||||
where
|
where
|
||||||
script = mkTexScript exec args headers (T.unlines (postscript ++ [tex]))
|
script = mkTexScript exec args headers (T.unlines (postscript ++ [tex]))
|
||||||
|
|
||||||
-- | Invoke latex and separate results.
|
-- | Invoke latex using a given configuration and separate results.
|
||||||
latexChunks :: [T.Text] -> [Tree]
|
latexCfgChunks :: TexConfig -> [T.Text] -> [Tree]
|
||||||
latexChunks chunks | pNoExternals = map mkText chunks
|
latexCfgChunks _cfg chunks | pNoExternals = map mkText chunks
|
||||||
latexChunks chunks = worker (svgGlyphs $ latex $ T.concat chunks) chunks
|
latexCfgChunks cfg chunks = worker chunks $ svgGlyphs $ tex $ T.concat chunks
|
||||||
where
|
where
|
||||||
|
tex = latexCfg cfg
|
||||||
merge lst = mkGroup [fmt svg | (fmt, _, svg) <- lst]
|
merge lst = mkGroup [fmt svg | (fmt, _, svg) <- lst]
|
||||||
worker [] [] = []
|
worker [] [] = []
|
||||||
worker _ [] = error "latex chunk mismatch"
|
worker [] _ = error "latex chunk mismatch"
|
||||||
worker everything (x : xs) =
|
worker (x : xs) everything =
|
||||||
let width = length $ svgGlyphs (latex x)
|
let width = length $ svgGlyphs (tex x)
|
||||||
in merge (take width everything) : worker (drop width everything) xs
|
(first, rest) = splitAt width everything
|
||||||
|
in merge first : worker xs rest
|
||||||
|
|
||||||
|
-- | Invoke latex and separate results.
|
||||||
|
latexChunks :: [T.Text] -> [Tree]
|
||||||
|
latexChunks = latexCfgChunks (TexConfig LaTeX [] [])
|
||||||
|
|
||||||
-- | Invoke xelatex and import the result as an SVG object. SVG objects are
|
-- | Invoke xelatex and import the result as an SVG object. SVG objects are
|
||||||
-- cached to improve performance. Xelatex has support for non-western scripts.
|
-- cached to improve performance. Xelatex has support for non-western scripts.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue