But if I configure the extension, the error tells me the option value should be NilClass while of course it should be a string containing the delimiter.
Which is also what comrak documentation says:
--front-matter-delimiter <DELIMITER>
Ignore front-matter that starts and ends with the given string
require 'commonmarker'
Commonmarker.to_html("---\nyaml: true\nage: 42\n---\n# Title 1", options: { extension: { front_matter_delimiter: '---' } } )
/home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/commonmarker-1.0.0.pre10-x86_64-linux/lib/commonmarker/utils.rb:18:in `fetch_kv': extension option `:front_matter_delimiter` must be NilClass; got String (TypeError)
raise TypeError, "#{type} option `:#{key}` must be #{expected_type}; got #{option[key].class}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from /home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/commonmarker-1.0.0.pre10-x86_64-linux/lib/commonmarker/config.rb:75:in `block (3 levels) in <module:Config>'
from /home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/commonmarker-1.0.0.pre10-x86_64-linux/lib/commonmarker/config.rb:66:in `each'
from /home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/commonmarker-1.0.0.pre10-x86_64-linux/lib/commonmarker/config.rb:66:in `each_with_object'
from /home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/commonmarker-1.0.0.pre10-x86_64-linux/lib/commonmarker/config.rb:66:in `block (2 levels) in <module:Config>'
from /home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/commonmarker-1.0.0.pre10-x86_64-linux/lib/commonmarker/config.rb:53:in `process_options'
from /home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/commonmarker-1.0.0.pre10-x86_64-linux/lib/commonmarker.rb:24:in `to_html'
from (irb):3:in `<main>'
from /home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11:in `<top (required)>'
from /home/noraj/.asdf/installs/ruby/3.2.2/bin/irb:25:in `load'
from /home/noraj/.asdf/installs/ruby/3.2.2/bin/irb:25:in `<main>'
If I provide a nil instead of the string delimiter, it obviously doesn't return the expected output but also surprisingly remove the titles anchors.
Let's consider the following markdown file with a YAML front-matter:
Of course without the front-matter extension commonmarker tries to parse the YAML front-matter as markdown:
But if I configure the extension, the error tells me the option value should be
NilClass
while of course it should be a string containing the delimiter.Which is also what comrak documentation says:
If I provide a nil instead of the string delimiter, it obviously doesn't return the expected output but also surprisingly remove the titles anchors.
This is a behavior using
1.0.0.pre10
version (with comrak).I can't test for v0.23.10, as there is no front-matter support for this version and parser.