Skip to content
Permalink
Browse files
Shortcode support for mediawiki compiler
  • Loading branch information
ralsina committed Sep 24, 2016
1 parent 3067694 commit 651995c223d8b8a881ef3ac7d6aad7aa6f58cf94
Showing with 14 additions and 2 deletions.
  1. +1 −1 v7/mediawiki/mediawiki.plugin
  2. +12 −0 v7/mediawiki/mediawiki.py
  3. +1 −1 v7/mediawiki/requirements.txt
@@ -7,6 +7,6 @@ plugincategory = Compiler

[Documentation]
Author = Roberto Alsina
Version = 0.2
Version = 0.3
Website = http://plugins.getnikola.com/#mediawiki
Description = Compile MediaWiki markup into HTML using smc.mw
@@ -61,6 +61,10 @@ def compile_html(self, source, dest, is_two_file=True):
makedirs(os.path.dirname(dest))
if mw is None:
req_missing(['smc.mw'], 'build this site (compile with MediaWiki)', python=True)
try:
post = self.site.post_per_input_file[source]
except KeyError:
post = None
with io.open(dest, "w+", encoding="utf8") as out_file:
with io.open(source, "r", encoding="utf8") as in_file:
data = in_file.read()
@@ -69,7 +73,15 @@ def compile_html(self, source, dest, is_two_file=True):
parser = mw.Parser(parseinfo=False, whitespace='', nameguard=False)
ast = parser.parse(data, 'document', semantics=mw.Semantics(parser))
output = etree.tostring(ast, encoding='utf8').decode('utf8')
output, shortcode_deps = self.site.apply_shortcodes(output, filename=source, with_dependencies=True, extra_context=dict(post=post))
out_file.write(output)
if post is None:
if shortcode_deps:
self.logger.error(
"Cannot save dependencies for post {0} due to unregistered source file name",
source)
else:
post._depfile[dest] += shortcode_deps

def create_post(self, path, **kw):
content = kw.pop('content', None)
@@ -1,2 +1,2 @@
https://github.com/lambdafu/smc.mw/archive/master.zip
grako
grako==2.4.3

0 comments on commit 651995c

Please sign in to comment.