Re: [Pharo-users] Do we have a simple markdown parser?
Hmm I hadnât even thought of Xstreams⦠I always thought it sounded cool, perhaps its a place to start - but as you mention, Iâm not sure it really gained traction in the Pharo world. My use case is quite simple as the markdown files are simple configuration (and maybe donât even need a parser - e.g. https://github.com/servirtium/demo-java-climate-tck/blob/master/src/test/moc... <https://github.com/servirtium/demo-java-climate-tck/blob/master/src/test/moc...>). I was hoping there might be something simple I could run with to help explore how best to use the config in those files. Lets see if anyone else mentions something thatâs a no-brainer. Tim
On 24 Mar 2020, at 18:40, gettimothy via Pharo-users <pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org>> wrote:
From: gettimothy <gettimothy@zoho.com <mailto:gettimothy@zoho.com>> Subject: Re: [Pharo-users] Do we have a simple markdown parser? Date: 24 March 2020 at 18:40:42 GMT To: "Any question about pharo is welcome" <pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org>> Cc: "Pharo Users Newsgroup" <pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org>>
I do not know if it works on Pharo, but XTreams has a XTreams-Parsing section that I am currently working with. The existing Wikitext grammar was my starting point .
https://github.com/squeak-smalltalk/squeak-ci/blob/master/package-load-scrip... <https://github.com/squeak-smalltalk/squeak-ci/blob/master/package-load-scrip...>
the existing Grammar is under:
XTreams-Parsing -> PEGParser > grammars->grammarWiki
Use case is:
| wikiGrammar wikiParser output| Transcript clear. wikiGrammar := PEGParser grammarWiki reading positioning. wikiParser := PEGParser parserPEG parse: 'Grammar' stream: wikiGrammar actor: PEGParserParser new. input := (your string input goes here) output := wikiParser parse: 'Page' stream: input actor: PEGWikiGenerator new. output inspect.
hth
---- On Tue, 24 Mar 2020 13:51:31 -0400 Tim Mackinnon <tim@testit.works <mailto:tim@testit.works>> wrote ----
Hi guys - do we have a simple markdown parser that is reasonably up to date? I did a quick GitHub scan and a few popped out, but I wasnât convinced I had found one the âeveryoneâ uses (albeit, everyone might be a small sample).
Ideally I donât want to get sucked into writing another one (a project for a future time).
Tim
I have a github-markdown which translates into pillar - and from pillar you can get many things. It is lacking several aspects, as I personally was most interested in rendering it inside pharo. The major thing missing (because I could not figure out how to render them) is tables. But take a look at: https://github.com/kasperosterbye/PillarRichTextRender But perhaps it is better than nothing - your usage scenario is not quite clear to me. Best, Kasper On Tue, Mar 24, 2020 at 10:12 PM Tim Mackinnon <tim@testit.works> wrote:
Hmm I hadnât even thought of Xstreams⦠I always thought it sounded cool, perhaps its a place to start - but as you mention, Iâm not sure it really gained traction in the Pharo world. My use case is quite simple as the markdown files are simple configuration (and maybe donât even need a parser - e.g. https://github.com/servirtium/demo-java-climate-tck/blob/master/src/test/moc...). I was hoping there might be something simple I could run with to help explore how best to use the config in those files.
Lets see if anyone else mentions something thatâs a no-brainer.
Tim
On 24 Mar 2020, at 18:40, gettimothy via Pharo-users < pharo-users@lists.pharo.org> wrote:
*From: *gettimothy <gettimothy@zoho.com> *Subject: **Re: [Pharo-users] Do we have a simple markdown parser?* *Date: *24 March 2020 at 18:40:42 GMT *To: *"Any question about pharo is welcome" <pharo-users@lists.pharo.org> *Cc: *"Pharo Users Newsgroup" <pharo-users@lists.pharo.org>
I do not know if it works on Pharo, but XTreams has a XTreams-Parsing section that I am currently working with. The existing Wikitext grammar was my starting point .
https://github.com/squeak-smalltalk/squeak-ci/blob/master/package-load-scrip...
the existing Grammar is under:
XTreams-Parsing -> PEGParser > grammars->grammarWiki
Use case is:
| wikiGrammar wikiParser output| Transcript clear. wikiGrammar := PEGParser grammarWiki reading positioning. wikiParser := PEGParser parserPEG parse: 'Grammar' stream: wikiGrammar actor: PEGParserParser new. input := (your string input goes here) output := wikiParser parse: 'Page' stream: input actor: PEGWikiGenerator new. output inspect.
hth
---- On Tue, 24 Mar 2020 13:51:31 -0400 *Tim Mackinnon <tim@testit.works <tim@testit.works>>* wrote ----
Hi guys - do we have a simple markdown parser that is reasonably up to date? I did a quick GitHub scan and a few popped out, but I wasnât convinced I had found one the âeveryoneâ uses (albeit, everyone might be a small sample).
Ideally I donât want to get sucked into writing another one (a project for a future time).
Tim
Kaspar - I canât get it to load in a P8 image - it seems to stall half way through (Iâve seen that a few times with Metacello to be honest - I think there is some escaping timeout that causes issues). Does it load for you?
On 24 Mar 2020, at 22:38, Kasper Osterbye <kasper.osterbye@gmail.com <mailto:kasper.osterbye@gmail.com>> wrote:
I have a github-markdown which translates into pillar - and from pillar you can get many things.
It is lacking several aspects, as I personally was most interested in rendering it inside pharo. The major thing missing (because I could not figure out how to render them) is tables. But take a look at: https://github.com/kasperosterbye/PillarRichTextRender <https://github.com/kasperosterbye/PillarRichTextRender>
But perhaps it is better than nothing - your usage scenario is not quite clear to me.
Best,
Kasper
On Tue, Mar 24, 2020 at 10:12 PM Tim Mackinnon <tim@testit.works <mailto:tim@testit.works>> wrote: Hmm I hadnât even thought of Xstreams⦠I always thought it sounded cool, perhaps its a place to start - but as you mention, Iâm not sure it really gained traction in the Pharo world. My use case is quite simple as the markdown files are simple configuration (and maybe donât even need a parser - e.g. https://github.com/servirtium/demo-java-climate-tck/blob/master/src/test/moc... <https://github.com/servirtium/demo-java-climate-tck/blob/master/src/test/moc...>). I was hoping there might be something simple I could run with to help explore how best to use the config in those files.
Lets see if anyone else mentions something thatâs a no-brainer.
Tim
On 24 Mar 2020, at 18:40, gettimothy via Pharo-users <pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org>> wrote:
From: gettimothy <gettimothy@zoho.com <mailto:gettimothy@zoho.com>> Subject: Re: [Pharo-users] Do we have a simple markdown parser? Date: 24 March 2020 at 18:40:42 GMT To: "Any question about pharo is welcome" <pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org>> Cc: "Pharo Users Newsgroup" <pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org>>
I do not know if it works on Pharo, but XTreams has a XTreams-Parsing section that I am currently working with. The existing Wikitext grammar was my starting point .
https://github.com/squeak-smalltalk/squeak-ci/blob/master/package-load-scrip... <https://github.com/squeak-smalltalk/squeak-ci/blob/master/package-load-scrip...>
the existing Grammar is under:
XTreams-Parsing -> PEGParser > grammars->grammarWiki
Use case is:
| wikiGrammar wikiParser output| Transcript clear. wikiGrammar := PEGParser grammarWiki reading positioning. wikiParser := PEGParser parserPEG parse: 'Grammar' stream: wikiGrammar actor: PEGParserParser new. input := (your string input goes here) output := wikiParser parse: 'Page' stream: input actor: PEGWikiGenerator new. output inspect.
hth
---- On Tue, 24 Mar 2020 13:51:31 -0400 Tim Mackinnon <tim@testit.works <mailto:tim@testit.works>> wrote ----
Hi guys - do we have a simple markdown parser that is reasonably up to date? I did a quick GitHub scan and a few popped out, but I wasnât convinced I had found one the âeveryoneâ uses (albeit, everyone might be a small sample).
Ideally I donât want to get sucked into writing another one (a project for a future time).
Tim
@Tim. I just verified that it load on a fresh P8. I am on a mac, but that should not make any difference. [image: image.png] Best, Kasper
Hey thanks - I took another fresh image and this one seemed to work, so not sure what happened in the other image that causes that issue (Iâve seen it before with other projects too - something seems to cause a stall, and then things donât seem to work â¦). Anyway - thanks for putting it forward - I saw it load PP2, so it seems like something in the write direction for me (although my use case might be possible with a regex, but that is just so nasty). Tim
On 25 Mar 2020, at 17:03, Kasper Osterbye <kasper.osterbye@gmail.com> wrote:
@Tim. I just verified that it load on a fresh P8. I am on a mac, but that should not make any difference.
<image.png>
Best,
Kasper
I do not think the PP2 is used in the github parser actually. The github parser was just a addon to the rest of the stuff, and the pillar markdown parser used PP2. Anyways, if you have any questions, feel free to ask. Best, Kasper
Hey Kasper - it looks like your GHMParser does exactly what I need, in that it parses the markdown spec I am looking at. One question - GHMAbstractBlock has a children property - when would you expect that to be populated? E.g. if the markdown was # Header 1 Some text ## Header 2 More text ## Header 3 Other text Would you expect Header2 and 3 to be children of Header1? And equally the text blocks to be children of the respective headers? At the moment they are just represented as a flat list - which I can use, but I was curious of your thoughts on that children property with respect to headings. Digging a bit more, it seems that only Lists use children (maybe thatâs right, but I always viewed markdown a bit like a structure document and hence the idea of sections having children too). Iâll see how I get on, as this gives me a big leg up. If it does prove useful, might there be a possibility to either extract it into a separate project, or have a baseline group that just loads the parser? Tim
On 25 Mar 2020, at 19:46, Kasper Osterbye <kasper.osterbye@gmail.com> wrote:
I do not think the PP2 is used in the github parser actually. The github parser was just a addon to the rest of the stuff, and the pillar markdown parser used PP2.
Anyways, if you have any questions, feel free to ask.
Best,
Kasper
Hi Tim, I had the same need for a more structured access to a parsed document. I believe this class does something to like that https://raw.githubusercontent.com/kasperosterbye/PillarDocumentEditor/master... My parser and that of pillar produce what you call "flat" parses, so this thing creates a superstructure on top of the actual tree, and leaves the actual tree intact. It seems I even made a gtInspector for the thing. If you find it useful, I can try and move it to the PillarRichTextRender and make the baseline or separate project. Best, Kasper On Thu, Mar 26, 2020 at 5:12 PM Tim Mackinnon <tim@testit.works> wrote:
Hey Kasper - it looks like your GHMParser does exactly what I need, in that it parses the markdown spec I am looking at.
One question - GHMAbstractBlock has a children property - when would you expect that to be populated?
E.g. if the markdown was
# Header 1
Some text
## Header 2
More text
## Header 3
Other text
Would you expect Header2 and 3 to be children of Header1? And equally the text blocks to be children of the respective headers?
At the moment they are just represented as a flat list - which I can use, but I was curious of your thoughts on that children property with respect to headings. Digging a bit more, it seems that only Lists use children (maybe thatâs right, but I always viewed markdown a bit like a structure document and hence the idea of sections having children too).
Iâll see how I get on, as this gives me a big leg up. If it does prove useful, might there be a possibility to either extract it into a separate project, or have a baseline group that just loads the parser?
Tim
On 25 Mar 2020, at 19:46, Kasper Osterbye <kasper.osterbye@gmail.com> wrote:
I do not think the PP2 is used in the github parser actually. The github parser was just a addon to the rest of the stuff, and the pillar markdown parser used PP2.
Anyways, if you have any questions, feel free to ask.
Best,
Kasper
participants (2)
-
Kasper Osterbye -
Tim Mackinnon