diff --git a/liquid_tags/img.py b/liquid_tags/img.py index 68a3b1a..26039e4 100644 --- a/liquid_tags/img.py +++ b/liquid_tags/img.py @@ -36,7 +36,6 @@ ReTitleAlt = re.compile("""(?:"|')(?P
tags
+ body = body.replace('"
+
+ # specialize headers
+ for h in '123456':
+ body = body.replace(' tags
+ header = header.replace('html, body', '\n'.join(('pre.ipynb {',
+ ' color: black;',
+ ' background: #f7f7f7;',
+ ' border: 0;',
+ ' box-shadow: none;',
+ ' margin-bottom: 0;',
+ ' padding: 0;'
+ '}\n',
+ 'html, body')))
+
+ # create a special div for notebook
+ header = header.replace('body {', 'div.ipynb {')
+
+ # specialize headers
+ header = header.replace('html, body,',
+ '\n'.join((('h1.ipynb h2.ipynb h3.ipynb '
+ 'h4.ipynb h5.ipynb h6.ipynb {'),
+ 'h1.ipynb h2.ipynb ... {',
+ ' margin: 0;',
+ ' padding: 0;',
+ ' border: 0;',
+ ' font-size: 100%;',
+ ' font: inherit;',
+ ' vertical-align: baseline;',
+ '}\n',
+ 'html, body,')))
+
+ header = header.replace('html, body,',
+ '/*html, body,*/')
+ header = header.replace('h1, h2, h3, h4, h5, h6,',
+ '/*h1, h2, h3, h4, h5, h6,*/')
+
+ return header.split('\n')
+
+
+@LiquidTags.register('notebook')
+def notebook(preprocessor, tag, markup):
+ match = FORMAT.search(markup)
+ if match:
+ argdict = match.groupdict()
+ src = argdict['src']
+ else:
+ raise ValueError("Error processing input, "
+ "expected syntax: {0}".format(SYNTAX))
+
+ # TODO: make the notebook directory a configurable setting
+ nb_dir = 'notebooks'
+ nb_path = os.path.join('content', nb_dir, src)
+ url = '/{0}/{1}/{2}'.format('static', nb_dir, src)
+
+ if not os.path.exists(nb_path):
+ raise ValueError("File {0} could not be found".format(nb_path))
+
+ # Call the notebook converter
+ converter = ConverterBloggerHTML(nb_path)
+ converter.read()
+
+ header_lines = process_header(converter.header_body())
+
+ print ("\n *** Writing styles to _nb_header.html: "
+ "this should be included in the theme.\n")
+ open('_nb_header.html', 'w').write('\n'.join(header_lines).encode('utf-8'))
+
+ body_lines = process_body(converter.main_body('\n'))
+
+ body = preprocessor.configs.htmlStash.store('\n'.join(body_lines),
+ safe=True)
+ return body
+
+
+#----------------------------------------------------------------------
+# This import allows image tag to be a Pelican plugin
+from liquid_tags import register
diff --git a/liquid_tags/video.py b/liquid_tags/video.py
index 5ce441a..2bff9fb 100644
--- a/liquid_tags/video.py
+++ b/liquid_tags/video.py
@@ -35,8 +35,6 @@ VID_TYPEDICT = {'.mp4':"type='video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"'",
@LiquidTags.register('video')
def video(preprocessor, tag, markup):
- markup = markup.strip()
-
videos = []
width = None
height = None