Closed psteinb closed 9 years ago
Digging a bit further, the following seems to do the job
from pandocfilters import toJSONFilter
from pandocfilters import RawBlock
from pandocfilters import Header
from pandocfilters import stringify
import re
marked_re = re.compile('\{\.[a-z]+.*=.*\}')
def html(x):
return RawBlock('html', x)
def mk_data_background(key, value, fmat, meta):
if key == "Header":
#print stringify(value)
[ident, brief, contents] = value
str_content = stringify(contents)
if not marked_re.search(str_content):
return Header(ident, brief, contents)
new_content = str_content[:str_content.find("{.")]
marked_content = str_content[str_content.find("{.")+2:str_content.rfind("}")]
if marked_content:
html_text = r'<section %s><h1>%s</h1>' % (marked_content, new_content)
return html(html_text)
if __name__ == "__main__":
toJSONFilter(mk_data_background)
But the html has exactly the problem I expected:
<section>
<h1 class="title">Testing data-background</h1>
<h2 class="author">Peter Steinbach, steinbac@mpi-cbg</h2>
<h3 class="date">April 30, 2015</h3>
</section>
<section class="slide level6">
<section data-background="../images/PrincipleFusionDeconvolution.png"><h1>Fusion vs Deconvolution </h1>
</section>
<section><section id="slide-1" class="titleslide slide level2"><h1>slide 1</h1></section></section>
<section><section id="slide-2" class="titleslide slide level2"><h1>slide 2</h1></section></section>
Any ideas?
I suggest you post questions like this on pandoc-discuss at googlegroups. There are lots of people there who can help with filter questions; very few people look at this tracker and it's really for bug reports, not questions.
+++ Peter Steinbach [Jun 09 15 01:58 ]:
Hi - pandocfilters is a great tool to help me making slides based on markdown but producing any output. I am currently struggling to write a pandocfilter in python that allows me to do the following
# Any Title {.data-background="path/to/image.png"} ## Sub-slide 1 ## Sub-slide 2
which then results in
<section data-background="path/to/image.png"> <h1>Any Title</h1> <section><h2>Sub-slide 1</h2></section> <section><h2>Sub-slide 2</h2></section> </section>
inside the reveal.js based output. Should I just look for the
Header
and replace it with raw HTML? How is the closing `' taken care of then? The whole idea behind this would be similar to the {.fragile} annotation in latex beamer. (see http://pandoc.org/demo/example9/producing-slide-shows-with-pandoc.html at the bottom)Best, P
Reply to this email directly or view it on GitHub: https://github.com/jgm/pandocfilters/issues/18
fair enough, I wasn't aware of this. Thanks. Keep going! P
On 06/09/2015 06:42 PM, John MacFarlane wrote:
I suggest you post questions like this on pandoc-discuss at googlegroups. There are lots of people there who can help with filter questions; very few people look at this tracker and it's really for bug reports, not questions.
+++ Peter Steinbach [Jun 09 15 01:58 ]:
Hi - pandocfilters is a great tool to help me making slides based on markdown but producing any output. I am currently struggling to write a pandocfilter in python that allows me to do the following
# Any Title {.data-background="path/to/image.png"} ## Sub-slide 1 ## Sub-slide 2
which then results in
<section data-background="path/to/image.png"> <h1>Any Title</h1> <section><h2>Sub-slide 1</h2></section> <section><h2>Sub-slide 2</h2></section> </section>
inside the reveal.js based output. Should I just look for the
Header
and replace it with raw HTML? How is the closing `' taken care of then? The whole idea behind this would be similar to the {.fragile} annotation in latex beamer. (see http://pandoc.org/demo/example9/producing-slide-shows-with-pandoc.html at the bottom)Best, P
Reply to this email directly or view it on GitHub: https://github.com/jgm/pandocfilters/issues/18
Reply to this email directly or view it on GitHub: https://github.com/jgm/pandocfilters/issues/18#issuecomment-110427582
Just to resolve this, I stumbled over a hint that the functionality I'm interested in already works with plain pandoc:
# Any Title {data-background="path/to/image.png"}
## Sub-slide 1
## Sub-slide 2
Hi - pandocfilters is a great tool to help me making slides based on markdown but producing any output. I am currently struggling to write a pandocfilter in python that allows me to do the following
which then results in
inside the reveal.js based output. Should I just look for the
Header
and replace it with raw HTML? How is the closing `' taken care of then? The whole idea behind this would be similar to the {.fragile} annotation in latex beamer. (see http://pandoc.org/demo/example9/producing-slide-shows-with-pandoc.html at the bottom)Best, P