From e22b8afc0d0ac04f4bdd74d09eadf6efdf0eeee6 Mon Sep 17 00:00:00 2001 From: Benjamin Audren Date: Tue, 28 Jul 2015 19:17:40 +0200 Subject: [PATCH 1/9] KaTeX support, no error handling yet, see #36 --- README.md | 6 +++--- noteorganiser/assets/style/bootstrap-blog.html | 2 +- noteorganiser/frames.py | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c3f8758..4232190 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,9 @@ issue: python setup.py install --user -when in the main directory. It requires PySide, and pypandoc, which will be -installed if not present. **Be warned, PySide is a huge install**. Go walk -outside for a bit. +when in the main directory. It requires PySide, pandoc (version >= 1.13.2 for +math support) and pypandoc, which will be installed if not present. **Be +warned, PySide is a huge install**. Go walk outside for a bit. To get you started, look at the file `example/example.md`. diff --git a/noteorganiser/assets/style/bootstrap-blog.html b/noteorganiser/assets/style/bootstrap-blog.html index 0c273c4..0483969 100644 --- a/noteorganiser/assets/style/bootstrap-blog.html +++ b/noteorganiser/assets/style/bootstrap-blog.html @@ -1,4 +1,4 @@ - + diff --git a/noteorganiser/frames.py b/noteorganiser/frames.py index ce89a2d..f69a889 100644 --- a/noteorganiser/frames.py +++ b/noteorganiser/frames.py @@ -620,6 +620,9 @@ def convert(self, path, tags): if self.info.use_TOC: extra_args.append('--toc') + # use KaTex + extra_args.append('--katex') + # Apply pandoc to this markdown file, from pypandoc thin wrapper, and # recover the html html = pa.convert(temp_path, 'html', encoding='utf-8', From 9fe36435d3d9143f175a663fd92ae3b94554e6d7 Mon Sep 17 00:00:00 2001 From: Benjamin Audren Date: Wed, 29 Jul 2015 11:32:25 +0200 Subject: [PATCH 2/9] added a check for pandoc version with pypandoc --- .travis.yml | 2 +- noteorganiser/frames.py | 15 +++++++++++++++ setup.py | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) mode change 100644 => 100755 .travis.yml mode change 100644 => 100755 noteorganiser/frames.py mode change 100644 => 100755 setup.py diff --git a/.travis.yml b/.travis.yml old mode 100644 new mode 100755 index 3d094e6..f88c42f --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ install: # Travis CI servers use virtualenvs, so we need to finish the install by the following - python ~/virtualenv/python${TRAVIS_PYTHON_VERSION}/bin/pyside_postinstall.py -install - pip install coveralls - - pip install pypandoc + - pip install 'pypandoc>=0.9.7' - pip install pandocfilters - pip install pytest - pip install 'pytest-qt>=1.2.1' diff --git a/noteorganiser/frames.py b/noteorganiser/frames.py old mode 100644 new mode 100755 index f69a889..38f42ed --- a/noteorganiser/frames.py +++ b/noteorganiser/frames.py @@ -13,6 +13,7 @@ import io import traceback # For failure display import time # for sleep +from distutils.version import StrictVersion from PySide import QtGui from PySide import QtCore @@ -623,6 +624,20 @@ def convert(self, path, tags): # use KaTex extra_args.append('--katex') + # use KaTex + if hasattr(pa, 'get_pandoc_version'): + version = StrictVersion(pa.get_pandoc_version()) + if version < StrictVersion('1.13.2'): + self.log.warning("Pandoc version %s " % pa.get_pandoc_version(), + "has no support for KaTeX. Please install" + " at least version 1.13.2 for math support.") + else: + extra_args.append('--katex') + else: + self.log.warning("Pypandoc version is below 0.9.7, and does not " + "allow to check for Pandoc version. Please " + "update it with pip.") + # Apply pandoc to this markdown file, from pypandoc thin wrapper, and # recover the html html = pa.convert(temp_path, 'html', encoding='utf-8', diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index 20cc29b..aac1f06 --- a/setup.py +++ b/setup.py @@ -36,6 +36,6 @@ url='https://github.com/baudren/NoteOrganiser', packages=PACKAGES, scripts=['noteorganiser/NoteOrganiser.py'], - install_requires=['pypandoc', 'six', 'PySide>=1.2.2', 'pygments'], + install_requires=['pypandoc>=0.9.7', 'six', 'PySide>=1.2.2', 'pygments'], data_files=ASSETS, ) From dbd386a95524639685802da2116ef9f02f5c2359 Mon Sep 17 00:00:00 2001 From: Benjamin Audren Date: Wed, 29 Jul 2015 15:29:40 +0200 Subject: [PATCH 3/9] removed double call to katex --- noteorganiser/frames.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/noteorganiser/frames.py b/noteorganiser/frames.py index 38f42ed..8cfd330 100755 --- a/noteorganiser/frames.py +++ b/noteorganiser/frames.py @@ -621,9 +621,6 @@ def convert(self, path, tags): if self.info.use_TOC: extra_args.append('--toc') - # use KaTex - extra_args.append('--katex') - # use KaTex if hasattr(pa, 'get_pandoc_version'): version = StrictVersion(pa.get_pandoc_version()) From 8ab334ea7fe7d8a3b9bd6ea99b9186d3c81abd2a Mon Sep 17 00:00:00 2001 From: Benjamin Audren Date: Thu, 13 Aug 2015 15:16:22 +0200 Subject: [PATCH 4/9] install newer pandoc through cabal --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 30e45ee..3d9936b 100755 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,11 @@ sudo: false addons: apt: packages: - - pandoc + - cabal-install before_install: + - cabal update + - cabal install pandoc + - export PATH=~/.cabal/bin:$PATH - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" install: From 4e491f52f9b5eb030d2b90dab29e9d07eb7daf44 Mon Sep 17 00:00:00 2001 From: Benjamin Audren Date: Thu, 13 Aug 2015 15:24:43 +0200 Subject: [PATCH 5/9] adding missing ghc --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 3d9936b..9af794e 100755 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ sudo: false addons: apt: packages: + - ghc - cabal-install before_install: - cabal update From b6e8021480946a2f68aaf3790cbdfa01c8d69924 Mon Sep 17 00:00:00 2001 From: Benjamin Audren Date: Fri, 14 Aug 2015 09:29:17 +0200 Subject: [PATCH 6/9] removed source install of pandoc --- .travis.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9af794e..30e45ee 100755 --- a/.travis.yml +++ b/.travis.yml @@ -6,12 +6,8 @@ sudo: false addons: apt: packages: - - ghc - - cabal-install + - pandoc before_install: - - cabal update - - cabal install pandoc - - export PATH=~/.cabal/bin:$PATH - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" install: From bbfaeca99981d3b8a523186cf22f44a8773dd65c Mon Sep 17 00:00:00 2001 From: Benjamin Audren Date: Fri, 14 Aug 2015 09:31:30 +0200 Subject: [PATCH 7/9] replaced Strict by LooseVersion to fix Travis --- noteorganiser/frames.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/noteorganiser/frames.py b/noteorganiser/frames.py index 7a37e41..6e7ea49 100755 --- a/noteorganiser/frames.py +++ b/noteorganiser/frames.py @@ -13,7 +13,7 @@ import io import traceback # For failure display import time # for sleep -from distutils.version import StrictVersion +from distutils.version import LooseVersion from PySide import QtGui from PySide import QtCore @@ -672,8 +672,8 @@ def convert(self, path, tags): # use KaTex if hasattr(pa, 'get_pandoc_version'): - version = StrictVersion(pa.get_pandoc_version()) - if version < StrictVersion('1.13.2'): + version = LooseVersion(pa.get_pandoc_version()) + if version < LooseVersion('1.13.2'): self.log.warning("Pandoc version %s " % pa.get_pandoc_version(), "has no support for KaTeX. Please install" " at least version 1.13.2 for math support.") From 6ebf0b4442ddf57c7231ce2cbbbbc993c93e6f0d Mon Sep 17 00:00:00 2001 From: Benjamin Audren Date: Fri, 14 Aug 2015 09:38:44 +0200 Subject: [PATCH 8/9] excluded old version check from coverage --- noteorganiser/frames.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noteorganiser/frames.py b/noteorganiser/frames.py index 6e7ea49..0041b31 100755 --- a/noteorganiser/frames.py +++ b/noteorganiser/frames.py @@ -679,7 +679,7 @@ def convert(self, path, tags): " at least version 1.13.2 for math support.") else: extra_args.append('--katex') - else: + else: # pragma: no cover self.log.warning("Pypandoc version is below 0.9.7, and does not " "allow to check for Pandoc version. Please " "update it with pip.") From 385e749ac803e271a0176f6db9c7d32811251a8a Mon Sep 17 00:00:00 2001 From: Benjamin Audren Date: Fri, 14 Aug 2015 09:43:15 +0200 Subject: [PATCH 9/9] exclude katex option from coverage --- noteorganiser/frames.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noteorganiser/frames.py b/noteorganiser/frames.py index 0041b31..9942b80 100755 --- a/noteorganiser/frames.py +++ b/noteorganiser/frames.py @@ -677,7 +677,7 @@ def convert(self, path, tags): self.log.warning("Pandoc version %s " % pa.get_pandoc_version(), "has no support for KaTeX. Please install" " at least version 1.13.2 for math support.") - else: + else: # pragma: no cover extra_args.append('--katex') else: # pragma: no cover self.log.warning("Pypandoc version is below 0.9.7, and does not "