Git Product home page Git Product logo

Comments (5)

sergiocorreia avatar sergiocorreia commented on July 21, 2024

Could you give me an example of how the markdown would look like? If you just want to run the filters already in the markdown file, I don't think you need to even save them as files. I would i) make a list of al the filters in the document, ii) and run eval() on them, while passing them the document.

from panflute.

kiwi0fruit avatar kiwi0fruit commented on July 21, 2024

Thank you for help.

Markdown code with a chunk would be like:

``` {panflute-name=filter_x}
# standard filter with main()
```

So you mean I should have a meta-filter like this (looks like this would work):

def prepare(doc):
    # add to the doc the temporary list
    # with found code chunks.
    # Now it's empty.

def action(elem, doc):
    # if the element is a code chunk
    # and has kwarg `panflute-name`
    # then add this code chunk to the
    # temp list.

def finalize(doc):
    # Loop over temp list. On each item:
        eval(item)
        main(doc)
    # Then delete temp list


def main(doc=None):
    return run_filter(action, prepare=prepare, finalize=finalize, doc=doc) 

from panflute.

sergiocorreia avatar sergiocorreia commented on July 21, 2024

I think that will work. I was a bit concerned about evaling functions with the same names (prepare, etc.) but since you are evaling within finalize, you could eval() it with a different namespace (if any issue arises)

from panflute.

kiwi0fruit avatar kiwi0fruit commented on July 21, 2024

from panflute.

kiwi0fruit avatar kiwi0fruit commented on July 21, 2024

Now I think that it's a bad idea :-) Closing.

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.