Skip to content
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

Expose code and code blocks' literals via string_content/=. #290

Merged
merged 3 commits into from
May 4, 2024

Conversation

kivikakk
Copy link
Collaborator

@kivikakk kivikakk commented May 4, 2024

Hiya! What do you think of this? Currently the literal members of Code and CodeBlock nodes isn't exposed anywhere.

The discrepancy between these and text()-fetchable things is a bit unfortunate on the Comrak side, but it's a side-effect of its legacy (i.e. the implication that text() means "get me the content of a Text node, and fail if it isn't one") — I see no reason to do the same to string_content just because of what it's backed by currently.

Fixes #289.

@kivikakk kivikakk requested a review from gjtorikian May 4, 2024 14:05
@gjtorikian
Copy link
Owner

Thank you!

@gjtorikian gjtorikian enabled auto-merge May 4, 2024 19:28
@gjtorikian gjtorikian merged commit 7a1a157 into main May 4, 2024
14 checks passed
@gjtorikian gjtorikian deleted the code-string-content branch May 4, 2024 19:31
@rossta
Copy link
Contributor

rossta commented May 4, 2024

Thank you @kivikakk and @gjtorikian!

rossta added a commit to joyofrails/joyofrails.com that referenced this pull request May 4, 2024
Replaces markly with commonmarker

Markly is a key piece in the original implementation of the ERB-enhanced
markdown rendering in Joy of Rails—adapted from phlex-markdown and built
on phlex-ruby.

* https://github.com/ioquatix/markly
* https://github.com/joeldrapper/phlex-markdown

According to the markly README, it was originally created as a fork of
commonmarker to get access to the parsed markdown Abstract Syntax Tree
(AST). The fork is from before commonmarker switched from being a
wrapper of cmark-gfm (implemented in C, gfm = GitHub-flavored markdown)
to comrak (Rust port of cmark-gfm), also maintained by awesome
maintainers.

* https://github.com/github/cmark-gfm
* https://github.com/kivikakk/comrak

It's been nearly a year since markly was released. Just a few days ago,
commonmarker introduced access to its AST meaning it supplies the key
feature set to make it compatible for markdown rendering enhancements in
Joy of rails.

I checked it out this morning and reported an issue with code fence
parsing early today that has already been fixed as of this afternoon—a
Saturday no less—in commonmarker v1.1.2.

* Issue:   gjtorikian/commonmarker#289
* Fix:     gjtorikian/commonmarker#290
* Release: https://github.com/gjtorikian/commonmarker/releases/tag/v1.1.2

Performance benchmarks are reported on commonmarker's README. According
to these benchmarks, commonmarker outperforms Kramdown by over 25x.
markly outperforms commonmarker by roughly 3x.

* https://github.com/gjtorikian/commonmarker?tab=readme-ov-file#benchmarks

That said, this changeset provides the minimum changes to switch from
markly to commonmarker for markdown parsing.

Why change? The energy in the commonmarker and comrak projects is
encouraging. I also belive in markly's maintainer, who is awesome, and a
terrific advocate for improvements in the Ruby ecosystem. My choice to
switch is more about my perception of the momentum of the respective
projects. I have no issues with reconsidering this decision at a later
time assuming switching back is comparably straightforward.
rossta added a commit to joyofrails/joyofrails.com that referenced this pull request May 4, 2024
Replaces markly with commonmarker

Markly is a key piece in the original implementation of the ERB-enhanced
markdown rendering in Joy of Rails—adapted from phlex-markdown and built
on phlex-ruby.

* https://github.com/ioquatix/markly
* https://github.com/joeldrapper/phlex-markdown

According to the markly README, it was originally created as a fork of
commonmarker to get access to the parsed markdown Abstract Syntax Tree
(AST). The fork is from before commonmarker switched from being a
wrapper of cmark-gfm (implemented in C, gfm = GitHub-flavored markdown)
to comrak (Rust port of cmark-gfm), also maintained by awesome
maintainers.

* https://github.com/github/cmark-gfm
* https://github.com/kivikakk/comrak

It's been nearly a year since markly was released. Just a few days ago,
commonmarker introduced access to its AST meaning it supplies the key
feature set to make it compatible for markdown rendering enhancements in
Joy of rails.

I checked it out this morning and reported an issue with code fence
parsing early today that has already been fixed as of this afternoon—a
Saturday no less—in commonmarker v1.1.2.

* Issue:   gjtorikian/commonmarker#289
* Fix:     gjtorikian/commonmarker#290
* Release: https://github.com/gjtorikian/commonmarker/releases/tag/v1.1.2

Performance benchmarks are reported on commonmarker's README. According
to these benchmarks, commonmarker outperforms Kramdown by over 25x.
markly outperforms commonmarker by roughly 3x.

* https://github.com/gjtorikian/commonmarker?tab=readme-ov-file#benchmarks

That said, this changeset provides the minimum changes to switch from
markly to commonmarker for markdown parsing.

Why change? The libs have similar functionality with regards to what Joy
of Rails needs at this time. It feels like with commonmarker it is a little
easier for me to figure out how to customize the configuration options.
Markly's performance outshines commonmarker but not so much for me to
say the tradeoff is painful. The energy in the commonmarker and comrak
projects is encouraging. I also believe in markly's maintainer, who is
awesome, and a terrific advocate for improvements in the Ruby ecosystem.

Ultimately, my choice to switch is more about my perception of the
momentum of the respective projects. I have no issues with reconsidering
this decision at a later time assuming switching back is comparably
straightforward.
rossta added a commit to joyofrails/joyofrails.com that referenced this pull request May 5, 2024
Replaces markly with commonmarker

Markly is a key piece in the original implementation of the ERB-enhanced
markdown rendering in Joy of Rails—adapted from phlex-markdown and built
on phlex-ruby.

* https://github.com/ioquatix/markly
* https://github.com/joeldrapper/phlex-markdown

According to the markly README, it was originally created as a fork of
commonmarker to get access to the parsed markdown Abstract Syntax Tree
(AST). The fork is from before commonmarker switched from being a
wrapper of cmark-gfm (implemented in C, gfm = GitHub-flavored markdown)
to comrak (Rust port of cmark-gfm), also maintained by awesome
maintainers.

* https://github.com/github/cmark-gfm
* https://github.com/kivikakk/comrak

It's been nearly a year since markly was released. Just a few days ago,
commonmarker introduced access to its AST meaning it supplies the key
feature set to make it compatible for markdown rendering enhancements in
Joy of rails.

I checked it out this morning and reported an issue with code fence
parsing early today that has already been fixed as of this afternoon—a
Saturday no less—in commonmarker v1.1.2.

* Issue:   gjtorikian/commonmarker#289
* Fix:     gjtorikian/commonmarker#290
* Release: https://github.com/gjtorikian/commonmarker/releases/tag/v1.1.2

Performance benchmarks are reported on commonmarker's README. According
to these benchmarks, commonmarker outperforms Kramdown by over 25x.
markly outperforms commonmarker by roughly 3x.

* https://github.com/gjtorikian/commonmarker?tab=readme-ov-file#benchmarks

That said, this changeset provides the minimum changes to switch from
markly to commonmarker for markdown parsing.

Why change? The libs have similar functionality with regards to what Joy
of Rails needs at this time. It feels like with commonmarker it is a little
easier for me to figure out how to customize the configuration options.
Markly's performance outshines commonmarker but not so much for me to
say the tradeoff is painful. The energy in the commonmarker and comrak
projects is encouraging. I also believe in markly's maintainer, who is
awesome, and a terrific advocate for improvements in the Ruby ecosystem.

Ultimately, my choice to switch is more about my perception of the
momentum of the respective projects. I have no issues with reconsidering
this decision at a later time assuming switching back is comparably
straightforward.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parse tree missing text for code and code blocks
3 participants