summaryrefslogtreecommitdiffstats
path: root/nikola/plugins/compile/pandoc.py
diff options
context:
space:
mode:
authorLibravatarAgustin Henze <tin@sluc.org.ar>2014-06-13 21:51:02 -0300
committerLibravatarAgustin Henze <tin@sluc.org.ar>2014-06-13 21:51:02 -0300
commit58c4878526dec5510f23c812274686787d8724ba (patch)
tree5f2374bc17adb10e15f7e5b4576595d9cc2ef17e /nikola/plugins/compile/pandoc.py
parentfa50632a9d87c3989566fed3e49c160a132e0d14 (diff)
Imported Upstream version 7.0.1upstream/7.0.1
Diffstat (limited to 'nikola/plugins/compile/pandoc.py')
-rw-r--r--nikola/plugins/compile/pandoc.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/nikola/plugins/compile/pandoc.py b/nikola/plugins/compile/pandoc.py
index 654c7c8..6aa737e 100644
--- a/nikola/plugins/compile/pandoc.py
+++ b/nikola/plugins/compile/pandoc.py
@@ -35,12 +35,7 @@ import os
import subprocess
from nikola.plugin_categories import PageCompiler
-from nikola.utils import req_missing, makedirs
-
-try:
- from collections import OrderedDict
-except ImportError:
- OrderedDict = dict # NOQA
+from nikola.utils import req_missing, makedirs, write_metadata
class CompilePandoc(PageCompiler):
@@ -56,15 +51,20 @@ class CompilePandoc(PageCompiler):
if e.strreror == 'No such file or directory':
req_missing(['pandoc'], 'build this site (compile with pandoc)', python=False)
- def create_post(self, path, onefile=False, is_page=False, **kw):
- metadata = OrderedDict()
+ def create_post(self, path, **kw):
+ content = kw.pop('content', None)
+ onefile = kw.pop('onefile', False)
+ # is_page is not used by create_post as of now.
+ kw.pop('is_page', False)
+ metadata = {}
metadata.update(self.default_metadata)
metadata.update(kw)
makedirs(os.path.dirname(path))
+ if not content.endswith('\n'):
+ content += '\n'
with codecs.open(path, "wb+", "utf8") as fd:
if onefile:
- fd.write('<!-- \n')
- for k, v in metadata.items():
- fd.write('.. {0}: {1}\n'.format(k, v))
+ fd.write('<!--\n')
+ fd.write(write_metadata(metadata))
fd.write('-->\n\n')
- fd.write("Write your {0} here.".format('page' if is_page else 'post'))
+ fd.write(content)