Package: pelican-math-svg
math-svg: A Plugin for PelicanRender math expressions to svg and embed them.InstallationThis plugin can be installed via:python-mpipinstallpelican-math-svgAfterwards, add the plugin to thePLUGINSlist in yourpelicanconf.pyfile, e.g.:PLUGINS=["math_svg",]Multi-Core RenderingTo use multi-core rendering of equations (highly recommended, especially when many equations have to be rendered) change thehtmltarget in theMakefileof your pelican site to a three step process:html:PELICAN_MATH_SVG_DRY=True"$(PELICAN)""$(INPUTDIR)"-o"$(OUTPUTDIR)"-s"$(CONFFILE)"$(PELICANOPTS)pelican-math-svgrender-j$(shellnproc)"$(PELICAN)""$(INPUTDIR)"-o"$(OUTPUTDIR)"-s"$(CONFFILE)"$(PELICANOPTS)The first commands will executemath-svgin dry-mode and only populate the equation database without actually rendering anything.
The second command will render all missing equations in parallel.
The number of threads is specified by the-jflag, in this example all CPU cores are used.
Replace$(shell nproc)with a number to use a fixed number of cores.
The last command is the usual pelican command and produces the output files again, know including the rendered equations.Requirementsrequired LaTeX tools (all included in TeX Live and possibly other LaTeX distributions):lualatex(or another LaTeX compiler if changed in the settings,see below)pdfcropdvisvgmscour(optional)svgo(optional)UsageIn Markdown you can use$x$for inline math and$$
  \int x^2
$$for display math.It is required to set the stroke color using thestrokeonlyclass (this class name can be changed, seeconfiguration options below), otherwise lines would be rendered white:svgpath.strokeonly{color:#000;}To change the fill color for equations as well, thus essential changing the default color for math, specify the following additionally:span.mathsvgpath,div.mathsvgpath{fill:#000;}ConfigurationIn yourpelicanconf.pyyou can use the following options to tweak the behavior of the plugin:SettingDescriptionDefault Value`MATH_SVG["titles"]Whether to generate<title>tags containing the raw LaTeX code (recommended for accessibility).TrueMATH_SVG["scale_inline"]scaling factor for inline math1.0MATH_SVG["scale_display"]scaling factor for display math1.0MATH_SVG["strokeonly_class]CSS class for SVG paths that have no filling and a black stroke color, useful when changing the color of rendered equationsstrokeonlyMATH_SVG["latex"]["args"]CLI arguments of the invoked LaTeX compiler"--interaction=errorstopmode", "--halt-on-error"MATH_SVG["latex"]["preamble"]preamble of the generated LaTeX document[r"\documentclass[preview,border={2pt 0pt}]{standalone}",r"\usepackage{amsmath}",r"\usepackage{amssymb}",]MATH_SVG["latex"]["program"]LaTeX compiler to uselualatexMATH_SVG["pdfcrop"]["args"]CLI arguments forpdfcrop--hiresMATH_SVG["dvisvgm"]["args"]CLI arguments fordvisvgm["--pdf", "--optimize=all", "--no-fonts", "--exact-bbox"]MATH_SVG["scour"]["args"]CLI arguments forscour["--strip-xml-prolog", "--remove-descriptions", "--remove-metadata", "--enable-comment-stripping", "--strip-xml-space", "--enable-id-stripping",]MATH_SVG["scour"]["enabled"]whether to usescourto optimize SVG outputTrueifscouris in$PATH,FalseotherwiseMATH_SVG["svgo"]["args"]CLI arguments forsvgo["--multipass", "--precision", "5"]MATH_SVG["svgo"]["enabled"]whether to usesvgoto optimize SVG outputTrueifsvgois in$PATH,FalseotherwiseContributingContributions are welcome and much appreciated. Every little bit helps. You can contribute by improving the documentation, adding missing features, and fixing bugs. You can also help out by reviewing and commenting onexisting issues.To start contributing to this plugin, review theContributing to Pelicandocumentation, beginning with theContributing Codesection.LicenseThis project is licensed under the GPLv3 license.