latex_to_myst package¶
Submodules¶
latex_to_myst.cli module¶
latex_to_myst.directive module¶
Collection of Helpers to create directive blocks consistent with MyST syntax
The syntax for MyST Directive Blocks that is followed in this repository takes the form of:
```{directivename} arg1 arg2
:key1: metadata1
:key2: metadata2
My directive content.
```
-
latex_to_myst.directive.
create_directive_block
(elem, doc, content, block_type, create_using=<class 'panflute.elements.Span'>, label='')[source]¶ Create a directive block as literal
- Parameters
elem (panflute.base.Element) –
doc (panflute.elements.Doc) –
content (Iterable[panflute.base.Element]) –
block_type (str) –
create_using (Union[panflute.elements.Para, panflute.elements.Span]) –
label (str) –
- Return type
Union[panflute.elements.Para, panflute.elements.Span]
-
latex_to_myst.directive.
directive_level
(elem, doc, starting_level=0)[source]¶ Check the nested level of a directive block
- Parameters
elem (panflute.base.Element) –
doc (panflute.elements.Doc) –
starting_level (int) –
- Return type
int
-
latex_to_myst.directive.
elem_has_multiple_figures
(elem)[source]¶ Check if an element is a subplot (subfigures)
- Parameters
elem (panflute.base.Element) –
latex_to_myst.figures module¶
Figures directives
-
latex_to_myst.figures.
break_long_string
(string, max_len=70, indent=0)[source]¶ Break long string into shorter strings of max_len (with indent added)
- Parameters
string (str) –
max_len (int) –
indent (int) –
- Return type
str
-
latex_to_myst.figures.
create_image
(elem, doc=None)[source]¶ Create Image Directive Block
- Parameters
elem (panflute.elements.Image) –
doc (Optional[panflute.elements.Doc]) –
- Return type
panflute.elements.Span
-
latex_to_myst.figures.
create_subplots
(elem, doc=None)[source]¶ Create Subplot using list-table and return table and substitutions to put in header
- Parameters
elem (Union[panflute.elements.Para, panflute.table_elements.Table]) –
doc (Optional[panflute.elements.Doc]) –
- Return type
Tuple[panflute.elements.Para, Iterable[Any]]
latex_to_myst.latex_math module¶
Handle LaTeX math blocks
Deals with amsthm blocks and also DisplayMath blocks and render them in formats that are compatible with MyST syntax.
-
latex_to_myst.latex_math.
create_amsthm_blocks
(elem, doc=None)[source]¶ Create directive blocks that render AMSTHM
Takes advantage of sphinx-proof sphinx extension to render amsthm blocks. It does the following:
Walk the element to see if a label{} node is found and save that label. Remove that label element if found.
Parses the :py:func`panflute.Div`’s stringified representation to see if pattern like Theorem 1.1 (Theorem Name) or Example 1.1 is encountered. Save the theorem name Theorem Name if found.
Render output as a
panflute.Div()
element with the sphinx-proof syntax.
The output looks something like:
```{prf:remark} My Remark :label: remark-1 This is my remark. ```
- Parameters
elem (panflute.elements.Div) –
doc (Optional[panflute.elements.Doc]) –
- Return type
panflute.elements.Para
-
latex_to_myst.latex_math.
create_displaymath
(elem, doc=None)[source]¶ Create DisplayMath block
Create a
panflute.Span()
block that contains the display math using MyST syntax that looks like:```{math} :label: my-equation a = \int_1^2 u(t) dt ```
- Parameters
elem (panflute.elements.Math) –
doc (Optional[panflute.elements.Doc]) –
- Return type
panflute.elements.Span
latex_to_myst.main module¶
Module contents¶
Pandoc filter for converting LaTeX to MyST