Thanks to those who replied to my earlier email, I've been able to add a custom latex block to my markdown for highlighting best practices in my document. I'd like to take it to the next step and make a filter that will output either this new latex element or an HTML div if encountered. Currently I start each best practice paragraph with ***Best Practice:***, so I'm thinking I can key on that and add what I need around that paragraph. I'm struggling a bit to understand the pandoc filters system. I'm working from the pandoc-filters python examples and source. I *think* I need to key on the Para type, rather than RawBlock, but I'm not certain and can't really find much documentation about the types. The filter below prints to stderr that it's found the string I'm searching for, but when I try to modify the text and return the results I'm not getting the expected results. To simplify things, I've boiled it all down to a filter that finds "Best Practice" and changes is to "Worst Practice." If I can get that working, I think I can get the rest. == Filter source == from pandocfilters import toJSONFilter, Str, Para, RawBlock, stringify import re import sys def bestpractice(key, value, format, meta): global inblock if key == 'Para': s = stringify(value) if format == "latex": if re.search("Best Practice:", s): sys.stderr.write("FOUND") s.replace("Best", "Worst") inblock = True return Para([Str(s)]) if __name__ == "__main__": toJSONFilter(bestpractice) == Markdown == ***Best Practice:*** This is a best practice. It's limited to a single paragraph, although I could add something to end the range if that'll simplify things. I see in the output that the token is being found, but "Worst" doesn't appear in the resulting document. I'm really not sure what to return the edited string as (Para([Str(s))]) is just what I happened to get to run without error). These types don't seem very well documented and I've dug through both the python and haskell sources, but haven't figured them out. Is there a better option than using stringify on the paragraph and then trying to convert it back into a Para object? Is anyone aware of additional filter examples that may include something that munges paragraphs like this? Thanks for the help. -Jeff -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/7ed6f5ef-dd3d-40f5-a096-31a430c16ddc%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.