Hello! On Habré there are periodically articles where authors want to insert mathematical formulas:

,

or even
Some get it, some get it hard.
parpalak made a web service for inserting svg formulas, and this is very cool. I want to supplement it with a small script, with which the insertion of many formulas will be reduced to one command.

')
The method is as follows. You write your post in markdown-editor with support

. You can try
stackedit.io . When the post is ready, copy the markup to the clipboard; run the command
> poster clipboard
The command changes the current source in the buffer to readable; we insert into Habrahabr; do a preview and, if you like, publish.
There are alternative ways, but this one seems to be the most optimal. Maybe you optimize it in your own pair of shortcuts.
Poster Script
The purpose of the script is to simplify the set of formulas. The script collects all the dollars scattered throughout the text and highlights the formulas. Formulas are converted into images via
codecogs or
tex.s2cms services .
In addition, the script converts the standard markdown to html + slightly corrects line breaks.
From my own experience, I know that services with pictures can be very stupid, and even die from habraeffekt, multiplied by the number of formulas in the article. I made an automatic image uploader, which loads all but make up svg with tex.s2cms.
Training
- Put Python 2.7 if not.
- Put curl if not. If you install under Windows, do not forget to add the path to the PATH variable.
- We swing a script with GitHub .
- Run the init.py script.
Almost done. Under Linux or Mac, you can invoke init.py through sudo with the -l flag. The script will add a soft-link / usr / bin / poster to the poster.py script.
In the file default.json, you can change the source of the formulas: texsvg, texpng for tex.s2cms or codecogs, as well as the encoding.
How can I use
> poster clipboard
Converts the contents of the buffer to a readable form and writes back to the buffer.
> poster <filename.md>
Converts the contents of filename.md and writes the result to filename.txt
> poster -c <filename.md>
The same, but the result is copied to the buffer. It is possible to specify where to write the result through the -o flag.
Nuances
- When downloading images, the script requests habrasid and saves it in default.json. Once you have to decide how important it is for you that the habrasid will be in the clear. If you agree, then it will have to be updated periodically. How to mine, look in this post .
- Uploading images takes time. Therefore, the script caches the links. If the path to the file is specified, the folder with links to pictures and a file links.json with information about the loaded pictures will appear in the same folder. If you convert via buffer, the files will be downloaded to the folder where the script is located.
Syntax features
- To make a cat, type
- To make a spoiler, enter first
and then
- Use the keywords left, center, right to mark the alignment of the picture.
![left][beautiful.png]
Bun at the end
Windows users can use the program
AutoHotKey . For example, ahk-script
^j:: Send, ^a Send, ^c Run, <path to poster.py> clipboard Return
allows you to press the Ctrl + J combination to simultaneously highlight the current text, copy to the clipboard and convert.
I hope that I can facilitate with my small contribution the design of mathematical articles here and on other resources that do not support

.
Good luck!