Git Product home page Git Product logo

Comments (5)

sergiocorreia avatar sergiocorreia commented on August 22, 2024

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.

nickwynja avatar nickwynja commented on August 22, 2024

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.

nickwynja avatar nickwynja commented on August 22, 2024

To clarify, I don't intend to use the style='italic' string for any use within pandoc, it can simply be ignored.

from panflute.

sergiocorreia avatar sergiocorreia commented on August 22, 2024

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.

nickwynja avatar nickwynja commented on August 22, 2024

Got it. Thanks for all of your help!

from panflute.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.