Skip to content

Commit

Permalink
Configuration parameters are no longer a global.
Browse files Browse the repository at this point in the history
latex2svg functionality has been consolidated in a class. This changes the
way the plugin is used a bit, so we bump the version number. Not that anybody
else has used this yet.
  • Loading branch information
crisluengo committed Feb 3, 2021
1 parent a8d5b02 commit 9c78c51
Show file tree
Hide file tree
Showing 4 changed files with 250 additions and 234 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
build
dist
*.egg-info
__pycache__
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ md = markdown.Markdown(extensions=[math_svg_extension])

# Load cache (if it's there)
math_cache_file_name = 'math_cache'
mdx_math_svg.load_cache(math_cache_file_name)
math_svg_extension.latex2svg.load_cache(math_cache_file_name)

# Use Python-Markdown instance
md.convert("My Markdown text")

# Save cache
mdx_math_svg.save_cache(math_cache_file_name)
math_svg_extension.latex2svg.save_cache(math_cache_file_name)
```

Load the cache file before you begin any Markdown parsing, and save the cache file when you're done with
Expand All @@ -112,10 +112,10 @@ The extension recognizes the following parameters:
- `fontsize`: Font size in em for rendering LaTeX equations. Defaults to 1, matching surrounding text,
usually. Depending on the font used, you might want to increase or decrease this value a bit.

There are other things that can be configured with a bit more difficulty. The `mdx_math_svg.params`
There are other things that can be configured with a bit more difficulty. The `math_svg_extension.latex2svg.params`
variable is a struct containing the following:
```python
mdx_math_svg.params = {
math_svg_extension.latex2svg.params = {
'fontsize': 1, # em (in the sense used by CSS)
'template': r"""
\documentclass[12pt,preview]{standalone}
Expand All @@ -135,8 +135,8 @@ mdx_math_svg.params = {
\usepackage{newtxmath}
""",
'latex_cmd': 'latex -interaction nonstopmode -halt-on-error',
'dvisvgm_cmd': 'dvisvgm --no-fonts --exact',
'libgs': None,
'dvisvgm_cmd': 'dvisvgm --no-fonts --exact', # Has '--precision=2' added if the dvisvgm version is >= 2.2.2
'libgs': None, # Gets set through environment variable or default location
}
```
By changing these values, it is possible to change the preamble, and the options passed to `latex` and `dvisvgm`.
Expand Down
Loading

0 comments on commit 9c78c51

Please sign in to comment.