-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Markdown Macro for CommonMark #14
Comments
Thanks for the kind words @jlewis91, much appreciated. As you've already linked elsewhere (fonsp/Pluto.jl#957) to the JuliaLang/julia issue regarding replacement of What would help towards that goal is for Regarding your actual feature request: for the basic case, the following would work: macro cm_str(str)
p = Parser()
return p(str)
end though you may want to |
Awesome, thanks for the reply. I can imagine there is a bit of a catch-22 situation here...libraries currently using Markdown implicitly rely upon the interpolation offered by the lib, so the absence of this feature limits drop-in adoption, though I very much get your point of view that the current setup should not be preserved in the context of a full refactor. Looking forward to seeing how this lib develops, feel free to tag me in any beginner level issues that may come up in this project, I'm eager for sensible ways to support core maintainers and participate more in the community. |
Yeah, pretty much that. We'll have to implement it prior to consideration for stdlib otherwise it doesn't have feature parity with
Not exactly a beginner level issue, but getting the interpolation syntax working is the only major outstanding thing. If you ever feel like looking into that one the best place to start is look at how the CommonMark.jl/src/extensions/math.jl Lines 53 to 103 in 1acfbef
|
Updated code for this feature (not particularly well tested): # Macro could also be named md2, or something else...
import Pkg; Pkg.add("CommonMark")
using CommonMark
parser = Parser()
enable!(parser, MathRule())
enable!(parser, TableRule())
macro cm_str(str)
return cm_md(str)
end
function cm_md(str_ex)
md = parser(IOBuffer(str_ex))
esc(md)
end
cm"""
# Test text
```math
1 + \epsilon
```
- list a
- list b
More text here
"""
Given the relative utility, I'll focus on the interpolation issue for now. |
Closed in #16. |
Very nice talk (https://www.youtube.com/watch?v=AeEmImQ46L8) @jeremiahpslewis. Couldn't agree more with the points you've raised in it, thanks for taking the time to talk about it. |
@MichaelHatherly Thank you for the kind words! And, especially, thank you for the great package and very friendly collaboration!! |
Thanks for this wonderful package...I'd been struggling with the stdlib markdown library for over a week until I found this today and it felt like suddenly the issues I couldn't find a way past in terms of incomplete tests and inconsistent parsing were all resolved at once.
One lovely feature of the existing markdown lib, however, is the
md"..."
string macro which prevents clunky syntax in notebooks likeparse(raw"``\epsilon + 1``")
. Do you know whether your library could easily accommodate its own string macro, something likemd2"..."
or even something that overrides themd
macro whenCommonMark
is loaded into the main environment?The text was updated successfully, but these errors were encountered: