Skip to content
Permalink
Browse files

fix #973

  • Loading branch information
ralsina committed Jun 9, 2015
1 parent 88c4cad commit 8a522c81e3481b9cfd7044a10b76d72fd807ff6b
Showing with 10 additions and 4 deletions.
  1. +1 −0 CHANGES.txt
  2. +7 −0 nikola/plugin_categories.py
  3. +1 −3 nikola/plugins/compile/html.py
  4. +1 −1 nikola/plugins/compile/markdown/__init__.py
@@ -11,6 +11,7 @@ Features
Bugfixes
--------

* Cleaner splitting of metadata in onefile posts (Issue #973)
* It's markdown extra, not extras (Issue #1799)

New in v7.5.0
@@ -270,6 +270,13 @@ def read_metadata(self, post, file_metadata_regexp=None, unslugify_titles=False,
"""
return {}

def split_metadata(self, data):
"""Split data from metadata in the raw post content.
This splits in the first empty line that is NOT at the beginning
of the document."""

return re.split('(\n\n|\r\n\r\n)', data.lstrip(), maxsplit=1)

class RestExtension(BasePlugin):
name = "dummy_rest_extension"
@@ -35,8 +35,6 @@
from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, write_metadata

_META_SEPARATOR = '(' + os.linesep * 2 + '|' + ('\n' * 2) + '|' + ("\r\n" * 2) + ')'


class CompileHtml(PageCompiler):
"""Compile HTML into HTML."""
@@ -48,7 +46,7 @@ def compile_html(self, source, dest, is_two_file=True):
with io.open(source, "r", encoding="utf8") as in_file:
data = in_file.read()
if not is_two_file:
data = re.split(_META_SEPARATOR, data, maxsplit=1)[-1]
_, data = self.split_metadata(data)
out_file.write(data)
return True

@@ -76,7 +76,7 @@ def compile_html(self, source, dest, is_two_file=True):
with io.open(source, "r", encoding="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]
_, data = self.split_metadata(data)
output = markdown(data, self.extensions)
out_file.write(output)

0 comments on commit 8a522c8

Please sign in to comment.
You can’t perform that action at this time.