Package: pelican-render-math
Render Math Plugin for PelicanThis plugin givesPelicanthe ability to render mathematics inside post
content. It accomplishes this by using theMathJaxJavaScript engine.The plugin also makesTypogrifyand recognized math play nicely together by
ensuringTypogrifydoes not alter math content.Both Markdown and reStructuredText are supported.RequirementsPelicanversion4.5or above is required.Typogrifyversion2.0.7or higher is needed for Typogrify to behave
properly with this plugin. If this version is not available, Typogrify will be
disabled for the entire site.BeautifulSoup4+ is required to correct summaries. If BeautifulSoup is not
installed, summary processing will be ignored, even if specified in user
settings.InstallationThis plugin can be installed via:python -m pip install pelican-render-mathYour site should now be capable of rendering math using the MathJax JavaScript
engine. No alterations to the template are needed — just use and enjoy!However, if you wish, you can set theauto_insertsetting toFalsewhich
will disable the MathJax script from being automatically inserted into the
content. You would only want to do this if you have control over the template
and want to insert the script manually.TypogrifyIn the past, usingTypogrifywould alter math content, resulting in math
that could not be rendered byMathJax. The only option was to ensure thatTypogrifywas disabled in the settings.The problem has been rectified in this plugin, but it requires at a minimumTypogrifyversion 2.0.7 or higher. If this version is not present, the
plugin will disable Typogrify for the entire site.BeautifulSoupPelican creates summaries by truncating the post content to a specified user
length. The truncation process is oblivious to any math and can therefore
destroy the math output in the summary.To restore math,BeautifulSoupis used. If it is not installed, no summary
processing will happen.UsageTemplatesNo template alteration is needed for this plugin to work. Just install the
plugin and start writing your math.SettingsCertain MathJax rendering options can be set. These options are in a dictionary
variable calledMATH_JAXin the Pelican settings file.The dictionary can be set with the following keys:align: [string] controls how displayed math will be aligned. Can be set to
either'left','right'or'center'.Default Value:'center'.auto_insert: [boolean] will insert the MathJax script into content that it
is detected to have math in it. Setting it to false is not recommended.Default Value:Trueindent: [string] ifalignnot set to'center', then this controls the
indent level.Default Value:'0em'.show_menu: [boolean] controls whether the MathJax contextual menu is
shown.Default Value:Trueprocess_escapes: [boolean] controls whether MathJax processes escape
sequences.Default Value:TrueMathJax_font: [string] will force MathJax to use the chosen font. Current
choices for the font issanserif,typewriterorfraktur. If this is
not set, it will use the default font settings.Default Value:defaultlatex_preview: [string] controls the preview message users are shown while
MathJax is rendering LaTex. If set to'Tex', then the TeX code is used as
the preview (which will be visible until it is processed by MathJax).Default Value:'Tex'color: [string] controls the color of the MathJax rendered font.Default
Value:'inherit'linebreak_automatic: [boolean] If set, MathJax will try tointelligentlybreak up displayed math (Note: It will not work for inline math). This is
very useful for a responsive site. It is turned off by default due to it
potentially being CPU expensive.Default Value:Falsetex_extensions: [list] a list oflatex
extensionsaccepted by MathJax.Default Value:[](empty list)responsive: [boolean] tries to make displayed math render responsively. It
does by determining if the width is less thanresponsive_break(see below)
and if so, setsaligntoleft,indentto0emandlinebreak_automatictoTrue.Default Value:False(defaults toFalsefor backward compatibility)responsive_break: [integer] a number (in pixels) representing the width
breakpoint that is used when settingresponsive_aligntoTrue.Default
Value: 768process_summary: [boolean] ensures math will render in summaries and fixes
math in that were cut off. RequiresBeautifulSoupbe installed.Default
Value:Truemessage_style: [string] This value controls the verbosity of the messages
in the lower left-hand corner. Set it toNoneto eliminate all messages.Default Value: normalSettings ExamplesMake math render in blue and display math aligned to the left:MATH_JAX = {'color':'blue','align':left}Use thecolorandmhchemextensions:MATH_JAX = {'tex_extensions': ['color.js','mhchem.js']}Resulting HTMLInline math is wrapped inspantags, while displayed math is wrapped indivtags.  These tags will have a class attribute that is set tomathwhich
can be used by template designers to alter the display of the math.MarkdownThis plugin implements a custom extension for Markdown resulting in math being
a "first class citizen" for Pelican.Inline MathMath between$..$, for example,$x^2$, will be rendered inline with
respect to the current HTML block. Note: To use inline math, there mustnotbe any whitespace before the ending$. So for example:Relevant inline math:$e=mc^2$Will not render as inline math:$40 vs $50Displayed MathMath between$$..$$will be rendered "block style", for example,$$x^2$$, will be rendered centered in a new paragraph.Other Latex Display Math CommandsThe other LaTeX commands which usually invoke display math mode from text mode
are supported, and are automatically treated like$$-style displayed math in
that they are rendered "block" style on their own lines.  For example,\begin{equation}x^2\end{equation}, will be rendered in its own block with
a right justified equation number at the top of the block. This equation number
can be referenced in the document.  To do this, use alabelinside of the
equation format and then refer to that label usingref. For example:\begin{equation}\label{eq}X^2\end{equation}.  Now refer to that
equation number by$\ref{eq}$.reStructuredTextIf there is math detected in reStructuredText content, the plugin will
automatically set themath_outputconfiguration setting tomathjax.Inline MathInline math needs to use themath
role:The area of a circle is :math:`A_\text{c} = (\pi/4) d^2`.Displayed MathDisplayed math uses themath block:..math::α_t(i) = P(O_1, O_2, … O_t, q_t = S_i λ)ContributingContributions 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.