How to write a post with the formula: markdown + LaTeX

Hello! On habré periodically there are articles where the authors want to insert the mathematical formula: inline_formula, inline_formula or even


For some it turns out, some with difficulty. parpalak made web-service to insert svg formulas, and it's very cool. I want to Supplement it with a small script, which insert many formulas will be reduced to a single command.



The method consists in the following. You write your post in markdown editor with support for inline_formula. Can try stackedit.io. When the post is ready, copy the markup to the clipboard, run the command

the
> clipboard poster

The command changes the buffer current source for capacitary; insert into...; do the preview and, if you like, publish.

There is an alternative way but this seems the most optimal. May be you are optimizing a couple of shortcuts.

the

Script Poster


The purpose of the script is to simplify the set of equations. The script collects all the dollars scattered in the text and highlights them formula. Formulas are converted to images through the services of codecogs or tex.s2cms.

In addition, the script converts standard markdown to html + a little straighten the line.

In my experience I know that good pictures can be very blunt, and even die from gebrettert multiplied by the number of formulas in the article. I did the automatic loading of images, which loads all with the exception of svg tex.s2cms.

the

Preparation


    the
  1. Put Python 2.7 if not.
  2. the
  3. Put curl if not. If put under Windows, don't forget to add the path to the PATH variable.
  4. the
  5. Download the script from GitHub.
  6. the
  7. Run the script init.py.

Almost ready. Under Linux or Mac, you can call init.py using sudo with the-l flag. The script will add soft-link /usr/bin/poster on the script poster.py.

In default.json you can change the source of the formulae: texsvg, texpng for tex.s2cms or codecogs, as well as the encoding.

the

How to use


the
> clipboard poster

Converts the contents of the buffer to capacitiva mind and writes back to the buffer.

the
> poster <filename.md>

Converts the contents of the file filename.md and writes the result to filename.txt

the
> poster -c <filename.md>

The same thing, but the result is copied to the clipboard. It is possible to specify where to write the result using the-o flag.

the

Nuances


    the
  1. When loading images, the script prompts habrasid and saves it in the default.json. Once you have to decide how important that habrasid will be in the clear. If you agree, then it will have to be updated periodically. How to get, look at this post.
  2. the
  3. Uploading of pictures takes time. Therefore, the script caches the links. If you specify the path to the file in the same folder will appear in the links folder with images links and file links.json with information about the uploaded pictures. If you transform via a buffer, the file will be downloaded to the folder where is script.

the

Features


the
    the
  • to make the cut, type

    the
    <!--  cut  [Cut title] -->
    

  • the
  • to make a spoiler, type the first

    the
    <!-- spoiler [spoiler title] -->
    

    and then

    the
    <!-- /spoiler -->
    

  • the
  • Use the keywords left, center, right, to indicate the alignment of images

    the
    ![left][beautiful.png]
    


the

Bun in the end



the
^j::
Send, ^a
Send, ^c
Run <path to poster.py> clipboard
Return

allow by pressing Ctrl+J simultaneously to highlight the current text, copy to clipboard and convert.

I hope I will be able to facilitate your small contribution making mathematical articles here and on other sites that don't support LaTeX.

Good luck!
Article based on information from habrahabr.ru

Comments

Popular posts from this blog

Powershell and Cyrillic in the console (updated)

Active/Passive PostgreSQL Cluster, using Pacemaker, Corosync

Automatic deployment ElasticBeanstalk using Bitbucket Pipelines