Comments (5)
Hi Nick,
The way I tackled this issue was by taking advantage of "yaml blocks" (api) and using them for other purposes. For instance, this is the example filter:
#!/usr/bin/env python3
"""
Converts poetics
"""
import io
import csv
import panflute as pf
def fenced_action(options, data, element, doc):
para = pf.convert_text(element.text)
block = pf.BlockQuote(*para)
return block
def main(doc=None):
return pf.run_filter(pf.yaml_filter,
tag='poem',
function=fenced_action,
doc=doc)
if __name__ == '__main__':
main()
And this is the example markdown file:
This is just some normal text that is prose. It might have some _markdown_.
~~~ poem
this is a
line of a poem
and this is yet _another_
stanza of a poem that has a really long line which will wrap
and more **markdown** in it
~~~
And then this is some **more** markdown that follows.
Basically, it's quite tricky to match brackets (such as |||:
and |||
) so I just gave up and resorted to this approach. If you really want to use the three pipes, you can also replace the pipes into tildes right before calling pandoc/panflute.
Cheers,
S
from panflute.
Thanks @sergiocorreia, this is working well! I've updated to using a codeblock syntax as you've suggested since it is more standard across markdown.
Given a case like this:
```poem style='italic'
And in a blink, we rise above the tarmac
and the city shrinks. The problems there
seem miniscule instantly compared to the
grandeur of the world around. You transform
in moments from the ants milling about into
the birds soaring above.
```
where there is some sort of option passed to the codeblock (as supported in superfences, is there anyway to ignore this text for processing it? When I have a block like above and try to process it with your code to latex, it seems to get confused and process it as a normal paragraph rather than the "poem".
from panflute.
To clarify, I don't intend to use the style='italic'
string for any use within pandoc, it can simply be ignored.
from panflute.
The code snipped used yaml blocks (~~~) instead of code blocks (what superfences use), but you can just adapt the underlying code in yaml_filter() for the other type of blocks. The extra options should be ignored automatically then.
from panflute.
Got it. Thanks for all of your help!
from panflute.
Related Issues (20)
- stringify bug with Cite
- Nav and other HTML5 elements missing
- How to skip a table? HOT 2
- Creating a Table without a Caption produces error HOT 1
- Creating a Panflute filter that interacts with other filters HOT 1
- Reimplement the panflute.stringify with native pandoc writer HOT 2
- Unable to get Panflute filter comments.py to work correctly HOT 1
- Add comparison method to Element class? HOT 2
- Compatibility with Pandoc 2.18 HOT 3
- Using panflute as a writer rather than a filter HOT 8
- Stringifying the terms of a definition list results in AttributeError HOT 7
- Hwo to use the span method? HOT 1
- Applying panflute filter multiple times generates an unexpected result
- Can't convert markdown style citations to LaTeX style using panflute filter HOT 5
- Navigation with next and prev unstable HOT 3
- Add space before footnote in stringify function HOT 4
- Is there solution to add custom style for lists with panflute ? HOT 2
- Avoid side-effects in walk
- Figure, Table: to_json() crashes if caption is None HOT 1
- Reading the value of `--resource-path` inside a panflute filter ? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from panflute.