{"action":"created","issue":{"url":"https://api.github.com/repos/sergiocorreia/panflute/issues/86","repository_url":"https://api.github.com/repos/sergiocorreia/panflute","labels_url":"https://api.github.com/repos/sergiocorreia/panflute/issues/86/labels{/name}","comments_url":"https://api.github.com/repos/sergiocorreia/panflute/issues/86/comments","events_url":"https://api.github.com/repos/sergiocorreia/panflute/issues/86/events","html_url":"https://github.com/sergiocorreia/panflute/issues/86","id":387475085,"node_id":"MDU6SXNzdWUzODc0NzUwODU=","number":86,"title":"Converting a Para element to BlockQuote","user":{"login":"nickwynja","id":1012017,"node_id":"MDQ6VXNlcjEwMTIwMTc=","avatar_url":"https://avatars0.githubusercontent.com/u/1012017?v=4","gravatar_id":"","url":"https://api.github.com/users/nickwynja","html_url":"https://github.com/nickwynja","followers_url":"https://api.github.com/users/nickwynja/followers","following_url":"https://api.github.com/users/nickwynja/following{/other_user}","gists_url":"https://api.github.com/users/nickwynja/gists{/gist_id}","starred_url":"https://api.github.com/users/nickwynja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickwynja/subscriptions","organizations_url":"https://api.github.com/users/nickwynja/orgs","repos_url":"https://api.github.com/users/nickwynja/repos","events_url":"https://api.github.com/users/nickwynja/events{/privacy}","received_events_url":"https://api.github.com/users/nickwynja/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-12-04T20:53:36Z","updated_at":"2018-12-05T19:36:41Z","closed_at":null,"author_association":"NONE","body":"Hi @sergiocorreia, thanks for making panflute! It's really helped with a couple filters I've wanted to make.\r\n\r\nI'm really struggling with a template and hoping you could lend a hand. I want to create a pandoc filter to have a similar effect as with this `python-markdown` extension that I wrote: https://github.com/nickwynja/mdx_poetic\r\n\r\nEssentially, I want to take a markdown file like below and have it convert `SoftBreak`s to `LineBreak`s and set the entire \"poem\" (the text in between `|||:` and closing `|||`) in a `BlockQuote`.\r\n\r\n```markdown\r\nThis is just some normal text that is prose. It might have some _markdown_.\r\n\r\n|||:\r\n\r\nthis is a\r\nline of a poem\r\n\r\nand this is _another_\r\nstanza of a poem that has a really long line\r\nand more **markdown** in it\r\n\r\n|||\r\n\r\nAnd then this is some **more** markdown that follows.\r\n```\r\n\r\nHere's what I have so far. It _seems_ really quite wrong but it's working convert the linebreaks and then remove the `|||:` and `|||` \"syntax\" out of the file.\r\n\r\n```python\r\n#!/usr/bin/env python3\r\n\r\n\"\"\"\r\nConverts poetics\r\n\"\"\"\r\n\r\nimport panflute as pf\r\n\r\ndef action(e, doc):\r\n    if isinstance(e, pf.Para):\r\n        s = pf.stringify(e).strip()\r\n        if s == '|||:':\r\n            e = e.next\r\n            while s != '|||':\r\n                e.walk(parse_lines)\r\n                e.walk(blockquote)\r\n                e = e.next\r\n                s = pf.stringify(e).strip()\r\n\r\ndef blockquote(e, doc):\r\n    if isinstance(e, pf.Para):\r\n        bq = pf.BlockQuote()\r\n        bq.content = [e]\r\n        return bq\r\n\r\ndef parse_lines(e, doc):\r\n    if isinstance(e, pf.SoftBreak):\r\n        return pf.LineBreak\r\n\r\ndef finalize(doc):\r\n    open_syntax = \"|||:\"\r\n    close_syntax = \"|||\"\r\n    doc.replace_keyword(open_syntax, pf.Null())\r\n    doc.replace_keyword(close_syntax, pf.Null())\r\n\r\ndef main(doc=None):\r\n    pf.toJSONFilter(action, finalize=finalize)\r\n\r\n\r\nif __name__ == '__main__':\r\n    main()\r\n```\r\n\r\nBut I can't for the life of me figure out how to get the `Para`s from inside the `|||:` \"poetry\" block into `BlockQuote`s. You can see with my `blockquote` function, I'm taking a stab at it but with no effect.\r\n\r\nI'd appreciate any advice you might have.\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/sergiocorreia/panflute/issues/comments/444615886","html_url":"https://github.com/sergiocorreia/panflute/issues/86#issuecomment-444615886","issue_url":"https://api.github.com/repos/sergiocorreia/panflute/issues/86","id":444615886,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NDYxNTg4Ng==","user":{"login":"nickwynja","id":1012017,"node_id":"MDQ6VXNlcjEwMTIwMTc=","avatar_url":"https://avatars0.githubusercontent.com/u/1012017?v=4","gravatar_id":"","url":"https://api.github.com/users/nickwynja","html_url":"https://github.com/nickwynja","followers_url":"https://api.github.com/users/nickwynja/followers","following_url":"https://api.github.com/users/nickwynja/following{/other_user}","gists_url":"https://api.github.com/users/nickwynja/gists{/gist_id}","starred_url":"https://api.github.com/users/nickwynja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickwynja/subscriptions","organizations_url":"https://api.github.com/users/nickwynja/orgs","repos_url":"https://api.github.com/users/nickwynja/repos","events_url":"https://api.github.com/users/nickwynja/events{/privacy}","received_events_url":"https://api.github.com/users/nickwynja/received_events","type":"User","site_admin":false},"created_at":"2018-12-05T19:36:41Z","updated_at":"2018-12-05T19:36:41Z","author_association":"NONE","body":"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.\r\n\r\nGiven a case like this:\r\n````\r\n```poem style='italic'\r\nAnd in a blink, we rise above the tarmac\r\nand the city shrinks. The problems there\r\nseem miniscule instantly compared to the\r\ngrandeur of the world around. You transform\r\nin moments from the ants milling about into\r\nthe birds soaring above.\r\n```\r\n````\r\n\r\nwhere there is some sort of option passed to the codeblock (as supported in [superfences](https://facelessuser.github.io/pymdown-extensions/extensions/superfences/#custom-fences), 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\"."}}
{"actor":{"display_login":"nickwynja"}}