Name | latex JSON |
Version |
0.7.0
JSON |
| download |
home_page | http://github.com/mbr/latex |
Summary | Wrappers for calling LaTeX/building LaTeX documents. |
upload_time | 2017-11-16 12:33:12 |
maintainer | |
docs_url | https://pythonhosted.org/latex/ |
author | Marc Brinkmann |
requires_python | |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
latex
=====
Documentation can be found at https://pythonhosted.org/latex .
Allows calling LaTeX from Python without leaving a mess. Similar to the
(officially obsolete) `tex <https://pypi.python.org/pypi/tex/>`_ package, whose
`successor <http://www.profv.de/texcaller/>`_ is not PyPi-installable:
.. code-block:: python
min_latex = (r"\documentclass{article}"
r"\begin{document}"
r"Hello, world!"
r"\end{document}")
from latex import build_pdf
# this builds a pdf-file inside a temporary directory
pdf = build_pdf(min_latex)
# look at the first few bytes of the header
print bytes(pdf)[:10]
Also comes with support for using `Jinja2 <http://jinja.pocoo.org/>`_ templates
to generate LaTeX files.
``make_env`` can be used to create an ``Environment`` that plays well with
LaTex::
Variables can be used in a LaTeX friendly way: Hello, \VAR{name|e}.
Note that autoescaping is off. Blocks are creating using the block macro:
\BLOCK{if weather is 'good'}
Hooray.
\BLOCK{endif}
\#{comments are supported as well}
%# and so are line comments
To keep things short, line statements can be used:
%- if weather is good
Yay.
%- endif
Example use
-----------
.. code-block:: python
from jinja2.loaders import FileSystemLoader
from latex.jinja2 import make_env
env = make_env(loader=FileSystemLoader('.'))
tpl = env.get_template('doc.latex')
print(tpl.render(name="Alice"))
The ``base.latex`` demonstrates how ``\BLOCK{...}`` is substituted for
``{% ... %}``:
.. code-block:: latex
\documentclass{article}
\begin{document}
\BLOCK{block body}\BLOCK{endblock}
\end{document}
Finally, ``doc.latex`` shows why the ``%-`` syntax is usually preferable:
.. code-block:: latex
%- extends "base.latex"
%- block body
Hello, \VAR{name|e}.
%- endblock
Raw data
{
"_id": null,
"home_page": "http://github.com/mbr/latex",
"name": "latex",
"maintainer": "",
"docs_url": "https://pythonhosted.org/latex/",
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Marc Brinkmann",
"author_email": "git@marcbrinkmann.de",
"download_url": "https://files.pythonhosted.org/packages/e3/f3/c2562ee509faadaaf4f9d5b9491de146c6522ed2843dcecfd4f8e1a72f1d/latex-0.7.0.tar.gz",
"platform": "",
"description": "latex\n=====\n\nDocumentation can be found at https://pythonhosted.org/latex .\n\nAllows calling LaTeX from Python without leaving a mess. Similar to the\n(officially obsolete) `tex <https://pypi.python.org/pypi/tex/>`_ package, whose\n`successor <http://www.profv.de/texcaller/>`_ is not PyPi-installable:\n\n.. code-block:: python\n\n min_latex = (r\"\\documentclass{article}\"\n r\"\\begin{document}\"\n r\"Hello, world!\"\n r\"\\end{document}\")\n\n from latex import build_pdf\n\n # this builds a pdf-file inside a temporary directory\n pdf = build_pdf(min_latex)\n\n # look at the first few bytes of the header\n print bytes(pdf)[:10]\n\nAlso comes with support for using `Jinja2 <http://jinja.pocoo.org/>`_ templates\nto generate LaTeX files.\n\n``make_env`` can be used to create an ``Environment`` that plays well with\nLaTex::\n\n Variables can be used in a LaTeX friendly way: Hello, \\VAR{name|e}.\n\n Note that autoescaping is off. Blocks are creating using the block macro:\n\n \\BLOCK{if weather is 'good'}\n Hooray.\n \\BLOCK{endif}\n\n \\#{comments are supported as well}\n %# and so are line comments\n\n To keep things short, line statements can be used:\n\n %- if weather is good\n Yay.\n %- endif\n\n\nExample use\n-----------\n\n.. code-block:: python\n\n from jinja2.loaders import FileSystemLoader\n from latex.jinja2 import make_env\n\n env = make_env(loader=FileSystemLoader('.'))\n tpl = env.get_template('doc.latex')\n\n print(tpl.render(name=\"Alice\"))\n\nThe ``base.latex`` demonstrates how ``\\BLOCK{...}`` is substituted for\n``{% ... %}``:\n\n.. code-block:: latex\n\n \\documentclass{article}\n \\begin{document}\n \\BLOCK{block body}\\BLOCK{endblock}\n \\end{document}\n\nFinally, ``doc.latex`` shows why the ``%-`` syntax is usually preferable:\n\n.. code-block:: latex\n\n %- extends \"base.latex\"\n\n %- block body\n Hello, \\VAR{name|e}.\n %- endblock\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Wrappers for calling LaTeX/building LaTeX documents.",
"version": "0.7.0",
"project_urls": {
"Homepage": "http://github.com/mbr/latex"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e3f3c2562ee509faadaaf4f9d5b9491de146c6522ed2843dcecfd4f8e1a72f1d",
"md5": "13bcf3dc19136a535dd455f6546635d6",
"sha256": "bf10c3fe27e9f3adccebc12e90ec239c86dcba101b89221f6775918211482a79"
},
"downloads": -1,
"filename": "latex-0.7.0.tar.gz",
"has_sig": false,
"md5_digest": "13bcf3dc19136a535dd455f6546635d6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6523,
"upload_time": "2017-11-16T12:33:12",
"upload_time_iso_8601": "2017-11-16T12:33:12.526020Z",
"url": "https://files.pythonhosted.org/packages/e3/f3/c2562ee509faadaaf4f9d5b9491de146c6522ed2843dcecfd4f8e1a72f1d/latex-0.7.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2017-11-16 12:33:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mbr",
"github_project": "latex",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "latex"
}