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

Calling to_html to a node of paragraph causes an error #327

Open
wakairo opened this issue Dec 7, 2024 · 1 comment
Open

Calling to_html to a node of paragraph causes an error #327

wakairo opened this issue Dec 7, 2024 · 1 comment
Labels

Comments

@wakairo
Copy link

wakairo commented Dec 7, 2024

I tested the following code, and it seems that calling to_html to a node of paragraph causes an error.

Code

require 'commonmarker'

p RUBY_VERSION # => "3.2.3"
p Commonmarker::VERSION # => "2.0.1"

document = Commonmarker.parse("- a")
p document.first_child.type # => :list
p document.first_child.to_html # => "<ul>\n<li>a</li>\n</ul>\n"

document = Commonmarker.parse("ABC")
p document.first_child.type # => :paragraph
p document.first_child.to_html # An error occurs.

Output of the code

$ ruby step_to_reproduce.rb
"3.2.3"
"2.0.1"
:list
"<ul>\n<li>a</li>\n</ul>\n"
:paragraph
thread '<unnamed>' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/comrak-0.30.0/src/html.rs:683:44:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
/var/lib/gems/3.2.0/gems/commonmarker-2.0.1-x86_64-linux/lib/commonmarker/node.rb:47:in `node_to_html': called `Option::unwrap()` on a `None` value (fatal)
        from /var/lib/gems/3.2.0/gems/commonmarker-2.0.1-x86_64-linux/lib/commonmarker/node.rb:47:in `to_html'
        from step_to_reproduce.rb:12:in `<main>'
@gjtorikian
Copy link
Owner

Thanks for the report. I am ack'ing this, but I don't have time for a fix just yet!

@gjtorikian gjtorikian added the TODO label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants