Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix #973
  • Loading branch information
ralsina committed Jun 9, 2015
1 parent 88c4cad commit 8a522c8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions nikola/plugin_categories.py
Expand Up @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions nikola/plugins/compile/html.py
Expand Up @@ -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."""
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/compile/markdown/__init__.py
Expand Up @@ -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)

Expand Down

0 comments on commit 8a522c8

Please sign in to comment.