Skip to content

Commit

Permalink
fix #1374 -- remove metadata comments in PHP files
Browse files Browse the repository at this point in the history
Signed-off-by: Chris “Kwpolska” Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jul 30, 2014
1 parent 607d0f8 commit a46c526
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Features
Bugfixes
--------

* PHP compiler now removes metadata comments the usual way (Issue #1374)
* PHP compiler’s permalinks were .html instead of .php (Issue #1373)
* Fixed importing WordPress blogs outside of / (Issue #1368)
* Fixed importing WordPress blogs without slugs (Issue #1364)
Expand Down
13 changes: 11 additions & 2 deletions nikola/plugins/compile/php.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,30 @@
from __future__ import unicode_literals

import os
import shutil
import codecs
import re

from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, write_metadata


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


class CompilePhp(PageCompiler):
"""Compile PHP into PHP."""

name = "php"

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, **kw):
content = kw.pop('content', None)
Expand Down

0 comments on commit a46c526

Please sign in to comment.