diff --git a/tests/data/codefolding.ipynb b/tests/data/codefolding.ipynb
new file mode 100644
index 0000000..d170b99
--- /dev/null
+++ b/tests/data/codefolding.ipynb
@@ -0,0 +1,56 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "code_folding": [
+ 0
+ ],
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "# Codefolding test 1\n",
+ "'AXYZ12AXY'"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "code_folding": [
+ 1
+ ],
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "# Codefolding test 2\n",
+ "def myfun():\n",
+ " 'GR4CX32ZT'"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.5.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/tests/data/Untitled.ipynb b/tests/data/pymarkdown.ipynb
similarity index 78%
rename from tests/data/Untitled.ipynb
rename to tests/data/pymarkdown.ipynb
index ace058d..a2d8c33 100644
--- a/tests/data/Untitled.ipynb
+++ b/tests/data/pymarkdown.ipynb
@@ -2,27 +2,24 @@
"cells": [
{
"cell_type": "code",
- "execution_count": 30,
+ "execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
- "a=1"
+ "a = 'world'"
]
},
{
"cell_type": "markdown",
- "metadata": {},
+ "metadata": {
+ "variables": {
+ " a ": "world"
+ }
+ },
"source": [
- "Markdown Cell"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "
"
+ "Hello {{ a }}"
]
},
{
@@ -51,7 +48,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.4.1"
+ "version": "3.5.1"
}
},
"nbformat": 4,
diff --git a/tests/data/svg2pdf.ipynb b/tests/data/svg2pdf.ipynb
new file mode 100644
index 0000000..3c361fa
--- /dev/null
+++ b/tests/data/svg2pdf.ipynb
@@ -0,0 +1,64 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "$x=1$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "$ x=1$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\\\\( x=1^2 \\\\)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ ""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.5.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/tests/data/test.svg b/tests/data/test.svg
new file mode 100644
index 0000000..d3a8e1a
--- /dev/null
+++ b/tests/data/test.svg
@@ -0,0 +1,9 @@
+
+
diff --git a/tests/test-postprocessors.py b/tests/test-postprocessors.py
index e69de29..16c7b48 100644
--- a/tests/test-postprocessors.py
+++ b/tests/test-postprocessors.py
@@ -0,0 +1,54 @@
+# -*- coding: utf-8 -*-
+from nbconvert import RSTExporter, LatexExporter
+import nbformat
+from traitlets.config import Config
+import os
+import sys
+sys.path.append('extensions')
+c = Config()
+
+
+def test_pymarkdown_preprocessor():
+ """ Test python markdown preprocessor """
+ nb_name='tests/data/pymarkdown.ipynb'
+ with open(nb_name, 'r') as f:
+ notebook_json = f.read()
+ notebook = nbformat.reads(notebook_json, as_version=4)
+ c.RSTExporter.preprocessors = ["pre_pymarkdown.PyMarkdownPreprocessor"]
+ c.NbConvertApp.export_format = 'rst'
+ rst_exporter = RSTExporter(config=c)
+ body = rst_exporter.from_notebook_node(notebook)
+ with open('test.txt', 'wb') as f:
+ f.write(body[0].encode('utf8'))
+ assert 'Hello world' in body[0]
+ pass
+
+
+def test_codefolding():
+ """ Test codefolding preprocessor """
+ nb_name='tests/data/codefolding.ipynb'
+ with open(nb_name, 'r') as f:
+ notebook_json = f.read()
+ notebook = nbformat.reads(notebook_json, as_version=4)
+ c.RSTExporter.preprocessors = ["pre_codefolding.CodeFoldingPreprocessor"]
+ c.NbConvertApp.export_format = 'rst'
+ rst_exporter = RSTExporter(config=c)
+ body = rst_exporter.from_notebook_node(notebook)
+ assert 'AXYZ12AXY' not in body[0] # firstline fold
+ assert 'GR4CX32ZT' not in body[0] # function fold
+
+
+def test_svg2pdf_preprocessor():
+ """ Test svg2pdf preprocessor for markdown cell images """
+ nb_name='tests/data/svg2pdf.ipynb'
+ pdf_file='tests/data/test.pdf'
+ with open(nb_name, 'r') as f:
+ notebook_json = f.read()
+ notebook = nbformat.reads(notebook_json, as_version=4)
+ c.LatexExporter.preprocessors = ["pre_svg2pdf.SVG2PDFPreprocessor"]
+ c.NbConvertApp.export_format = 'latex'
+ latex_exporter = LatexExporter(config=c)
+ body = latex_exporter.from_notebook_node(notebook)
+ assert os.path.isfile(pdf_file)
+ os.remove(pdf_file)
+ assert 'test.pdf' in body[0]