Closed sswatson closed 6 years ago
Well that's weird. I'm surprised no one (including me) has ever noticed this. I'll try to fix this soon.
The markdown library parser is handling these correctly, and producing x-expressions like (pre ((class "brush: python")) (code () "sum(range(100))")))
.
The problem is Frog's syntax-highlight
function. It is looking for these only as top-level x-expressions (i.e. what will become direct children of the <body>
element).
Instead it needs to walk the whole x-expression tree to look for these, and hand off to pygments.
In theory this is a quick fix. But I like to slow down and try to think of what else I might be forgetting, add regression tests, etc. So it may take me a day or two to push a commit and bump Frog on the package server.
I think I once had the same problem and thought it was just me being stupid not realizing this earlier. At that time I read about "* functions" in "The Little Schemer" and it came to me that I needed to use such a thing.
Two links to the code I use:
You probably already solved it, but maybe it'll somehow still be helpful. @greghendershott Btw.: Did you see https://github.com/greghendershott/markdown/issues/72 ? I still did not get around to really understand how parser combinators work, otherwise I might be able to add something there : /
@ZelphirKaltstahl Thanks. In terms of my existing code, I think it's a fairly straightforward change: commit 51730d0 -- (a) nest in a named let
and (b) add a match
clause to recursively walk child elements.
@ZelphirKaltstahl As for https://github.com/greghendershott/markdown/issues/72:
In the context of Frog: My personal opinion is that if I need a table, I'd rather not write it in HTML or markdown. Instead I'd say, "this blog post would be a good one to write in Scribble format so I can write some Racket code to make the table."
In the context of the markdown library as its own thing: It's a valid feature request. I guess I'm just reluctant to expand the scope. Writing a markdown parser turned out to be waaaaay more work than I imagined. These days I'm just happy there are no glaring bugs or performance issues. I'd rather not "poke the jello". But. That's probably OT here. I'll copy this text to that issue and if you want to discuss more let's do it there?
@sswatson OK I merged this to master
and nudged the Racket package server to rescan; it has. You can update Frog to get this. Thank you for reporting this!
Fenced code which is indented so as to be associated with a list item does not seem to get syntax highlighting.