diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..a7a3be7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +language: python +python: + - "3.6" +install: + - wget https://github.com/jgm/pandoc/releases/download/2.8.1/pandoc-2.8.1-1-amd64.deb + - sudo dpkg -i pandoc-2.8.1-1-amd64.deb + - pandoc -v + - pip install -e .[test] + - pip install black + - pip install pylint + - pip install coverage + - pip install coveralls +script: + - black --check pandoc_beamer_arrow.py setup.py tests/test_arrow.py + - pylint pandoc_beamer_arrow.py setup.py + - coverage run -a --source=pandoc_beamer_arrow setup.py test +after_success: + - coveralls + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5fa142e --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2019, Christophe Demko +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..b42efab --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +include README.md +include LICENSE +include MANIFEST.in + diff --git a/README.md b/README.md new file mode 100644 index 0000000..636300d --- /dev/null +++ b/README.md @@ -0,0 +1,76 @@ +# pandoc-beamer-arrow +[![Build Status](https://img.shields.io/travis/chdemko/pandoc-beamer-arrow/0.1.0.svg?logo=travis)](https://travis-ci.org/chdemko/pandoc-beamer-arrow/branches) +[![Coveralls](https://img.shields.io/coveralls/github/chdemko/pandoc-beamer-arrow/0.1.0.svg?logo=Codecov&logoColor=white)](https://coveralls.io/github/chdemko/pandoc-beamer-arrow?branch=0.1.0) +[![Code Climate](https://codeclimate.com/github/chdemko/pandoc-beamer-arrow/badges/gpa.svg)](https://codeclimate.com/github/chdemko/pandoc-beamer-arrow/) +[![Code Beat](https://codebeat.co/badges/4d7e44d2-04ed-4c66-b8d2-ea1d28bc16ee)](https://codebeat.co/projects/github-com-chdemko-pandoc-beamer-arrow-develop/) +[![Codacy](https://img.shields.io/codacy/grade/5e04e80fe4124ea18911026086fdafe9.svg?logo=codacy&logoColor=white)](https://www.codacy.com/app/chdemko/pandoc-beamer-arrow) +[![CodeFactor](https://www.codefactor.io/repository/github/chdemko/pandoc-beamer-arrow/badge)](https://www.codefactor.io/repository/github/chdemko/pandoc-beamer-arrow) +[![PyPI version](https://img.shields.io/pypi/v/pandoc-beamer-arrow.svg?logo=Python&logoColor=white)](https://pypi.org/project/pandoc-beamer-arrow/) +[![PyPI format](https://img.shields.io/pypi/format/pandoc-beamer-arrow.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4gwPFiYw92eBNAAAAgJJREFUeNrt3T1WwkAUgNH31Br3ogWptdAlgyvQxYgHeh0LKKxI+PHAzNyvRo8xlxl5CZKllBIaax0Rr5n53tqB3Ti3k7qPiEUpZQAAggEACAYAIBgAgGAAoG8Ey9oRAHBas9oR5NgcIDOz5TN4pjnIJiJeapwTWAFGfMR2CDRlJViUUuYAtAfgOSK+Jv5N8FbddlBGav4M7+9795jHUsqqTGtdFQIAxgE0jQCAaQCaRQDAdABNIgDgMADNIQDgcAB/EHxWjwCA4wDsvvahegQAHA+gCQQAnAagegQAnA6gagQAnAdArQhcDdx//D+ZeXvg95tHxDK21wbG2mTm/SWP38Wgcz+jMj8i4ikiVhMePrv0z3vnlO1/grS+DVoBehfuVwCAABAAAkAAqLO6nwP896Tz2ucIVgBbgAAQAAJAAAgAASAABIAAEAACQAAIADXZyfcD9P55A7W/c8oKYAsQAAJAAAgAASBzgJ5eB1sBBIAAEAACQAAIAJkDTM/9AO4HEAACQAAIAAEgANTPHMD9AFYAASAABIAAEAACQP3MAWq/H6D3OYYVwBYgAASAABAAAkDmAF5HWwEEgAAQAAJAAAgAASAABIAAEAACQAAIAAEgAASAABAAAkAACAABIAAEgAAQAAJAAAgAXVWj/x+g988FtAIIAAEgAASAABAAaqhfB1BFkJjdTNQAAAAASUVORK5CYII=)](https://pypi.org/project/pandoc-beamer-arrow/) +[![License](https://img.shields.io/pypi/l/pandoc-beamer-arrow.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAABmCAYAAAADI5lUAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4gwPFiQKA106BAAABUNJREFUeNrtnV2IFlUYx3/P625qbrGlpWmWdaMVKau2EmpCrSDqxRpUUkr0SYVEFyFRUXQhfUAihTdCESVpKpKQpLZBsghltn605VVKpmZgGYvmbhpPFzMbWu3LO7szO1//H+zN7sw5c57nd8685+zMeY0quLsB04FW4A7gWmAMMAyRRbqBE8BRYCfwMfCNmXlfJ1iV5LcAbwBNimuu+Q54xcw21iSAuzcA7wOLFLtCsQl4yMxO9ymAu48HtgK3Kl6F5ACw0Mx++o8AYc/fBUxWnArN98DtZtYFULngDx8o+aXgZuDdi0YAd58fDv2iPMwzs+0WTvX2qfeXjv1Ak7n7DOBLxaOU3FYhWOQR5aS1AsxWHErLnArB8q4oJ+PM3buBoRFO6gJ2K3aZpBm4PMLxPXh09ijO2cTd90RNZkVhKzcSQAIICSAkgJAAQgIICSAkgJAAQgIICSAKT91gVOLui4EVKbZzvZm9kGD7rgHmEbw9NRoYCTQCvwInCd7UaQPaep/GLZUABP+ivDHFdo5KKPHTgNeAu6jyllXIk8A5d/8QeN7MjusWkGPcfRnBs5QtNSS/l3rgQaDT3e+UAPlN/iPA2wMYQa8APnH3ZgmQv+SPBlbGUNRw4D13r5MA+WIF0R67qsZNwMMSID+9vwF4IOZin5AA+WE+8W+O0eTuN0iAfNCSs3IlQMxMSqjciRIgH0wsmgCDNQU5CKxJMXHtMXwAHAJcndD1jSu0AGbWHkcSUmZEgmVfqltA9kkySQ0SIPsMyWnZEiAm/kiw7DMSIPt0AecSKvukBMg4ZvYXcCSh4g9LgHzwVc7KzcY00N0XAM+kmLitZrYqhnLagPsTuL7PCy0AwUJHS4oCHMpwok4AnboF5ONzwJFwFIiTd6pt5y4BssebMZbVA6xOszESIDrbiW+TrDVm9rMEyNdtwIHHgPMDLOoX4KW02yMB+ifBAWCgs4qnzex3CZBfXgS+7ee568xsQxYaIQH6Pwr0ELzk8WfEU48Dy7LSDgkwMAn2Eu2dRwceNbPfJEBxeD3s1bWwzcw+zdLFD9ZK4DHiX0CJwsEkbwXuvrrGkWBl5vTVXsGxxHBaDXE76+71CV+H9gpOiRM1HHPKzM5l7cIlQDxcX8Mxo9x9uAQoJktqOKYeuE8CFO/+P5NgabgWXnX3sRKgOMmfDWyJMJsaA+xw9wkSIN+Jr7j7U+HUdmTE028Bdrv73NKsA4Q9ZUmK7Ww3s7UxtaUZeAuYMYBirgpHgg3AcjP7sdACEOyE8XjKsq8dSI8H5gLPEu+jbfcCi9x9PbDKzDqKKkBeh/rpwN0Eu4Jcl1A19cBSYKm77wXWAZvN7AcJkG7ypwBfD3K1TeHPy+7eaGbnk65QHwL7ZlKKdY8AxmsWkC5XlqF+CdA3jWWoXwL0TUPK9V8mAdLlkpTrr5cA6VInAcpNfRnqHyzLu4jvBc3+0J8NGE6lfM1nB6UWPRJWHPRImNBnACEBhAQQEkBIACEBhAQQEkBIACEBhAQQ/8bcvRsYGuGcLuLbJ0/ESzPRvtW0x9z9MDBBsSslhyoE27eIcnKsAuxUHErLFxWC15tFOdli7m7AXmCK4lEq9gFTK+Hmx88pHqVjuZkFj4SZ2TZgs2JSGjaa2WcA1vsbd28AdgGTFZ9Csx+YaWZn4IKVQDM7DSwIDxDFve8v7E3+RQKEEhwFZgGbFKvC8REwK8wx/ytA70hgZvcQbInSobjlns6w1y++sOf/k+9qZ4ZTxKlAKzCH4OvfxgLDFNdM0k2wc/lRggW+LUBHtW8l+xuWwqBw5I0ApAAAAABJRU5ErkJggg==)](https://raw.githubusercontent.com/chdemko/pandoc-beamer-arrow/0.1.0/LICENSE) +[![Python version](https://img.shields.io/pypi/pyversions/pandoc-beamer-arrow.svg?logo=Python&logoColor=white)](https://pypi.org/project/pandoc-beamer-arrow/) +[![Downloads](https://pepy.tech/badge/pandoc-beamer-arrow)](https://pepy.tech/project/pandoc-beamer-arrow) +[![Development Status](https://img.shields.io/pypi/status/pandoc-beamer-arrow.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4gwPFiUnX5lXMAAAAlBJREFUeNrt3b1qlEEUBuB3TNDCP7wDOwv/cgv+pDC3YcDe+xBFFFLoDWhhpxiD12Ch1mJsg7irjRLGYjcKEbLC92n223meMgQSzrx7Zs6wMAkAAAAAAAAAAAAAAAAAAAAw78r+H9RaLyZZT3Itydkkx5XpUH1L8iHJVpJHpZS3/yQAtdZjSe4muZXkiLrPpd0kG0lul1K+9xaA6eK/SHJFjQfhdZIbfYRg75N+z+IPytUkd3rpANM9/422P8jt4HIp5V3XDrBu8QdpKcnNPraA62o5WKt9bAHjJCfUcpDGpZRTXQNQ1fGAApVSDvPvz1qfrv+fvb9xAiAACACDVf80qrU+q7Wecwhs4BB4gM+ZXBRt6wBtOpO/uC7WARa3AyTJqJRyWgdo18xLIgEwBSAACABt3hOYAhZ7Cph9TyAAzQYgSZ4KQNsBGAlA2wFwCDQFIAAIAAKAACAACAACgAAgAAgAAoAAIAAIAIvniwC07aVvBM2wwN8I2kmyogO0Z5TkSZKVUsqnZfVou4PpAKYABAABYDHnfAFofM6feUh0D7Cw9wA7e6OeDtDwnD/rl90DNN6hdABTAAJAs5aTjJOcVIreT+H/68DXuQNsW+bB+thHAF6p42Btdp4iaq0XMnk2bkk9B2U3yaVSyvtOHWD6Fu2Geg7Ow66Ln/x+OvZokueZPBjN/NtKslZK+dHLGDh9g3YtyYNpa2F+2/79vhb/VwfYN/acz+RFytVMno/3puDh+prJ8/GbSR730fYBAAAAAAAAAAAAAAAAAACAYfkJuHbYr8dtGYwAAAAASUVORK5CYII=)](https://pypi.org/project/pandoc-beamer-arrow/) +[![Docs](https://img.shields.io/readthedocs/pandoc-beamer-arrow.svg?logo=read-the-docs&logoColor=white)](http://pandoc-beamer-arrow.readthedocs.io/en/latest/) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANwSURBVGiB7Zndi1VlFIefNZPR9GkTmSkOhIZYeBFiIDEYNUREXVQEQUhK4hdEf0GQf0IUU2BdhHUjNQTpRRdl0NdFXYRZCA0SJTZ9CJEDmY49Xewzw57Xfc7+OGfOEJzn5vCuvfbav/Wutd+993tgwIAB/2ui3xdUVwKPAbcDPwDHIuJiv3XURr1HPaTOuphpdeNy6ytEvUbdoX5pZ75Xr15uvQuoa9WX1N9KhOfZsdyih9QJ9Yg6V0P4PF8sl/CV6gvq6QaiU7b0U/g29bB6oQfC5znUD+HXqu/2UHSeWbNltjJDDXKYBJ4EfgFeBo42iNGO64BnexhvMeoqsxt0Vh3L2V/tYRVOqZUfsHUrcCcwDJyKiJ9y9g9rxunERuDBqs51Ezjb+t2UrwDwcM04Zeyv6lj7XUj9GtgCzABHgA3AI3XjlDAH3BERZ3ocF9TnetjvnThYRU+TCowAZ4DRuufWZAYYi4hLnZxqL6MR8TfwVlNVNVgNPL4kkdUN6uU+tNEnZVo6VkC9tcgeEdPAR83Sr8V29e5ODmUttLvDscn6ehpReUldhLpebTvL6rD6Yx/a6C/1xnY6OlVgf6fjEXEZeKPSbHTHDcAztc5QR9Q/1OOJfSgZr1b/6UMVTrTT2m6GnwZuKbBvVRfW/4iYAaaqT01jNqvjRQfaJdDuxhkBdia21xqKqku1m9ls+2OetIXuN9sGSVvpRB/a6KK6JtVbVIHnS3JcD0wktterTE6XrAB2pcZ0JkfJ+r+MA8n4MHC+sbTq7FGH84a0AjvJ+ryMR819D0TEeeDtruWVMwbcmzcsJGD2GbevYqBhYE9i69eTeVV+kK/ANrJPxqrsNrcdGBEngU+701aJb/ODfAJ1xAPcBjyR2Ja6Cu9FxOm8IZ/AdIOA6c08RfYhshQcB/amxnwCXwHf1Qw6rm6eH7T2+d9sJK+YObJJmYiIByLiXEfv1kPs15IHWcpk4rPOZpu7ec6qB9W1tVNWR9UX1Z8LEhgvuNgVr7vq+w1E/6t+rD6lrqgtvCCRq0x2i9U1rQulHEj8Hqoh/E/1FXVT16IrJjZVIOJk4hPqZyXCv1H3qtf3RXhO3M3qsQJB2xO/dS2ReS6o76j39UpP438p1QlgK3BTy/R5RHyQ+AyRbTveBZwDjkbE702vOWDAgCv5DyyzjR7/CUzHAAAAAElFTkSuQmCC)](https://pypi.org/project/black/) + +*pandoc-beamer-arrow* is a [pandoc] filter for adding admonition to `div`s or `codeblock`s elements. + +It uses the *tcolorbox* LaTeX package to generate admonitions and the *footnote* LaTeX package to handle correctly footnotes in admonition. + +[pandoc]: http://pandoc.org/ + +Documentation +------------- + +See the [Read the docs pages](http://pandoc-beamer-arrow.readthedocs.io/en/0.1.0/). + +Usage +----- + +To apply the filter, use the following option with pandoc: + + --filter pandoc-beamer-arrow + +Installation +------------ + +*pandoc-beamer-arrow* requires [python 3.6], a programming language that comes pre-installed on linux and Mac OS X, and which is easily installed [on Windows]. + +Install *pandoc-beamer-arrow* as root using the bash command + + pip install pandoc-beamer-arrow + +To upgrade to the most recent release, use + + pip install --upgrade pandoc-beamer-arrow + +To upgrade to the current code, use + + pip install --upgrade --force git+https://github.com/chdemko/pandoc-beamer-arrow + +`pip` is a script that downloads and installs modules from the Python Package Index, [PyPI]. It should come installed with your python distribution. If you are running linux, `pip` may be bundled separately. On a Debian-based system (including Ubuntu), you can install it as root using + + apt-get update + apt-get install python-pip + +Make sure you have the + +* *xcolor* + +LaTeX packages. On linux you have to install some extra libraries **before** *pandoc-beamer-arrow*. On a Debian-based system (including Ubuntu), you can install it as root using + + apt-get texlive-latex-extra + +[python 3.6]: https://www.python.org +[on Windows]: https://www.python.org/downloads/windows +[PyPI]: https://pypi.org + + +Getting Help +------------ + +If you have any difficulties with pandoc-beamer-arrow, please feel welcome to [file an issue] on github so that we can help. + +[file an issue]: https://github.com/chdemko/pandoc-beamer-arrow/issues + diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..7a31e2d --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,196 @@ +# -*- coding: utf-8 -*- +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/master/config + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + +import os +import sys + +sys.path.insert(0, os.path.abspath("../..")) + +on_rtd = os.environ.get("READTHEDOCS", None) == "True" + +# -- Project information ----------------------------------------------------- + +project = "pandoc-beamer-arrow" +copyright = "2019, Christophe Demko" +author = "Christophe Demko" + +# The short X.Y version +version = "0.1" +# The full version, including alpha/beta/rc tags +release = "0.1.0" + +# -- General configuration --------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' +needs_sphinx = "2.2" + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [] + +# Add any paths that contain templates here, relative to this directory. +templates_path = [] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = ".rst" + +# The master toctree document. +master_doc = "index" + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + +# The name of the Pygments (syntax highlighting) style to use. +# pygments_style = None +pygments_style = "sphinx" + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +if not on_rtd: # only import and set the theme if we're building docs locally + import sphinx_rtd_theme + + html_theme = "sphinx_rtd_theme" + html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = [] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- Options for HTMLHelp output --------------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = "pandoc-latex-admonitiondoc" + + +# -- Options for LaTeX output ------------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + master_doc, + "pandoc-latex-admonition.tex", + "pandoc-latex-admonition Documentation", + "Christophe Demko", + "manual", + ) +] + + +# -- Options for manual page output ------------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + master_doc, + "pandoc-latex-admonition", + "pandoc-latex-admonition Documentation", + [author], + 1, + ) +] + + +# -- Options for Texinfo output ---------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + master_doc, + "pandoc-latex-admonition", + "pandoc-latex-admonition Documentation", + author, + "pandoc-latex-admonition", + "One line description of project.", + "Miscellaneous", + ) +] + + +# -- Options for Epub output ------------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = project + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +# +# epub_identifier = '' + +# A unique identification for the text. +# +# epub_uid = '' + +# A list of files that should not be packed into the epub file. +epub_exclude_files = ["search.html"] diff --git a/docs/images/pandoc-beamer-arrow-sample.pdf b/docs/images/pandoc-beamer-arrow-sample.pdf new file mode 100644 index 0000000..68388be Binary files /dev/null and b/docs/images/pandoc-beamer-arrow-sample.pdf differ diff --git a/docs/images/pandoc-beamer-arrow-sample.txt b/docs/images/pandoc-beamer-arrow-sample.txt new file mode 100644 index 0000000..6dde01b --- /dev/null +++ b/docs/images/pandoc-beamer-arrow-sample.txt @@ -0,0 +1,14 @@ +[**abc**]{.beamer-arrow-node #id1} +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer auctor blandit felis ut +elementum. Donec accumsan ex at orci volutpat iaculis. Proin in risus metus. Nunc sit amet +auctor nunc, quis consectetur turpis. Maecenas gravida blandit odio vitae dignissim. In +maximus purus quis enim molestie iaculis. Quisque ut urna nec justo dictum accumsan ut +quis odio. Sed nulla erat, posuere at sapien tempus, venenatis vulputate mi. Nam pretium +sem id enim condimentum, vel porttitor dolor viverra. Sed commodo est sit amet nisi +pharetra lacinia. Vivamus consectetur ut mauris quis posuere. Pellentesque eget ipsum et +nibh ullamcorper ullamcorper eget eu velit. +[**def**]{.beamer-arrow-node #id2 color="pink" from="2"} Pellentesque eget ipsum et nibh +ullamcorper ullamcorper eget eu velit. +[**ghi**]{.beamer-arrow-node from="2"} + +[]{.beamer-arrow-edge src="id1" dest="id2" angle_src="90" color="pink" linewidth="3" from="2"} diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..8d93ccc --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,20 @@ +.. pandoc-numbering documentation master file, created by + sphinx-quickstart on Mon Dec 17 11:33:59 2018. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to pandoc-beamer-arrow's documentation! +=================================================== + +Explanation +----------- + +*pandoc-beamer-arrow* creates arrows between text elements for beamer presentation. + +Example +------- + +Demonstration: Using +:download:`pandoc-beamer-arrow-sample.txt ` +as input gives output file in +:download:`pdf `. diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..b57ad2e --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,3 @@ +Sphinx>=2.2 +sphinx_rtd_theme>=0.4 + diff --git a/pandoc_beamer_arrow.py b/pandoc_beamer_arrow.py new file mode 100644 index 0000000..e3894f6 --- /dev/null +++ b/pandoc_beamer_arrow.py @@ -0,0 +1,397 @@ +#!/usr/bin/env python + +""" +Pandoc filter for adding admonition in LaTeX +""" +from panflute import ( + run_filter, + RawInline, + MetaList, + MetaInlines, + convert_text, + Plain, + debug, +) + + +def x11colors(): + """ + Get the x11 colors + + Returns + ------- + The x11 colors + """ + # See https://www.w3.org/TR/css-color-3/#svg-color + return { + "aliceblue": "F0F8FF", + "antiquewhite": "FAEBD7", + "aqua": "00FFFF", + "aquamarine": "7FFFD4", + "azure": "F0FFFF", + "beige": "F5F5DC", + "bisque": "FFE4C4", + "black": "000000", + "blanchedalmond": "FFEBCD", + "blue": "0000FF", + "blueviolet": "8A2BE2", + "brown": "A52A2A", + "burlywood": "DEB887", + "cadetblue": "5F9EA0", + "chartreuse": "7FFF00", + "chocolate": "D2691E", + "coral": "FF7F50", + "cornflowerblue": "6495ED", + "cornsilk": "FFF8DC", + "crimson": "DC143C", + "cyan": "00FFFF", + "darkblue": "00008B", + "darkcyan": "008B8B", + "darkgoldenrod": "B8860B", + "darkgray": "A9A9A9", + "darkgreen": "006400", + "darkgrey": "A9A9A9", + "darkkhaki": "BDB76B", + "darkmagenta": "8B008B", + "darkolivegreen": "556B2F", + "darkorange": "FF8C00", + "darkorchid": "9932CC", + "darkred": "8B0000", + "darksalmon": "E9967A", + "darkseagreen": "8FBC8F", + "darkslateblue": "483D8B", + "darkslategray": "2F4F4F", + "darkslategrey": "2F4F4F", + "darkturquoise": "00CED1", + "darkviolet": "9400D3", + "deeppink": "FF1493", + "deepskyblue": "00BFFF", + "dimgray": "696969", + "dimgrey": "696969", + "dodgerblue": "1E90FF", + "firebrick": "B22222", + "floralwhite": "FFFAF0", + "forestgreen": "228B22", + "fuchsia": "FF00FF", + "gainsboro": "DCDCDC", + "ghostwhite": "F8F8FF", + "gold": "FFD700", + "goldenrod": "DAA520", + "gray": "808080", + "green": "008000", + "greenyellow": "ADFF2F", + "grey": "808080", + "honeydew": "F0FFF0", + "hotpink": "FF69B4", + "indianred": "CD5C5C", + "indigo": "4B0082", + "ivory": "FFFFF0", + "khaki": "F0E68C", + "lavender": "E6E6FA", + "lavenderblush": "FFF0F5", + "lawngreen": "7CFC00", + "lemonchiffon": "FFFACD", + "lightblue": "ADD8E6", + "lightcoral": "F08080", + "lightcyan": "E0FFFF", + "lightgoldenrodyellow": "FAFAD2", + "lightgray": "D3D3D3", + "lightgreen": "90EE90", + "lightgrey": "D3D3D3", + "lightpink": "FFB6C1", + "lightsalmon": "FFA07A", + "lightseagreen": "20B2AA", + "lightskyblue": "87CEFA", + "lightslategray": "778899", + "lightslategrey": "778899", + "lightsteelblue": "B0C4DE", + "lightyellow": "FFFFE0", + "lime": "00FF00", + "limegreen": "32CD32", + "linen": "FAF0E6", + "magenta": "FF00FF", + "maroon": "800000", + "mediumaquamarine": "66CDAA", + "mediumblue": "0000CD", + "mediumorchid": "BA55D3", + "mediumpurple": "9370DB", + "mediumseagreen": "3CB371", + "mediumslateblue": "7B68EE", + "mediumspringgreen": "00FA9A", + "mediumturquoise": "48D1CC", + "mediumvioletred": "C71585", + "midnightblue": "191970", + "mintcream": "F5FFFA", + "mistyrose": "FFE4E1", + "moccasin": "FFE4B5", + "navajowhite": "FFDEAD", + "navy": "000080", + "oldlace": "FDF5E6", + "olive": "808000", + "olivedrab": "6B8E23", + "orange": "FFA500", + "orangered": "FF4500", + "orchid": "DA70D6", + "palegoldenrod": "EEE8AA", + "palegreen": "98FB98", + "paleturquoise": "AFEEEE", + "palevioletred": "DB7093", + "papayawhip": "FFEFD5", + "peachpuff": "FFDAB9", + "peru": "CD853F", + "pink": "FFC0CB", + "plum": "DDA0DD", + "powderblue": "B0E0E6", + "purple": "800080", + "red": "FF0000", + "rosybrown": "BC8F8F", + "royalblue": "4169E1", + "saddlebrown": "8B4513", + "salmon": "FA8072", + "sandybrown": "F4A460", + "seagreen": "2E8B57", + "seashell": "FFF5EE", + "sienna": "A0522D", + "silver": "C0C0C0", + "skyblue": "87CEEB", + "slateblue": "6A5ACD", + "slategray": "708090", + "slategrey": "708090", + "snow": "FFFAFA", + "springgreen": "00FF7F", + "steelblue": "4682B4", + "tan": "D2B48C", + "teal": "008080", + "thistle": "D8BFD8", + "tomato": "FF6347", + "turquoise": "40E0D0", + "violet": "EE82EE", + "wheat": "F5DEB3", + "white": "FFFFFF", + "whitesmoke": "F5F5F5", + "yellow": "FFFF00", + "yellowgreen": "9ACD32", + } + + +# pylint: disable=inconsistent-return-statements,too-many-branches,too-many-statements +def tikz(elem, doc): + """ + Add admonition to elem + + Arguments + --------- + elem: + The current element + doc: + The pandoc document + + Returns + ------- + The modified element + """ + # Is it in the right format and is it Div or a CodeBlock? + if doc.format in ["beamer"] and elem.tag in ["Span"]: + # Is there a latex-admonition-color attribute? + if "beamer-arrow-node" in elem.classes: + text = convert_text( + Plain(*elem.content), input_format="panflute", output_format="latex" + ) + + options = ["anchor=base"] + + color = get_color(elem, doc) + if color: + options.append(f"fill={color}") + + (from_value, to_value) = get_range(elem, doc) + if from_value or to_value: + display = f"\\only<{from_value}-{to_value}>" + else: + display = "" + + return RawInline( + f"\\tikz[baseline]{{" + f"{display}{{\\node[{','.join(options)}] " + f"({elem.identifier}) " + f"{{{text}}}" + f";}}}}", + format="tex", + ) + + if "beamer-arrow-edge" in elem.classes: + angles = [] + if "angle_src" in elem.attributes: + try: + angle = elem.attributes["angle_src"] + angle = int(angle) + angles.append(f"in={angle}") + except ValueError: + debug(f"pandoc-beamer-arrow: angle_src '{angle}' is not correct") + + if "angle_dest" in elem.attributes: + try: + angle = elem.attributes["angle_dest"] + angle = int(angle) + angles.append(f"out={angle}") + except ValueError: + debug(f"pandoc-beamer-arrow: angle_dest '{angle}' is not correct") + + options = ["->"] + + color = get_color(elem, doc) + if color: + options.append(color) + + if "linewidth" in elem.attributes: + try: + linewidth = elem.attributes["linewidth"] + linewidth = int(linewidth) + options.append(f"line width={linewidth}pt") + except ValueError: + debug( + f"pandoc-beamer-arrow: linewidth '{linewidth}' is not correct" + ) + + (from_value, to_value) = get_range(elem, doc) + if from_value or to_value: + display = f"<{from_value}-{to_value}>" + else: + display = "" + + return RawInline( + f"\\begin{{tikzpicture}}[overlay]" + f"\\path[{','.join(options)}]{display} " + f"({elem.attributes['src']}) " + f"edge " + f"[{','.join(angles)}] " + f"({elem.attributes['dest']});" + f"\\end{{tikzpicture}}", + format="tex", + ) + + +def get_range(elem, _): + """ + Get the range of display for an element. + """ + from_value = elem.attributes.get("from", "") + if bool(from_value): + try: + from_value = max(1, int(from_value)) + except ValueError: + debug(f"pandoc-beamer-arrow: from value '{from_value}' is not " f"correct") + from_value = "" + else: + from_value = "" + + to_value = elem.attributes.get("to", "") + if bool(to_value): + try: + to_value = max(1, int(to_value)) + except ValueError: + debug(f"pandoc-beamer-arrow: to value '{to_value}' is not " f"correct") + to_value = "" + else: + to_value = "" + + try: + if to_value < from_value: + debug( + f"pandoc-beamer-arrow: from value '{from_value}' and " + f" to value '{to_value}' are incompatible" + ) + from_value = "" + to_value = "" + except TypeError: + pass + + return (from_value, to_value) + + +def get_color(elem, doc): + """ + Get the color of display for an element. + """ + if "color" in elem.attributes: + color = elem.attributes["color"] + if color in doc.x11colors: + return color + debug(f"pandoc-beamer-arrow: color '{color}' is not correct") + return "" + + +def prepare(doc): + """ + Prepare the document + + Arguments + --------- + doc: + The pandoc document + """ + doc.x11colors = x11colors() + + +def finalize(doc): + """ + Finalize the pandoc document + + Arguments + --------- + doc: + The pandoc document + """ + # Add header-includes if necessary + if "header-includes" not in doc.metadata: + doc.metadata["header-includes"] = MetaList() + # Convert header-includes to MetaList if necessary + elif not isinstance(doc.metadata["header-includes"], MetaList): + doc.metadata["header-includes"] = MetaList(doc.metadata["header-includes"]) + + # Add usefull LaTexPackage + doc.metadata["header-includes"].append( + MetaInlines(RawInline("\\usepackage{tikz}", "tex")) + ) + doc.metadata["header-includes"].append( + MetaInlines(RawInline("\\tikzstyle{every picture}+=[remember picture]", "tex")) + ) + doc.metadata["header-includes"].append( + MetaInlines(RawInline("\\usetikzlibrary{positioning}", "tex")) + ) + doc.metadata["header-includes"].append( + MetaInlines( + RawInline( + "\\tikzset{onslide/.code args={<#1>#2}{\\only<#1>{\\pgfkeysalso{#2}}}}", + "tex", + ) + ) + ) + + # Define x11 colors + tex = [] + for name, color in doc.x11colors.items(): + tex.append("\\definecolor{" + name.lower() + "}{HTML}{" + color + "}") + doc.metadata["header-includes"].append( + MetaInlines(RawInline("\n".join(tex), "tex")) + ) + + +def main(doc=None): + """ + Main function called by the script. + + Arguments + --------- + doc: + The pandoc document + + Returns + ------- + The modified pandoc document + """ + return run_filter(tikz, prepare=prepare, finalize=finalize, doc=doc) + + +if __name__ == "__main__": + main() diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..ee9c50a --- /dev/null +++ b/setup.cfg @@ -0,0 +1,11 @@ +[bdist_wheel] +# This flag says that the code is written to work on both Python 2 and Python +# 3. If at all possible, it is good practice to do this. If you cannot, you +# will need to generate wheels for each Python version that you support. +universal=1 + +[metadata] +description-file = README.md + +[aliases] +test=pytest diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..1f4804a --- /dev/null +++ b/setup.py @@ -0,0 +1,91 @@ +"""A setuptools based setup module. + +See: +https://packaging.python.org/en/latest/distributing.html +https://github.com/chdemko/pandoc-beamer-arrow +""" + +# To use a consistent encoding +import codecs +import os + +# Always prefer setuptools over distutils +from setuptools import setup + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# Get the long description from the README file +try: + import pypandoc + + LONG_DESCRIPTION = pypandoc.convert("README.md", "rst") +except (IOError, ImportError): + with codecs.open(os.path.join(HERE, "README.md"), encoding="utf-8") as f: + LONG_DESCRIPTION = f.read() + + +setup( + name="pandoc-beamer-arrow", + # Versions should comply with PEP440. For a discussion on single-sourcing + # the version across setup.py and the project code, see + # https://packaging.python.org/en/latest/single_source_version.html + version="0.1.0", + # The project's description + description="A pandoc filter for adding arrows in Beamer/LaTeX", + long_description=LONG_DESCRIPTION, + # The project's main homepage. + url="https://github.com/chdemko/pandoc-beamer-arrow", + # The project's download page + download_url="https://github.com/chdemko/pandoc-beamer-arrow/archive/develop.zip", + # Author details + author="Christophe Demko", + author_email="chdemko@gmail.com", + # Maintainer details + maintainer="Christophe Demko", + maintainer_email="chdemko@gmail.com", + # Choose your license + license="BSD-3-Clause", + # See https://pypi.python.org/pypi?%3Aaction=list_classifiers + classifiers=[ + # How mature is this project? Common values are + # 3 - Alpha + # 4 - Beta + # 5 - Production/Stable + "Development Status :: 4 - Beta", + # Specify the OS + "Operating System :: OS Independent", + # Indicate who your project is intended for + "Environment :: Console", + "Intended Audience :: End Users/Desktop", + "Intended Audience :: Developers", + "Topic :: Software Development :: Build Tools", + # Specify the Python versions you support here. In particular, ensure + # that you indicate whether you support Python 2, Python 3 or both. + "Programming Language :: Python :: 3.6", + ], + # What does your project relate to? + keywords="pandoc filters beamer arrows", + # Alternatively, if you want to distribute just a my_module.py, uncomment + # this: + py_modules=["pandoc_beamer_arrow"], + # To provide executable scripts, use entry points in preference to the + # "scripts" keyword. Entry points provide cross-platform support and allow + # pip to create the appropriate form of executable for the target platform. + entry_points={ + "console_scripts": ["pandoc-beamer-arrow = pandoc_beamer_arrow:main"] + }, + # List run-time dependencies here. These will be installed by pip when + # your project is installed. For an analysis of "install_requires" vs pip's + # requirements files see: + # https://packaging.python.org/en/latest/requirements.html + install_requires=["panflute>=1.12", "pypandoc>=1.4"], + # List additional groups of dependencies here (e.g. development + # dependencies). You can install these using the following syntax, + # for example: + # $ pip install -e .[dev,test] + extras_require={"dev": ["check-manifest"], "test": ["coverage"]}, + # packages=find_packages(), + # include_package_data = True, + setup_requires=["pytest-runner"], + tests_require=["pytest", "coverage"], +) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_arrow.py b/tests/test_arrow.py new file mode 100644 index 0000000..b1bf0ba --- /dev/null +++ b/tests/test_arrow.py @@ -0,0 +1,329 @@ +# This Python file uses the following encoding: utf-8 + +import io +from contextlib import redirect_stderr +from unittest import TestCase + +from panflute import convert_text + +import pandoc_beamer_arrow + + +def conversion(markdown, fmt="markdown"): + doc = convert_text(markdown, standalone=True) + doc.format = fmt + pandoc_beamer_arrow.main(doc) + return doc + + +class NodeTest(TestCase): + def test_simple(self): + doc = conversion("[**abc**]{.beamer-arrow-node #id1}", fmt="beamer") + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, r"\tikz[baseline]{{\node[anchor=base] (id1) {\textbf{abc}};}}" + ) + + def test_color(self): + doc = conversion('[**abc**]{.beamer-arrow-node #id1 color="red"}', fmt="beamer") + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, + r"\tikz[baseline]{{\node[anchor=base,fill=red] (id1) {\textbf{abc}};}}", + ) + + def test_bad_color(self): + stream = io.StringIO() + with redirect_stderr(stream): + doc = conversion( + '[**abc**]{.beamer-arrow-node #id1 color="unknown"}', fmt="beamer" + ) + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, r"\tikz[baseline]{{\node[anchor=base] (id1) {\textbf{abc}};}}" + ) + self.assertEqual( + stream.getvalue(), + "pandoc-beamer-arrow: color 'unknown' is not correct\n", + ) + + def test_from(self): + doc = conversion('[**abc**]{.beamer-arrow-node #id1 from="2"}', fmt="beamer") + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, + r"\tikz[baseline]{\only<2->{\node[anchor=base] (id1) {\textbf{abc}};}}", + ) + + def test_bad_from(self): + stream = io.StringIO() + with redirect_stderr(stream): + doc = conversion( + '[**abc**]{.beamer-arrow-node #id1 from="bad"}', fmt="beamer" + ) + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, r"\tikz[baseline]{{\node[anchor=base] (id1) {\textbf{abc}};}}" + ) + self.assertEqual( + stream.getvalue(), + "pandoc-beamer-arrow: from value 'bad' is not correct\n", + ) + + def test_to(self): + doc = conversion('[**abc**]{.beamer-arrow-node #id1 to="2"}', fmt="beamer") + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, + r"\tikz[baseline]{\only<-2>{\node[anchor=base] (id1) {\textbf{abc}};}}", + ) + + def test_bad_to(self): + stream = io.StringIO() + with redirect_stderr(stream): + doc = conversion( + '[**abc**]{.beamer-arrow-node #id1 to="bad"}', fmt="beamer" + ) + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, r"\tikz[baseline]{{\node[anchor=base] (id1) {\textbf{abc}};}}" + ) + self.assertEqual( + stream.getvalue(), + "pandoc-beamer-arrow: to value 'bad' is not correct\n", + ) + + def test_incompatible_from_to(self): + stream = io.StringIO() + with redirect_stderr(stream): + doc = conversion( + '[**abc**]{.beamer-arrow-node #id1 from="2" to="1"}', fmt="beamer" + ) + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, r"\tikz[baseline]{{\node[anchor=base] (id1) {\textbf{abc}};}}" + ) + self.assertEqual( + stream.getvalue(), + "pandoc-beamer-arrow: from value '2' and to value '1' are incompatible\n", + ) + + +class ArrowTest(TestCase): + def test_simple(self): + doc = conversion( + '[**abc**]{.beamer-arrow-edge src="id1" dest="id2"}', fmt="beamer" + ) + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, + r"\begin{tikzpicture}" + r"[overlay]\path[->] (id1) edge [] (id2);" + r"\end{tikzpicture}", + ) + + def test_angle_src(self): + doc = conversion( + '[**abc**]{.beamer-arrow-edge src="id1" dest="id2" angle_src="90"}', + fmt="beamer", + ) + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, + r"\begin{tikzpicture}" + r"[overlay]\path[->] (id1) edge [in=90] (id2);" + r"\end{tikzpicture}", + ) + + def test_bad_angle_src(self): + stream = io.StringIO() + with redirect_stderr(stream): + doc = conversion( + '[**abc**]{.beamer-arrow-edge src="id1" dest="id2" angle_src="bad"}', + fmt="beamer", + ) + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, + r"\begin{tikzpicture}" + r"[overlay]\path[->] (id1) edge [] (id2);" + r"\end{tikzpicture}", + ) + self.assertEqual( + stream.getvalue(), + "pandoc-beamer-arrow: angle_src 'bad' is not correct\n", + ) + + def test_angle_dest(self): + doc = conversion( + '[**abc**]{.beamer-arrow-edge src="id1" dest="id2" angle_dest="90"}', + fmt="beamer", + ) + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, + r"\begin{tikzpicture}" + r"[overlay]\path[->] (id1) edge [out=90] (id2);" + r"\end{tikzpicture}", + ) + + def test_bad_angle_dest(self): + stream = io.StringIO() + with redirect_stderr(stream): + doc = conversion( + '[**abc**]{.beamer-arrow-edge src="id1" dest="id2" angle_dest="bad"}', + fmt="beamer", + ) + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, + r"\begin{tikzpicture}" + r"[overlay]\path[->] (id1) edge [] (id2);" + r"\end{tikzpicture}", + ) + self.assertEqual( + stream.getvalue(), + "pandoc-beamer-arrow: angle_dest 'bad' is not correct\n", + ) + + def test_color(self): + doc = conversion( + '[**abc**]{.beamer-arrow-edge src="id1" dest="id2" color="red"}', + fmt="beamer", + ) + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, + r"\begin{tikzpicture}" + r"[overlay]\path[->,red] (id1) edge [] (id2);" + r"\end{tikzpicture}", + ) + + def test_linewidth(self): + doc = conversion( + '[**abc**]{.beamer-arrow-edge src="id1" dest="id2" linewidth="3"}', + fmt="beamer", + ) + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, + r"\begin{tikzpicture}" + r"[overlay]\path[->,line width=3pt] (id1) edge [] (id2);" + r"\end{tikzpicture}", + ) + + def test_bad_linewidth(self): + stream = io.StringIO() + with redirect_stderr(stream): + doc = conversion( + '[**abc**]{.beamer-arrow-edge src="id1" dest="id2" linewidth="bad"}', + fmt="beamer", + ) + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, + r"\begin{tikzpicture}" + r"[overlay]\path[->] (id1) edge [] (id2);" + r"\end{tikzpicture}", + ) + self.assertEqual( + stream.getvalue(), + "pandoc-beamer-arrow: linewidth 'bad' is not correct\n", + ) + + def test_range(self): + doc = conversion( + '[**abc**]{.beamer-arrow-edge src="id1" dest="id2" to="3" from="2"}', + fmt="beamer", + ) + text = convert_text( + doc, + input_format="panflute", + output_format="latex", + extra_args=["--wrap=none"], + ) + self.assertEqual( + text, + r"\begin{tikzpicture}[overlay]\path[->]<2-3> (id1) edge [] (id2);\end{" + r"tikzpicture}", + ) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..f947f4e --- /dev/null +++ b/tox.ini @@ -0,0 +1,13 @@ +[tox] +envlist = py36,py37,py38 + +[testenv] +deps = + coverage + black + pylint + panflute>=1.12 +commands = + black --check pandoc_beamer_arrow.py setup.py tests/test_arrow.py docs/conf.py + coverage run -a --source=pandoc_beamer_arrow setup.py test + pylint pandoc_beamer_arrow.py setup.py