diff options
Diffstat (limited to 'nikola/plugins/compile')
26 files changed, 218 insertions, 53 deletions
diff --git a/nikola/plugins/compile/__init__.py b/nikola/plugins/compile/__init__.py index e69de29..6ad8bac 100644 --- a/nikola/plugins/compile/__init__.py +++ b/nikola/plugins/compile/__init__.py @@ -0,0 +1,25 @@ +# -*- 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. diff --git a/nikola/plugins/compile/asciidoc.py b/nikola/plugins/compile/asciidoc.py index 67dfe1a..12cb4bf 100644 --- a/nikola/plugins/compile/asciidoc.py +++ b/nikola/plugins/compile/asciidoc.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 @@ -37,11 +37,17 @@ import subprocess from nikola.plugin_categories import PageCompiler from nikola.utils import makedirs, req_missing +try: + from collections import OrderedDict +except ImportError: + OrderedDict = None # 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)) @@ -52,7 +58,10 @@ class CompileAsciiDoc(PageCompiler): req_missing(['asciidoc'], 'build this site (compile with asciidoc)', python=False) def create_post(self, path, onefile=False, **kw): - metadata = {} + if OrderedDict is not None: + metadata = OrderedDict() + else: + metadata = {} metadata.update(self.default_metadata) metadata.update(kw) makedirs(os.path.dirname(path)) diff --git a/nikola/plugins/compile/bbcode.py b/nikola/plugins/compile/bbcode.py index e998417..5345be3 100644 --- a/nikola/plugins/compile/bbcode.py +++ b/nikola/plugins/compile/bbcode.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 @@ -37,6 +37,10 @@ except ImportError: from nikola.plugin_categories import PageCompiler from nikola.utils import makedirs, req_missing +try: + from collections import OrderedDict +except ImportError: + OrderedDict = None # NOQA class CompileBbcode(PageCompiler): @@ -63,7 +67,10 @@ class CompileBbcode(PageCompiler): out_file.write(output) def create_post(self, path, onefile=False, **kw): - metadata = {} + if OrderedDict is not None: + metadata = OrderedDict() + else: + metadata = {} metadata.update(self.default_metadata) metadata.update(kw) makedirs(os.path.dirname(path)) diff --git a/nikola/plugins/compile/html.py b/nikola/plugins/compile/html.py index a309960..5352f00 100644 --- a/nikola/plugins/compile/html.py +++ b/nikola/plugins/compile/html.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 @@ -27,25 +27,40 @@ """Implementation of compile_html for HTML source files.""" import os -import shutil +import re import codecs from nikola.plugin_categories import PageCompiler from nikola.utils import makedirs +try: + from collections import OrderedDict +except ImportError: + OrderedDict = None # NOQA + + +_META_SEPARATOR = '(' + os.linesep * 2 + '|' + ('\n' * 2) + '|' + ("\r\n" * 2) + ')' + class CompileHtml(PageCompiler): """Compile HTML into HTML.""" - name = "html" def compile_html(self, source, dest, is_two_file=True): makedirs(os.path.dirname(dest)) - shutil.copyfile(source, 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(_META_SEPARATOR, data, maxsplit=1)[-1] + out_file.write(data) return True def create_post(self, path, onefile=False, **kw): - metadata = {} + if OrderedDict is not None: + metadata = OrderedDict() + else: + metadata = {} metadata.update(self.default_metadata) metadata.update(kw) makedirs(os.path.dirname(path)) @@ -55,4 +70,4 @@ class CompileHtml(PageCompiler): for k, v in metadata.items(): fd.write('.. {0}: {1}\n'.format(k, v)) fd.write('-->\n\n') - fd.write("\n<p>Write your post here.</p>") + fd.write("\n<p>Write your post here.</p>\n") diff --git a/nikola/plugins/compile/ipynb/__init__.py b/nikola/plugins/compile/ipynb/__init__.py index 7c318ca..5f2f0b3 100644 --- a/nikola/plugins/compile/ipynb/__init__.py +++ b/nikola/plugins/compile/ipynb/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2013 Damian Avila. +# Copyright © 2013-2014 Damián Avila and others. # Permission is hereby granted, free of charge, to any # person obtaining a copy of this software and associated @@ -41,6 +41,11 @@ except ImportError: from nikola.plugin_categories import PageCompiler from nikola.utils import makedirs, req_missing +try: + from collections import OrderedDict +except ImportError: + OrderedDict = None # NOQA + class CompileIPynb(PageCompiler): """Compile IPynb into HTML.""" @@ -49,7 +54,7 @@ class CompileIPynb(PageCompiler): def compile_html(self, source, dest, is_two_file=True): if flag is None: - req_missing(['ipython>=1.0.0'], 'build this site (compile ipynb)') + req_missing(['ipython>=1.1.0'], 'build this site (compile ipynb)') makedirs(os.path.dirname(dest)) HTMLExporter.default_template = 'basic' c = Config(self.site.config['IPYNB_CONFIG']) @@ -62,18 +67,20 @@ class CompileIPynb(PageCompiler): out_file.write(body) def create_post(self, path, onefile=False, **kw): - metadata = {} + if OrderedDict is not None: + metadata = OrderedDict() + else: + metadata = {} metadata.update(self.default_metadata) metadata.update(kw) d_name = os.path.dirname(path) makedirs(os.path.dirname(path)) meta_path = os.path.join(d_name, kw['slug'] + ".meta") with codecs.open(meta_path, "wb+", "utf8") as fd: - if onefile: - fd.write('%s\n' % kw['title']) - fd.write('%s\n' % kw['slug']) - fd.write('%s\n' % kw['date']) - fd.write('%s\n' % kw['tags']) + fd.write('\n'.join((metadata['title'], metadata['slug'], + metadata['date'], metadata['tags'], + metadata['link'], + metadata['description'], metadata['type']))) print("Your post's metadata is at: ", meta_path) with codecs.open(path, "wb+", "utf8") as fd: fd.write("""{ diff --git a/nikola/plugins/compile/markdown/__init__.py b/nikola/plugins/compile/markdown/__init__.py index b41c6b5..1376b11 100644 --- a/nikola/plugins/compile/markdown/__init__.py +++ b/nikola/plugins/compile/markdown/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 @@ -50,6 +50,12 @@ except ImportError: gist_extension = None podcast_extension = None + +try: + from collections import OrderedDict +except ImportError: + OrderedDict = None # NOQA + from nikola.plugin_categories import PageCompiler from nikola.utils import makedirs, req_missing @@ -58,6 +64,7 @@ class CompileMarkdown(PageCompiler): """Compile markdown into HTML.""" name = "markdown" + demote_headers = True extensions = [gist_extension, nikola_extension, podcast_extension] site = None @@ -75,7 +82,10 @@ class CompileMarkdown(PageCompiler): out_file.write(output) def create_post(self, path, onefile=False, **kw): - metadata = {} + if OrderedDict is not None: + metadata = OrderedDict() + else: + metadata = {} metadata.update(self.default_metadata) metadata.update(kw) makedirs(os.path.dirname(path)) diff --git a/nikola/plugins/compile/markdown/mdx_gist.py b/nikola/plugins/compile/markdown/mdx_gist.py index 3c3bef9..d92295d 100644 --- a/nikola/plugins/compile/markdown/mdx_gist.py +++ b/nikola/plugins/compile/markdown/mdx_gist.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (c) 2013 Michael Rabbitt. +# Copyright © 2013 Michael Rabbitt. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the diff --git a/nikola/plugins/compile/markdown/mdx_nikola.py b/nikola/plugins/compile/markdown/mdx_nikola.py index b0ad2f7..b7c29a5 100644 --- a/nikola/plugins/compile/markdown/mdx_nikola.py +++ b/nikola/plugins/compile/markdown/mdx_nikola.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 @@ -34,10 +34,6 @@ from markdown.extensions import Extension class NikolaPostProcessor(Postprocessor): def run(self, text): output = text - # h1 is reserved for the title so increment all header levels - for n in reversed(range(1, 9)): - output = re.sub('<h%i>' % n, '<h%i>' % (n + 1), output) - output = re.sub('</h%i>' % n, '</h%i>' % (n + 1), output) # python-markdown's highlighter uses the class 'codehilite' to wrap # code, instead of the standard 'code'. None of the standard diff --git a/nikola/plugins/compile/markdown/mdx_podcast.py b/nikola/plugins/compile/markdown/mdx_podcast.py index be8bb6b..b38b969 100644 --- a/nikola/plugins/compile/markdown/mdx_podcast.py +++ b/nikola/plugins/compile/markdown/mdx_podcast.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (c) 2013 Michael Rabbitt, Roberto Alsina +# Copyright © 2013-2014 Michael Rabbitt, 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 diff --git a/nikola/plugins/compile/misaka.py b/nikola/plugins/compile/misaka.py index 3733a85..8777ffc 100644 --- a/nikola/plugins/compile/misaka.py +++ b/nikola/plugins/compile/misaka.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2013 Chris Lee +# 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 @@ -37,6 +37,11 @@ try: except ImportError: misaka = None # NOQA nikola_extension = None +try: + from collections import OrderedDict +except ImportError: + OrderedDict = None # NOQA + gist_extension = None podcast_extension = None @@ -48,6 +53,7 @@ class CompileMisaka(PageCompiler): """Compile Misaka into HTML.""" name = "misaka" + demote_headers = True def __init__(self, *args, **kwargs): super(CompileMisaka, self).__init__(*args, **kwargs) @@ -68,7 +74,10 @@ class CompileMisaka(PageCompiler): out_file.write(output) def create_post(self, path, onefile=False, **kw): - metadata = {} + if OrderedDict is not None: + metadata = OrderedDict() + else: + metadata = {} metadata.update(self.default_metadata) metadata.update(kw) makedirs(os.path.dirname(path)) diff --git a/nikola/plugins/compile/pandoc.py b/nikola/plugins/compile/pandoc.py index 3a2911f..57c7d71 100644 --- a/nikola/plugins/compile/pandoc.py +++ b/nikola/plugins/compile/pandoc.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 @@ -37,6 +37,11 @@ import subprocess from nikola.plugin_categories import PageCompiler from nikola.utils import req_missing, makedirs +try: + from collections import OrderedDict +except ImportError: + OrderedDict = None # NOQA + class CompilePandoc(PageCompiler): """Compile markups into HTML using pandoc.""" @@ -52,7 +57,10 @@ class CompilePandoc(PageCompiler): req_missing(['pandoc'], 'build this site (compile with pandoc)', python=False) def create_post(self, path, onefile=False, **kw): - metadata = {} + if OrderedDict is not None: + metadata = OrderedDict() + else: + metadata = {} metadata.update(self.default_metadata) metadata.update(kw) makedirs(os.path.dirname(path)) diff --git a/nikola/plugins/compile/php.py b/nikola/plugins/compile/php.py index 44701c8..14b80e8 100644 --- a/nikola/plugins/compile/php.py +++ b/nikola/plugins/compile/php.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 @@ -35,6 +35,11 @@ import codecs from nikola.plugin_categories import PageCompiler from nikola.utils import makedirs +try: + from collections import OrderedDict +except ImportError: + OrderedDict = None # NOQA + class CompilePhp(PageCompiler): """Compile PHP into PHP.""" @@ -46,7 +51,10 @@ class CompilePhp(PageCompiler): shutil.copyfile(source, dest) def create_post(self, path, onefile=False, **kw): - metadata = {} + if OrderedDict is not None: + metadata = OrderedDict() + else: + metadata = {} metadata.update(self.default_metadata) metadata.update(kw) os.makedirs(os.path.dirname(path)) diff --git a/nikola/plugins/compile/rest/__init__.py b/nikola/plugins/compile/rest/__init__.py index c71a5f8..50b37cf 100644 --- a/nikola/plugins/compile/rest/__init__.py +++ b/nikola/plugins/compile/rest/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 @@ -35,10 +35,16 @@ try: import docutils.utils import docutils.io import docutils.readers.standalone + import docutils.writers.html4css1 has_docutils = True except ImportError: has_docutils = False +try: + from collections import OrderedDict +except ImportError: + OrderedDict = None # NOQA + from nikola.plugin_categories import PageCompiler from nikola.utils import get_logger, makedirs, req_missing @@ -47,6 +53,7 @@ class CompileRest(PageCompiler): """Compile reSt into HTML.""" name = "rest" + demote_headers = True logger = None def compile_html(self, source, dest, is_two_file=True): @@ -71,14 +78,16 @@ class CompileRest(PageCompiler): # author). add_ln = len(spl[0].splitlines()) + 1 + default_template_path = os.path.join(os.path.dirname(__file__), 'template.txt') output, error_level, deps = rst2html( data, settings_overrides={ - 'initial_header_level': 2, + 'initial_header_level': 1, 'record_dependencies': True, 'stylesheet_path': None, 'link_stylesheet': True, 'syntax_highlight': 'short', 'math_output': 'mathjax', + 'template': default_template_path, }, logger=self.logger, l_source=source, l_add_ln=add_ln) out_file.write(output) deps_path = dest + '.dep' @@ -94,7 +103,10 @@ class CompileRest(PageCompiler): return False def create_post(self, path, onefile=False, **kw): - metadata = {} + if OrderedDict is not None: + metadata = OrderedDict() + else: + metadata = {} metadata.update(self.default_metadata) metadata.update(kw) makedirs(os.path.dirname(path)) @@ -117,6 +129,9 @@ class CompileRest(PageCompiler): plugin_info.plugin_object.short_help = plugin_info.description self.logger = get_logger('compile_rest', site.loghandlers) + if not site.debug: + self.logger.level = 4 + return super(CompileRest, self).set_site(site) @@ -139,7 +154,10 @@ def get_observer(settings): """ errormap = {0: 1, 1: 2, 2: 4, 3: 5, 4: 6} text = docutils.nodes.Element.astext(msg) - out = '[{source}:{line}] {text}'.format(source=settings['source'], line=msg['line'] + settings['add_ln'], text=text) + line = msg['line'] + settings['add_ln'] if 'line' in msg else 0 + out = '[{source}{colon}{line}] {text}'.format( + source=settings['source'], colon=(':' if line else ''), + line=line, text=text) settings['logger'].log(errormap[msg['level']], out) return observer @@ -155,6 +173,14 @@ class NikolaReader(docutils.readers.standalone.Reader): return document +def add_node(node, visit_function=None, depart_function=None): + docutils.nodes._add_node_class_names([node.__name__]) + if visit_function: + setattr(docutils.writers.html4css1.HTMLTranslator, 'visit_' + node.__name__, visit_function) + if depart_function: + setattr(docutils.writers.html4css1.HTMLTranslator, 'depart_' + node.__name__, depart_function) + + def rst2html(source, source_path=None, source_class=docutils.io.StringInput, destination_path=None, reader=None, parser=None, parser_name='restructuredtext', writer=None, diff --git a/nikola/plugins/compile/rest/chart.py b/nikola/plugins/compile/rest/chart.py index ee917b9..03878a3 100644 --- a/nikola/plugins/compile/rest/chart.py +++ b/nikola/plugins/compile/rest/chart.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 diff --git a/nikola/plugins/compile/rest/doc.py b/nikola/plugins/compile/rest/doc.py index 915a7e1..a150a81 100644 --- a/nikola/plugins/compile/rest/doc.py +++ b/nikola/plugins/compile/rest/doc.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 diff --git a/nikola/plugins/compile/rest/listing.py b/nikola/plugins/compile/rest/listing.py index 31975bb..ecf885f 100644 --- a/nikola/plugins/compile/rest/listing.py +++ b/nikola/plugins/compile/rest/listing.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 diff --git a/nikola/plugins/compile/rest/media.py b/nikola/plugins/compile/rest/media.py index d1930dd..ccda559 100644 --- a/nikola/plugins/compile/rest/media.py +++ b/nikola/plugins/compile/rest/media.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 diff --git a/nikola/plugins/compile/rest/post_list.py b/nikola/plugins/compile/rest/post_list.py index eae4016..6804b58 100644 --- a/nikola/plugins/compile/rest/post_list.py +++ b/nikola/plugins/compile/rest/post_list.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2013 Udo Spallek, Roberto Alsina and others. +# Copyright © 2013-2014 Udo Spallek, Roberto Alsina and others. # Permission is hereby granted, free of charge, to any # person obtaining a copy of this software and associated @@ -33,6 +33,9 @@ from docutils.parsers.rst import Directive, directives from nikola import utils from nikola.plugin_categories import RestExtension +# WARNING: the directive name is post-list +# (with a DASH instead of an UNDERSCORE) + class Plugin(RestExtension): name = "rest_post_list" diff --git a/nikola/plugins/compile/rest/slides.py b/nikola/plugins/compile/rest/slides.py index 41c3314..203ae51 100644 --- a/nikola/plugins/compile/rest/slides.py +++ b/nikola/plugins/compile/rest/slides.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 diff --git a/nikola/plugins/compile/rest/soundcloud.py b/nikola/plugins/compile/rest/soundcloud.py index 6fb3e99..a26806c 100644 --- a/nikola/plugins/compile/rest/soundcloud.py +++ b/nikola/plugins/compile/rest/soundcloud.py @@ -15,12 +15,13 @@ class Plugin(RestExtension): def set_site(self, site): self.site = site directives.register_directive('soundcloud', SoundCloud) + directives.register_directive('soundcloud_playlist', SoundCloudPlaylist) return super(Plugin, self).set_site(site) CODE = ("""<iframe width="{width}" height="{height}" scrolling="no" frameborder="no" -src="https://w.soundcloud.com/player/?url=http://api.soundcloud.com/tracks/""" +src="https://w.soundcloud.com/player/?url=http://api.soundcloud.com/{preslug}/""" """{sid}"> </iframe>""") @@ -40,6 +41,7 @@ class SoundCloud(Directive): 'width': directives.positive_int, 'height': directives.positive_int, } + preslug = "tracks" def run(self): """ Required by the Directive interface. Create docutils nodes """ @@ -48,6 +50,7 @@ class SoundCloud(Directive): 'sid': self.arguments[0], 'width': 600, 'height': 160, + 'preslug': self.preslug, } options.update(self.options) return [nodes.raw('', CODE.format(**options), format='html')] @@ -58,3 +61,7 @@ class SoundCloud(Directive): raise self.warning("This directive does not accept content. The " "'key=value' format for options is deprecated, " "use ':key: value' instead") + + +class SoundCloudPlaylist(SoundCloud): + preslug = "playlists" diff --git a/nikola/plugins/compile/rest/template.txt b/nikola/plugins/compile/rest/template.txt new file mode 100644 index 0000000..2591bce --- /dev/null +++ b/nikola/plugins/compile/rest/template.txt @@ -0,0 +1,8 @@ +%(head_prefix)s +%(head)s +%(stylesheet)s +%(body_prefix)s +%(body_pre_docinfo)s +%(docinfo)s +%(body)s +%(body_suffix)s diff --git a/nikola/plugins/compile/rest/vimeo.py b/nikola/plugins/compile/rest/vimeo.py index 6d66648..82c4dc1 100644 --- a/nikola/plugins/compile/rest/vimeo.py +++ b/nikola/plugins/compile/rest/vimeo.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 diff --git a/nikola/plugins/compile/rest/youtube.py b/nikola/plugins/compile/rest/youtube.py index 3d4bdd3..19e12d1 100644 --- a/nikola/plugins/compile/rest/youtube.py +++ b/nikola/plugins/compile/rest/youtube.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 diff --git a/nikola/plugins/compile/textile.py b/nikola/plugins/compile/textile.py index b402329..73f35c0 100644 --- a/nikola/plugins/compile/textile.py +++ b/nikola/plugins/compile/textile.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 @@ -38,11 +38,17 @@ except ImportError: from nikola.plugin_categories import PageCompiler from nikola.utils import makedirs, req_missing +try: + from collections import OrderedDict +except ImportError: + OrderedDict = None # 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: @@ -57,7 +63,10 @@ class CompileTextile(PageCompiler): out_file.write(output) def create_post(self, path, onefile=False, **kw): - metadata = {} + if OrderedDict is not None: + metadata = OrderedDict() + else: + metadata = {} metadata.update(self.default_metadata) metadata.update(kw) makedirs(os.path.dirname(path)) diff --git a/nikola/plugins/compile/txt2tags.py b/nikola/plugins/compile/txt2tags.py index 2f62f04..8c9724e 100644 --- a/nikola/plugins/compile/txt2tags.py +++ b/nikola/plugins/compile/txt2tags.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 @@ -40,14 +40,20 @@ try: except ImportError: txt2tags = None # NOQA +try: + from collections import OrderedDict +except ImportError: + OrderedDict = None # NOQA + from nikola.plugin_categories import PageCompiler from nikola.utils import makedirs, req_missing -class CompileTextile(PageCompiler): +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: @@ -57,7 +63,10 @@ class CompileTextile(PageCompiler): txt2tags(cmd) def create_post(self, path, onefile=False, **kw): - metadata = {} + if OrderedDict is not None: + metadata = OrderedDict() + else: + metadata = {} metadata.update(self.default_metadata) metadata.update(kw) makedirs(os.path.dirname(path)) diff --git a/nikola/plugins/compile/wiki.py b/nikola/plugins/compile/wiki.py index b2c4afc..9a365fa 100644 --- a/nikola/plugins/compile/wiki.py +++ b/nikola/plugins/compile/wiki.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2013 Roberto Alsina and others. +# 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 @@ -37,6 +37,11 @@ except ImportError: creole = None from nikola.plugin_categories import PageCompiler +try: + from collections import OrderedDict +except ImportError: + OrderedDict = None # NOQA + from nikola.utils import makedirs, req_missing @@ -44,6 +49,7 @@ 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: @@ -57,7 +63,10 @@ class CompileWiki(PageCompiler): out_file.write(output) def create_post(self, path, onefile=False, **kw): - metadata = {} + if OrderedDict is not None: + metadata = OrderedDict() + else: + metadata = {} metadata.update(self.default_metadata) metadata.update(kw) makedirs(os.path.dirname(path)) |
