-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to write a filter that runs all filters that are written in code chunks inside markdown? #72
Comments
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 |
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) |
I think that will work. I was a bit concerned about |
Thanks again. I think I would post it here when it would be ready.
6 нояб. 2017 г. 10:58 пользователь "Sergio Correia" <
notifications@github.com> написал:
… 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
<https://stackoverflow.com/questions/13923091/how-do-you-do-a-python-eval-only-within-an-object-context>
(if any issue arises)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#72 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AS0iTe0UDcVmRihKxpDM6aqrZiYautViks5szoP8gaJpZM4QSelK>
.
|
Now I think that it's a bad idea :-) Closing. |
How to write a filter (
meta-filter
) that runs all filters that are written in code chunks inside markdown?Some code chunk can have attributes like
panflute-name=filter_x
. And metadata can have:I know how to find all such chunks. Then that meta-filter writes code from each chunk to it's own file like
C:/meta-filter/filter_x.py
before it'smain()
function.The question: would
filter_x
run in this scenario or reading from that file or checking if it's exist would occure before first meta-filter run?The text was updated successfully, but these errors were encountered: