summaryrefslogtreecommitdiffstats
path: root/nikola/plugins/compile
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
parentfa50632a9d87c3989566fed3e49c160a132e0d14 (diff)
Imported Upstream version 7.0.1upstream/7.0.1
Diffstat (limited to 'nikola/plugins/compile')
-rw-r--r--nikola/plugins/compile/asciidoc.py71
-rw-r--r--nikola/plugins/compile/bbcode.plugin10
-rw-r--r--nikola/plugins/compile/bbcode.py80
-rw-r--r--nikola/plugins/compile/html.py24
-rw-r--r--nikola/plugins/compile/ipynb.plugin2
-rw-r--r--nikola/plugins/compile/ipynb/__init__.py26
-rw-r--r--nikola/plugins/compile/markdown/__init__.py49
-rw-r--r--nikola/plugins/compile/markdown/mdx_gist.plugin (renamed from nikola/plugins/compile/asciidoc.plugin)7
-rw-r--r--nikola/plugins/compile/markdown/mdx_gist.py18
-rw-r--r--nikola/plugins/compile/markdown/mdx_nikola.plugin (renamed from nikola/plugins/compile/txt2tags.plugin)7
-rw-r--r--nikola/plugins/compile/markdown/mdx_nikola.py24
-rw-r--r--nikola/plugins/compile/markdown/mdx_podcast.plugin9
-rw-r--r--nikola/plugins/compile/markdown/mdx_podcast.py14
-rw-r--r--nikola/plugins/compile/misaka.plugin10
-rw-r--r--nikola/plugins/compile/misaka.py87
-rw-r--r--nikola/plugins/compile/pandoc.py24
-rw-r--r--nikola/plugins/compile/php.py24
-rw-r--r--nikola/plugins/compile/rest/__init__.py26
-rw-r--r--nikola/plugins/compile/rest/chart.py13
-rw-r--r--nikola/plugins/compile/rest/doc.py2
-rw-r--r--nikola/plugins/compile/rest/listing.py1
-rw-r--r--nikola/plugins/compile/rest/post_list.py5
-rw-r--r--nikola/plugins/compile/rest/slides.py9
-rw-r--r--nikola/plugins/compile/rest/vimeo.py6
-rw-r--r--nikola/plugins/compile/rest/youtube.py2
-rw-r--r--nikola/plugins/compile/textile.plugin10
-rw-r--r--nikola/plugins/compile/textile.py76
-rw-r--r--nikola/plugins/compile/txt2tags.py76
-rw-r--r--nikola/plugins/compile/wiki.plugin10
-rw-r--r--nikola/plugins/compile/wiki.py75
30 files changed, 164 insertions, 633 deletions
diff --git a/nikola/plugins/compile/asciidoc.py b/nikola/plugins/compile/asciidoc.py
deleted file mode 100644
index 68f96d9..0000000
--- a/nikola/plugins/compile/asciidoc.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright © 2012-2014 Roberto Alsina and others.
-
-# Permission is hereby granted, free of charge, to any
-# person obtaining a copy of this software and associated
-# documentation files (the "Software"), to deal in the
-# Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the
-# Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice
-# shall be included in all copies or substantial portions of
-# the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
-# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-"""Implementation of compile_html based on asciidoc.
-
-You will need, of course, to install asciidoc
-
-"""
-
-import codecs
-import os
-import subprocess
-
-from nikola.plugin_categories import PageCompiler
-from nikola.utils import makedirs, req_missing
-
-try:
- from collections import OrderedDict
-except ImportError:
- OrderedDict = dict # NOQA
-
-
-class CompileAsciiDoc(PageCompiler):
- """Compile asciidoc into HTML."""
-
- name = "asciidoc"
- demote_headers = True
-
- def compile_html(self, source, dest, is_two_file=True):
- makedirs(os.path.dirname(dest))
- try:
- subprocess.check_call(('asciidoc', '-f', 'html', '-s', '-o', dest, source))
- except OSError as e:
- if e.strreror == 'No such file or directory':
- req_missing(['asciidoc'], 'build this site (compile with asciidoc)', python=False)
-
- def create_post(self, path, onefile=False, is_page=False, **kw):
- metadata = OrderedDict()
- metadata.update(self.default_metadata)
- metadata.update(kw)
- makedirs(os.path.dirname(path))
- 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("\nWrite your {0} here.".format('page' if is_page else 'post'))
diff --git a/nikola/plugins/compile/bbcode.plugin b/nikola/plugins/compile/bbcode.plugin
deleted file mode 100644
index b3d9357..0000000
--- a/nikola/plugins/compile/bbcode.plugin
+++ /dev/null
@@ -1,10 +0,0 @@
-[Core]
-Name = bbcode
-Module = bbcode
-
-[Documentation]
-Author = Roberto Alsina
-Version = 0.1
-Website = http://getnikola.com
-Description = Compile BBCode into HTML
-
diff --git a/nikola/plugins/compile/bbcode.py b/nikola/plugins/compile/bbcode.py
deleted file mode 100644
index 0961ffe..0000000
--- a/nikola/plugins/compile/bbcode.py
+++ /dev/null
@@ -1,80 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright © 2012-2014 Roberto Alsina and others.
-
-# Permission is hereby granted, free of charge, to any
-# person obtaining a copy of this software and associated
-# documentation files (the "Software"), to deal in the
-# Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the
-# Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice
-# shall be included in all copies or substantial portions of
-# the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
-# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-"""Implementation of compile_html based on bbcode."""
-
-import codecs
-import os
-import re
-
-try:
- import bbcode
-except ImportError:
- bbcode = None # NOQA
-
-from nikola.plugin_categories import PageCompiler
-from nikola.utils import makedirs, req_missing
-try:
- from collections import OrderedDict
-except ImportError:
- OrderedDict = dict # NOQA
-
-
-class CompileBbcode(PageCompiler):
- """Compile bbcode into HTML."""
-
- name = "bbcode"
-
- def __init__(self):
- if bbcode is None:
- return
- self.parser = bbcode.Parser()
- self.parser.add_simple_formatter("note", "")
-
- def compile_html(self, source, dest, is_two_file=True):
- if bbcode is None:
- req_missing(['bbcode'], 'build this site (compile BBCode)')
- makedirs(os.path.dirname(dest))
- with codecs.open(dest, "w+", "utf8") as out_file:
- with codecs.open(source, "r", "utf8") as in_file:
- data = in_file.read()
- if not is_two_file:
- data = re.split('(\n\n|\r\n\r\n)', data, maxsplit=1)[-1]
- output = self.parser.format(data)
- out_file.write(output)
-
- def create_post(self, path, onefile=False, is_page=False, **kw):
- metadata = OrderedDict()
- metadata.update(self.default_metadata)
- metadata.update(kw)
- makedirs(os.path.dirname(path))
- with codecs.open(path, "wb+", "utf8") as fd:
- if onefile:
- fd.write('[note]<!--\n')
- for k, v in metadata.items():
- fd.write('.. {0}: {1}\n'.format(k, v))
- fd.write('-->[/note]\n\n')
- fd.write("Write your {0} here.".format('page' if is_page else 'post'))
diff --git a/nikola/plugins/compile/html.py b/nikola/plugins/compile/html.py
index 09a9756..fff7f89 100644
--- a/nikola/plugins/compile/html.py
+++ b/nikola/plugins/compile/html.py
@@ -31,12 +31,7 @@ import re
import codecs
from nikola.plugin_categories import PageCompiler
-from nikola.utils import makedirs
-
-try:
- from collections import OrderedDict
-except ImportError:
- OrderedDict = dict # NOQA
+from nikola.utils import makedirs, write_metadata
_META_SEPARATOR = '(' + os.linesep * 2 + '|' + ('\n' * 2) + '|' + ("\r\n" * 2) + ')'
@@ -56,15 +51,20 @@ class CompileHtml(PageCompiler):
out_file.write(data)
return True
- 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("\n<p>Write your {0} here.</p>\n".format('page' if is_page else 'post'))
+ fd.write(content)
diff --git a/nikola/plugins/compile/ipynb.plugin b/nikola/plugins/compile/ipynb.plugin
index 3d15bb0..e258d8a 100644
--- a/nikola/plugins/compile/ipynb.plugin
+++ b/nikola/plugins/compile/ipynb.plugin
@@ -3,7 +3,7 @@ Name = ipynb
Module = ipynb
[Documentation]
-Author = Damián Avila
+Author = Damian Avila
Version = 1.0
Website = http://www.oquanta.info
Description = Compile IPython notebooks into HTML
diff --git a/nikola/plugins/compile/ipynb/__init__.py b/nikola/plugins/compile/ipynb/__init__.py
index 2b1fd28..f4d554c 100644
--- a/nikola/plugins/compile/ipynb/__init__.py
+++ b/nikola/plugins/compile/ipynb/__init__.py
@@ -41,16 +41,12 @@ except ImportError:
from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, req_missing
-try:
- from collections import OrderedDict
-except ImportError:
- OrderedDict = dict # NOQA
-
class CompileIPynb(PageCompiler):
"""Compile IPynb into HTML."""
name = "ipynb"
+ supports_onefile = False
def compile_html(self, source, dest, is_two_file=True):
if flag is None:
@@ -66,19 +62,15 @@ class CompileIPynb(PageCompiler):
(body, resources) = exportHtml.from_notebook_node(nb_json)
out_file.write(body)
- def create_post(self, path, onefile=False, is_page=False, **kw):
- metadata = OrderedDict()
- metadata.update(self.default_metadata)
- metadata.update(kw)
- d_name = os.path.dirname(path)
+ def create_post(self, path, **kw):
+ # content and onefile are ignored by ipynb.
+ kw.pop('content', None)
+ onefile = kw.pop('onefile', False)
+ kw.pop('is_page', False)
+
makedirs(os.path.dirname(path))
- meta_path = os.path.join(d_name, kw['slug'] + ".meta")
- with codecs.open(meta_path, "wb+", "utf8") as fd:
- fd.write('\n'.join((metadata['title'], metadata['slug'],
- metadata['date'], metadata['tags'],
- metadata['link'],
- metadata['description'], metadata['type'])))
- print("Your {0}'s metadata is at: {1}".format('page' if is_page else 'post', meta_path))
+ if onefile:
+ raise Exception('The one-file format is not supported by this compiler.')
with codecs.open(path, "wb+", "utf8") as fd:
fd.write("""{
"metadata": {
diff --git a/nikola/plugins/compile/markdown/__init__.py b/nikola/plugins/compile/markdown/__init__.py
index d0fa66a..4182626 100644
--- a/nikola/plugins/compile/markdown/__init__.py
+++ b/nikola/plugins/compile/markdown/__init__.py
@@ -34,30 +34,14 @@ import re
try:
from markdown import markdown
-
- from nikola.plugins.compile.markdown.mdx_nikola import NikolaExtension
- nikola_extension = NikolaExtension()
-
- from nikola.plugins.compile.markdown.mdx_gist import GistExtension
- gist_extension = GistExtension()
-
- from nikola.plugins.compile.markdown.mdx_podcast import PodcastExtension
- podcast_extension = PodcastExtension()
-
except ImportError:
markdown = None # NOQA
nikola_extension = None
gist_extension = None
podcast_extension = None
-
-try:
- from collections import OrderedDict
-except ImportError:
- OrderedDict = dict # NOQA
-
from nikola.plugin_categories import PageCompiler
-from nikola.utils import makedirs, req_missing
+from nikola.utils import makedirs, req_missing, write_metadata
class CompileMarkdown(PageCompiler):
@@ -65,9 +49,22 @@ class CompileMarkdown(PageCompiler):
name = "markdown"
demote_headers = True
- extensions = [gist_extension, nikola_extension, podcast_extension]
+ extensions = []
site = None
+ def set_site(self, site):
+ for plugin_info in site.plugin_manager.getPluginsOfCategory("MarkdownExtension"):
+ if plugin_info.name in site.config['DISABLED_PLUGINS']:
+ site.plugin_manager.removePluginFromCategory(plugin_info, "MarkdownExtension")
+ continue
+
+ site.plugin_manager.activatePluginByName(plugin_info.name)
+ plugin_info.plugin_object.set_site(site)
+ self.extensions.append(plugin_info.plugin_object)
+ plugin_info.plugin_object.short_help = plugin_info.description
+
+ return super(CompileMarkdown, self).set_site(site)
+
def compile_html(self, source, dest, is_two_file=True):
if markdown is None:
req_missing(['markdown'], 'build this site (compile Markdown)')
@@ -81,15 +78,21 @@ class CompileMarkdown(PageCompiler):
output = markdown(data, self.extensions)
out_file.write(output)
- 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(write_metadata(metadata))
fd.write('-->\n\n')
- fd.write("Write your {0} here.".format('page' if is_page else 'post'))
+ fd.write(content)
diff --git a/nikola/plugins/compile/asciidoc.plugin b/nikola/plugins/compile/markdown/mdx_gist.plugin
index 47c5608..0e5c578 100644
--- a/nikola/plugins/compile/asciidoc.plugin
+++ b/nikola/plugins/compile/markdown/mdx_gist.plugin
@@ -1,10 +1,9 @@
[Core]
-Name = asciidoc
-Module = asciidoc
+Name = mdx_gist
+Module = mdx_gist
[Documentation]
Author = Roberto Alsina
Version = 0.1
Website = http://getnikola.com
-Description = Compile ASCIIDoc into HTML
-
+Description = Extension for embedding gists
diff --git a/nikola/plugins/compile/markdown/mdx_gist.py b/nikola/plugins/compile/markdown/mdx_gist.py
index d92295d..247478b 100644
--- a/nikola/plugins/compile/markdown/mdx_gist.py
+++ b/nikola/plugins/compile/markdown/mdx_gist.py
@@ -117,10 +117,18 @@ Error Case: non-existent file:
'''
from __future__ import unicode_literals, print_function
-from markdown.extensions import Extension
-from markdown.inlinepatterns import Pattern
-from markdown.util import AtomicString
-from markdown.util import etree
+
+try:
+ from markdown.extensions import Extension
+ from markdown.inlinepatterns import Pattern
+ from markdown.util import AtomicString
+ from markdown.util import etree
+except ImportError:
+ # No need to catch this, if you try to use this without Markdown,
+ # the markdown compiler will fail first
+ Extension = Pattern = object
+
+from nikola.plugin_categories import MarkdownExtension
from nikola.utils import get_logger, req_missing, STDERR_HANDLER
LOGGER = get_logger('compile_markdown.mdx_gist', STDERR_HANDLER)
@@ -209,7 +217,7 @@ class GistPattern(Pattern):
return gist_elem
-class GistExtension(Extension):
+class GistExtension(MarkdownExtension, Extension):
def __init__(self, configs={}):
# set extension defaults
self.config = {}
diff --git a/nikola/plugins/compile/txt2tags.plugin b/nikola/plugins/compile/markdown/mdx_nikola.plugin
index 55eb0a0..7af52a4 100644
--- a/nikola/plugins/compile/txt2tags.plugin
+++ b/nikola/plugins/compile/markdown/mdx_nikola.plugin
@@ -1,10 +1,9 @@
[Core]
-Name = txt2tags
-Module = txt2tags
+Name = mdx_nikola
+Module = mdx_nikola
[Documentation]
Author = Roberto Alsina
Version = 0.1
Website = http://getnikola.com
-Description = Compile Txt2tags into HTML
-
+Description = Nikola-specific Markdown extensions
diff --git a/nikola/plugins/compile/markdown/mdx_nikola.py b/nikola/plugins/compile/markdown/mdx_nikola.py
index b7c29a5..ca67511 100644
--- a/nikola/plugins/compile/markdown/mdx_nikola.py
+++ b/nikola/plugins/compile/markdown/mdx_nikola.py
@@ -27,23 +27,31 @@
"""Markdown Extension for Nikola-specific post-processing"""
from __future__ import unicode_literals
import re
-from markdown.postprocessors import Postprocessor
-from markdown.extensions import Extension
+try:
+ from markdown.postprocessors import Postprocessor
+ from markdown.extensions import Extension
+except ImportError:
+ # No need to catch this, if you try to use this without Markdown,
+ # the markdown compiler will fail first
+ Postprocessor = Extension = object
+
+from nikola.plugin_categories import MarkdownExtension
+
+# FIXME: duplicated with listings.py
+CODERE = re.compile('<div class="codehilite"><pre>(.*?)</pre></div>', flags=re.MULTILINE | re.DOTALL)
class NikolaPostProcessor(Postprocessor):
def run(self, text):
output = text
- # python-markdown's highlighter uses the class 'codehilite' to wrap
- # code, instead of the standard 'code'. None of the standard
- # pygments stylesheets use this class, so swap it to be 'code'
- output = re.sub(r'(<div[^>]+class="[^"]*)codehilite([^>]+)',
- r'\1code\2', output)
+ # python-markdown's highlighter uses <div class="codehilite"><pre>
+ # for code. We switch it to reST's <pre class="code">.
+ output = CODERE.sub('<pre class="code literal-block">\\1</pre>', output)
return output
-class NikolaExtension(Extension):
+class NikolaExtension(MarkdownExtension, Extension):
def extendMarkdown(self, md, md_globals):
pp = NikolaPostProcessor()
md.postprocessors.add('nikola_post_processor', pp, '_end')
diff --git a/nikola/plugins/compile/markdown/mdx_podcast.plugin b/nikola/plugins/compile/markdown/mdx_podcast.plugin
new file mode 100644
index 0000000..dc16044
--- /dev/null
+++ b/nikola/plugins/compile/markdown/mdx_podcast.plugin
@@ -0,0 +1,9 @@
+[Core]
+Name = mdx_podcast
+Module = mdx_podcast
+
+[Documentation]
+Author = Roberto Alsina
+Version = 0.1
+Website = http://getnikola.com
+Description = Markdown extensions for embedding podcasts and other audio files
diff --git a/nikola/plugins/compile/markdown/mdx_podcast.py b/nikola/plugins/compile/markdown/mdx_podcast.py
index b38b969..9a67910 100644
--- a/nikola/plugins/compile/markdown/mdx_podcast.py
+++ b/nikola/plugins/compile/markdown/mdx_podcast.py
@@ -39,9 +39,15 @@ Basic Example:
<p><audio src="http://archive.org/download/Rebeldes_Stereotipos/rs20120609_1.mp3"></audio></p>
'''
-from markdown.extensions import Extension
-from markdown.inlinepatterns import Pattern
-from markdown.util import etree
+from nikola.plugin_categories import MarkdownExtension
+try:
+ from markdown.extensions import Extension
+ from markdown.inlinepatterns import Pattern
+ from markdown.util import etree
+except ImportError:
+ # No need to catch this, if you try to use this without Markdown,
+ # the markdown compiler will fail first
+ Pattern = Extension = object
PODCAST_RE = r'\[podcast\](?P<url>.+)\[/podcast\]'
@@ -62,7 +68,7 @@ class PodcastPattern(Pattern):
return audio_elem
-class PodcastExtension(Extension):
+class PodcastExtension(MarkdownExtension, Extension):
def __init__(self, configs={}):
# set extension defaults
self.config = {}
diff --git a/nikola/plugins/compile/misaka.plugin b/nikola/plugins/compile/misaka.plugin
deleted file mode 100644
index fef6d71..0000000
--- a/nikola/plugins/compile/misaka.plugin
+++ /dev/null
@@ -1,10 +0,0 @@
-[Core]
-Name = misaka
-Module = misaka
-
-[Documentation]
-Author = Chris Lee
-Version = 0.1
-Website = http://c133.org/
-Description = Compile Markdown into HTML with Mikasa instead of python-markdown
-
diff --git a/nikola/plugins/compile/misaka.py b/nikola/plugins/compile/misaka.py
deleted file mode 100644
index 4951c9f..0000000
--- a/nikola/plugins/compile/misaka.py
+++ /dev/null
@@ -1,87 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright © 2013-2014 Chris Lee and others.
-
-# Permission is hereby granted, free of charge, to any
-# person obtaining a copy of this software and associated
-# documentation files (the "Software"), to deal in the
-# Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the
-# Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice
-# shall be included in all copies or substantial portions of
-# the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
-# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-"""Implementation of compile_html based on misaka."""
-
-from __future__ import unicode_literals
-
-import codecs
-import os
-import re
-
-try:
- import misaka
-except ImportError:
- misaka = None # NOQA
- nikola_extension = None
-try:
- from collections import OrderedDict
-except ImportError:
- OrderedDict = dict # NOQA
-
- gist_extension = None
- podcast_extension = None
-
-from nikola.plugin_categories import PageCompiler
-from nikola.utils import makedirs, req_missing
-
-
-class CompileMisaka(PageCompiler):
- """Compile Misaka into HTML."""
-
- name = "misaka"
- demote_headers = True
-
- def __init__(self, *args, **kwargs):
- super(CompileMisaka, self).__init__(*args, **kwargs)
- if misaka is not None:
- self.ext = misaka.EXT_FENCED_CODE | misaka.EXT_STRIKETHROUGH | \
- misaka.EXT_AUTOLINK | misaka.EXT_NO_INTRA_EMPHASIS
-
- def compile_html(self, source, dest, is_two_file=True):
- if misaka is None:
- req_missing(['misaka'], 'build this site (compile with misaka)')
- makedirs(os.path.dirname(dest))
- with codecs.open(dest, "w+", "utf8") as out_file:
- with codecs.open(source, "r", "utf8") as in_file:
- data = in_file.read()
- if not is_two_file:
- data = re.split('(\n\n|\r\n\r\n)', data, maxsplit=1)[-1]
- output = misaka.html(data, extensions=self.ext)
- out_file.write(output)
-
- def create_post(self, path, onefile=False, is_page=False, **kw):
- metadata = OrderedDict()
- metadata.update(self.default_metadata)
- metadata.update(kw)
- makedirs(os.path.dirname(path))
- 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\n')
- fd.write("\nWrite your {0} here.".format('page' if is_page else 'post'))
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)
diff --git a/nikola/plugins/compile/php.py b/nikola/plugins/compile/php.py
index 0a652a6..601f098 100644
--- a/nikola/plugins/compile/php.py
+++ b/nikola/plugins/compile/php.py
@@ -33,12 +33,7 @@ import shutil
import codecs
from nikola.plugin_categories import PageCompiler
-from nikola.utils import makedirs
-
-try:
- from collections import OrderedDict
-except ImportError:
- OrderedDict = dict # NOQA
+from nikola.utils import makedirs, write_metadata
class CompilePhp(PageCompiler):
@@ -50,18 +45,23 @@ class CompilePhp(PageCompiler):
makedirs(os.path.dirname(dest))
shutil.copyfile(source, dest)
- 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)
os.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("\n<p>Write your {0} here.</p>".format('page' if is_page else 'post'))
+ fd.write(content)
def extension(self):
return ".php"
diff --git a/nikola/plugins/compile/rest/__init__.py b/nikola/plugins/compile/rest/__init__.py
index 9a4e19b..a93199c 100644
--- a/nikola/plugins/compile/rest/__init__.py
+++ b/nikola/plugins/compile/rest/__init__.py
@@ -40,13 +40,8 @@ try:
except ImportError:
has_docutils = False
-try:
- from collections import OrderedDict
-except ImportError:
- OrderedDict = dict # NOQA
-
from nikola.plugin_categories import PageCompiler
-from nikola.utils import get_logger, makedirs, req_missing
+from nikola.utils import get_logger, makedirs, req_missing, write_metadata
class CompileRest(PageCompiler):
@@ -102,22 +97,25 @@ class CompileRest(PageCompiler):
else:
return 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:
- for k, v in metadata.items():
- fd.write('.. {0}: {1}\n'.format(k, v))
- fd.write("\nWrite your {0} here.".format('page' if is_page else 'post'))
+ fd.write(write_metadata(metadata))
+ fd.write('\n' + content)
def set_site(self, site):
for plugin_info in site.plugin_manager.getPluginsOfCategory("RestExtension"):
- if (plugin_info.name in site.config['DISABLED_PLUGINS']
- or (plugin_info.name in site.EXTRA_PLUGINS and
- plugin_info.name not in site.config['ENABLED_EXTRAS'])):
+ if plugin_info.name in site.config['DISABLED_PLUGINS']:
site.plugin_manager.removePluginFromCategory(plugin_info, "RestExtension")
continue
diff --git a/nikola/plugins/compile/rest/chart.py b/nikola/plugins/compile/rest/chart.py
index 03878a3..55ddf5c 100644
--- a/nikola/plugins/compile/rest/chart.py
+++ b/nikola/plugins/compile/rest/chart.py
@@ -37,13 +37,16 @@ except ImportError:
from nikola.plugin_categories import RestExtension
from nikola.utils import req_missing
+_site = None
+
class Plugin(RestExtension):
name = "rest_chart"
def set_site(self, site):
- self.site = site
+ global _site
+ _site = self.site = site
directives.register_directive('chart', Chart)
return super(Plugin, self).set_site(site)
@@ -146,5 +149,9 @@ class Chart(Directive):
for line in self.content:
label, series = literal_eval('({0})'.format(line))
chart.add(label, series)
-
- return [nodes.raw('', chart.render().decode('utf8'), format='html')]
+ data = chart.render().decode('utf8')
+ if _site and _site.invariant:
+ import re
+ data = re.sub('id="chart-[a-f0-9\-]+"', 'id="chart-foobar"', data)
+ data = re.sub('#chart-[a-f0-9\-]+', '#chart-foobar', data)
+ return [nodes.raw('', data, format='html')]
diff --git a/nikola/plugins/compile/rest/doc.py b/nikola/plugins/compile/rest/doc.py
index a150a81..6143606 100644
--- a/nikola/plugins/compile/rest/doc.py
+++ b/nikola/plugins/compile/rest/doc.py
@@ -48,7 +48,6 @@ def doc_role(name, rawtext, text, lineno, inliner,
# split link's text and post's slug in role content
has_explicit_title, title, slug = split_explicit_title(text)
-
# check if the slug given is part of our blog posts/pages
twin_slugs = False
post = None
@@ -73,7 +72,6 @@ def doc_role(name, rawtext, text, lineno, inliner,
if not has_explicit_title:
# use post's title as link's text
title = post.title()
-
permalink = post.permalink()
if twin_slugs:
msg = inliner.reporter.warning(
diff --git a/nikola/plugins/compile/rest/listing.py b/nikola/plugins/compile/rest/listing.py
index d70e02d..18a1807 100644
--- a/nikola/plugins/compile/rest/listing.py
+++ b/nikola/plugins/compile/rest/listing.py
@@ -46,6 +46,7 @@ except ImportError: # docutils < 0.9 (Debian Sid For The Loss)
class CodeBlock(Directive):
required_arguments = 1
has_content = True
+ option_spec = {}
CODE = '<pre>{0}</pre>'
def run(self):
diff --git a/nikola/plugins/compile/rest/post_list.py b/nikola/plugins/compile/rest/post_list.py
index 6804b58..456e571 100644
--- a/nikola/plugins/compile/rest/post_list.py
+++ b/nikola/plugins/compile/rest/post_list.py
@@ -124,7 +124,10 @@ class PostList(Directive):
show_all = self.options.get('all', False)
lang = self.options.get('lang', utils.LocaleBorg().current_lang)
template = self.options.get('template', 'post_list_directive.tmpl')
- post_list_id = self.options.get('id', 'post_list_' + uuid.uuid4().hex)
+ if self.site.invariant: # for testing purposes
+ post_list_id = self.options.get('id', 'post_list_' + 'fixedvaluethatisnotauuid')
+ else:
+ post_list_id = self.options.get('id', 'post_list_' + uuid.uuid4().hex)
posts = []
step = -1 if reverse is None else None
diff --git a/nikola/plugins/compile/rest/slides.py b/nikola/plugins/compile/rest/slides.py
index 203ae51..ea8e413 100644
--- a/nikola/plugins/compile/rest/slides.py
+++ b/nikola/plugins/compile/rest/slides.py
@@ -53,12 +53,17 @@ class Slides(Directive):
if len(self.content) == 0:
return
+ if self.site.invariant: # for testing purposes
+ carousel_id = 'slides_' + 'fixedvaluethatisnotauuid'
+ else:
+ carousel_id = 'slides_' + uuid.uuid4().hex
+
output = self.site.template_system.render_template(
'slides.tmpl',
None,
{
- 'content': self.content,
- 'carousel_id': 'slides_' + uuid.uuid4().hex,
+ 'slides_content': self.content,
+ 'carousel_id': carousel_id,
}
)
return [nodes.raw('', output, format='html')]
diff --git a/nikola/plugins/compile/rest/vimeo.py b/nikola/plugins/compile/rest/vimeo.py
index 82c4dc1..4b34dfe 100644
--- a/nikola/plugins/compile/rest/vimeo.py
+++ b/nikola/plugins/compile/rest/vimeo.py
@@ -49,9 +49,9 @@ class Plugin(RestExtension):
return super(Plugin, self).set_site(site)
-CODE = """<iframe src="http://player.vimeo.com/video/{vimeo_id}"
+CODE = """<iframe src="//player.vimeo.com/video/{vimeo_id}"
width="{width}" height="{height}"
-frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen>
+frameborder="0" webkitAllowFullScreen="webkitAllowFullScreen" mozallowfullscreen="mozallowfullscreen" allowFullScreen="allowFullScreen">
</iframe>
"""
@@ -108,7 +108,7 @@ class Vimeo(Directive):
if json: # we can attempt to retrieve video attributes from vimeo
try:
- url = ('http://vimeo.com/api/v2/video/{0}'
+ url = ('//vimeo.com/api/v2/video/{0}'
'.json'.format(self.arguments[0]))
data = requests.get(url).text
video_attributes = json.loads(data)[0]
diff --git a/nikola/plugins/compile/rest/youtube.py b/nikola/plugins/compile/rest/youtube.py
index 19e12d1..b32e77a 100644
--- a/nikola/plugins/compile/rest/youtube.py
+++ b/nikola/plugins/compile/rest/youtube.py
@@ -44,7 +44,7 @@ class Plugin(RestExtension):
CODE = """\
<iframe width="{width}"
height="{height}"
-src="http://www.youtube.com/embed/{yid}?rel=0&amp;hd=1&amp;wmode=transparent"
+src="//www.youtube.com/embed/{yid}?rel=0&amp;hd=1&amp;wmode=transparent"
></iframe>"""
diff --git a/nikola/plugins/compile/textile.plugin b/nikola/plugins/compile/textile.plugin
deleted file mode 100644
index 6439b0f..0000000
--- a/nikola/plugins/compile/textile.plugin
+++ /dev/null
@@ -1,10 +0,0 @@
-[Core]
-Name = textile
-Module = textile
-
-[Documentation]
-Author = Roberto Alsina
-Version = 0.1
-Website = http://getnikola.com
-Description = Compile Textile into HTML
-
diff --git a/nikola/plugins/compile/textile.py b/nikola/plugins/compile/textile.py
deleted file mode 100644
index 1679831..0000000
--- a/nikola/plugins/compile/textile.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright © 2012-2014 Roberto Alsina and others.
-
-# Permission is hereby granted, free of charge, to any
-# person obtaining a copy of this software and associated
-# documentation files (the "Software"), to deal in the
-# Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the
-# Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice
-# shall be included in all copies or substantial portions of
-# the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
-# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-"""Implementation of compile_html based on textile."""
-
-import codecs
-import os
-import re
-
-try:
- from textile import textile
-except ImportError:
- textile = None # NOQA
-
-from nikola.plugin_categories import PageCompiler
-from nikola.utils import makedirs, req_missing
-
-try:
- from collections import OrderedDict
-except ImportError:
- OrderedDict = dict # NOQA
-
-
-class CompileTextile(PageCompiler):
- """Compile textile into HTML."""
-
- name = "textile"
- demote_headers = True
-
- def compile_html(self, source, dest, is_two_file=True):
- if textile is None:
- req_missing(['textile'], 'build this site (compile Textile)')
- makedirs(os.path.dirname(dest))
- with codecs.open(dest, "w+", "utf8") as out_file:
- with codecs.open(source, "r", "utf8") as in_file:
- data = in_file.read()
- if not is_two_file:
- data = re.split('(\n\n|\r\n\r\n)', data, maxsplit=1)[-1]
- output = textile(data, head_offset=1)
- out_file.write(output)
-
- def create_post(self, path, onefile=False, is_page=False, **kw):
- metadata = OrderedDict()
- metadata.update(self.default_metadata)
- metadata.update(kw)
- makedirs(os.path.dirname(path))
- with codecs.open(path, "wb+", "utf8") as fd:
- if onefile:
- fd.write('<notextile> <!--\n')
- for k, v in metadata.items():
- fd.write('.. {0}: {1}\n'.format(k, v))
- fd.write('--></notextile>\n\n')
- fd.write("\nWrite your {0} here.".format('page' if is_page else 'post'))
diff --git a/nikola/plugins/compile/txt2tags.py b/nikola/plugins/compile/txt2tags.py
deleted file mode 100644
index bb6afa5..0000000
--- a/nikola/plugins/compile/txt2tags.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright © 2012-2014 Roberto Alsina and others.
-
-# Permission is hereby granted, free of charge, to any
-# person obtaining a copy of this software and associated
-# documentation files (the "Software"), to deal in the
-# Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the
-# Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice
-# shall be included in all copies or substantial portions of
-# the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
-# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-"""Implementation of compile_html based on txt2tags.
-
-Txt2tags is not in PyPI, you can install it with
-
-easy_install -f "http://txt2tags.org/txt2tags.py#egg=txt2tags-2.6" txt2tags
-
-"""
-
-import codecs
-import os
-
-try:
- from txt2tags import exec_command_line as txt2tags
-except ImportError:
- txt2tags = None # NOQA
-
-try:
- from collections import OrderedDict
-except ImportError:
- OrderedDict = dict # NOQA
-
-from nikola.plugin_categories import PageCompiler
-from nikola.utils import makedirs, req_missing
-
-
-class CompileTxt2tags(PageCompiler):
- """Compile txt2tags into HTML."""
-
- name = "txt2tags"
- demote_headers = True
-
- def compile_html(self, source, dest, is_two_file=True):
- if txt2tags is None:
- req_missing(['txt2tags'], 'build this site (compile txt2tags)')
- makedirs(os.path.dirname(dest))
- cmd = ["-t", "html", "--no-headers", "--outfile", dest, source]
- txt2tags(cmd)
-
- def create_post(self, path, onefile=False, is_page=False, **kw):
- metadata = OrderedDict()
- metadata.update(self.default_metadata)
- metadata.update(kw)
- makedirs(os.path.dirname(path))
- with codecs.open(path, "wb+", "utf8") as fd:
- if onefile:
- fd.write("\n'''\n<!--\n")
- for k, v in metadata.items():
- fd.write('.. {0}: {1}\n'.format(k, v))
- fd.write("-->\n'''\n")
- fd.write("\nWrite your {0} here.".format('page' if is_page else 'post'))
diff --git a/nikola/plugins/compile/wiki.plugin b/nikola/plugins/compile/wiki.plugin
deleted file mode 100644
index eee14a8..0000000
--- a/nikola/plugins/compile/wiki.plugin
+++ /dev/null
@@ -1,10 +0,0 @@
-[Core]
-Name = wiki
-Module = wiki
-
-[Documentation]
-Author = Roberto Alsina
-Version = 0.1
-Website = http://getnikola.com
-Description = Compile WikiMarkup into HTML
-
diff --git a/nikola/plugins/compile/wiki.py b/nikola/plugins/compile/wiki.py
deleted file mode 100644
index f4858c7..0000000
--- a/nikola/plugins/compile/wiki.py
+++ /dev/null
@@ -1,75 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright © 2012-2014 Roberto Alsina and others.
-
-# Permission is hereby granted, free of charge, to any
-# person obtaining a copy of this software and associated
-# documentation files (the "Software"), to deal in the
-# Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the
-# Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice
-# shall be included in all copies or substantial portions of
-# the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
-# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-"""Implementation of compile_html based on CreoleWiki."""
-
-import codecs
-import os
-
-try:
- from creole import Parser
- from creole.html_emitter import HtmlEmitter
- creole = True
-except ImportError:
- creole = None
-
-from nikola.plugin_categories import PageCompiler
-try:
- from collections import OrderedDict
-except ImportError:
- OrderedDict = dict # NOQA
-
-from nikola.utils import makedirs, req_missing
-
-
-class CompileWiki(PageCompiler):
- """Compile CreoleWiki into HTML."""
-
- name = "wiki"
- demote_headers = True
-
- def compile_html(self, source, dest, is_two_file=True):
- if creole is None:
- req_missing(['creole'], 'build this site (compile CreoleWiki)')
- makedirs(os.path.dirname(dest))
- with codecs.open(dest, "w+", "utf8") as out_file:
- with codecs.open(source, "r", "utf8") as in_file:
- data = in_file.read()
- document = Parser(data).parse()
- output = HtmlEmitter(document).emit()
- out_file.write(output)
-
- def create_post(self, path, onefile=False, is_page=False, **kw):
- metadata = OrderedDict()
- metadata.update(self.default_metadata)
- metadata.update(kw)
- makedirs(os.path.dirname(path))
- if onefile:
- raise Exception('There are no comments in CreoleWiki markup, so '
- 'one-file format is not possible, use the -2 '
- 'option.')
- with codecs.open(path, "wb+", "utf8") as fd:
- fd.write("Write your {0} here.".format('page' if is_page else 'post'))