Do we have a simple markdown parser?
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
Hi Tim, I was looking into this the other day (along with the potential native implementation) and remembered this was posted in Discord: https://github.com/PierceNg/Phoedown It uses an existing C based markdown parsing library via FFI. Evidently, it is quite difficult to make a Markdown parser because there can be a lot of ambiguity. Would be cool to have a full Smalltalk implementation though. On Tue, Mar 24, 2020 at 1:52 PM Tim Mackinnon <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
-- Eric
Thanks Eric - I did have a peek at Phoedown (as I did recall that announcement) but as my use case is for a generic library for testing (that I could potentially share with the wider community), I wasnât convince that needing a separate dependency would fly (for an own standalone project it did seem like a good bet and very comprehensive).
On 24 Mar 2020, at 17:56, Eric Gade <eric.gade@gmail.com> wrote:
Hi Tim,
I was looking into this the other day (along with the potential native implementation) and remembered this was posted in Discord: https://github.com/PierceNg/Phoedown <https://github.com/PierceNg/Phoedown>
It uses an existing C based markdown parsing library via FFI.
Evidently, it is quite difficult to make a Markdown parser because there can be a lot of ambiguity. Would be cool to have a full Smalltalk implementation though.
On Tue, Mar 24, 2020 at 1:52 PM Tim Mackinnon <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
-- Eric
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 <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
Much depends on what you mean by "Markdown". The current version of the CommonMark spec https://spec.commonmark.org/0.29/ comes to 124 printed pages. Mind you, some of that is background, some of it is advice about how to parse Markdown, and a lot of it is 500 examples. If I wanted to process Markdown in Smalltalk, I'd probably use the CommonMark reference implementation in C (cmark) to convert Markdown to XML and parse the XML. Alternatively, call libcmark through the foreign function interface. On Wed, 25 Mar 2020 at 06:52, Tim Mackinnon <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
On 2020-03-24 10:51 a.m., Tim Mackinnon wrote:
Hi guys - do we have a simple markdown parser that is reasonably up to date?
What's wrong with the real markdown itself? I've used the original Markdown.pl implementation for years same as I would any other shell script, via OSProcess markdown: someContent ^UnixProcess pipeString: someContent throughCommand: (FileDirectory default fullPathFor: 'Markdown.pl') -- Ramón León
Hi Ramón, I have a couple of questions. If you are using OSProcess in Pharo 8, how are you installing it and from what repository? If I add the Squeaksource version, I do not have the method that you are referencing. Additionally, it would be good to see an example of this in OSSubprocess. Using the latest Baseline installation instructions for it from Github, and from reading the instructions, I don't see a clear way to do this. The documentation claims that you can redirect the stdin to any file or readstream, but the new ZnStreams in P7/P8 DNU on #isOssPipe and StandardFileStream (for which OSSubprocess was designed, evidently) is being deprecated. If anyone reading has a good concise example of running a subprocess command with input from a stream (or string), that would be very useful. Thanks. On Thu, Mar 26, 2020 at 5:24 PM Ramon Leon <ramon.leon@allresnet.com> wrote:
On 2020-03-24 10:51 a.m., Tim Mackinnon wrote:
Hi guys - do we have a simple markdown parser that is reasonably up to date?
What's wrong with the real markdown itself? I've used the original Markdown.pl implementation for years same as I would any other shell script, via OSProcess
markdown: someContent ^UnixProcess pipeString: someContent throughCommand: (FileDirectory default fullPathFor: 'Markdown.pl')
-- Ramón León
-- Eric
On 2020-03-26 3:24 p.m., Eric Gade wrote:
Hi Ramón,
I have a couple of questions. If you are using OSProcess in Pharo 8
I'm not, I don't try and keep up with the latest stuff, too much churn. But I'd imagine the latest must still be able to pipe out to a command even if the API changed a bit.
but the new ZnStreams in P7/P8 DNU on #isOssPipe and StandardFileStream (for which OSSubprocess was designed, evidently) is being deprecated.
And this is why it's not worth riding the bleeding edge. Go back and find a stable older version you like and stick with it. Let others get all cut up playing with unstable new stuff. -- Ramón León
On Fri, Mar 27, 2020 at 08:35:47AM -0700, Ramon Leon wrote:
On 2020-03-26 3:24 p.m., Eric Gade wrote:
Hi Ram??n,
I have a couple of questions. If you are using OSProcess in Pharo 8
I'm not, I don't try and keep up with the latest stuff, too much churn. But I'd imagine the latest must still be able to pipe out to a command even if the API changed a bit.
For Pharo 7, you may want to use these: https://github.com/dtlewis290/OSProcess-Tonel https://github.com/dtlewis290/CommandShell-Tonel I have not tried Pharo 8, so I cannot say if it works there. Dave
but the new ZnStreams in P7/P8 DNU on #isOssPipe and StandardFileStream (for which OSSubprocess was designed, evidently) is being deprecated.
And this is why it's not worth riding the bleeding edge. Go back and find a stable older version you like and stick with it. Let others get all cut up playing with unstable new stuff.
-- Ram??n Le??n
participants (6)
-
David T. Lewis -
Eric Gade -
gettimothy -
Ramon Leon -
Richard O'Keefe -
Tim Mackinnon