Skip to content

Commit

Permalink
Merge pull request #257 from noraj/patch-1
Browse files Browse the repository at this point in the history
fix front_matter_delimiter type
  • Loading branch information
gjtorikian committed Oct 12, 2023
2 parents c1b112e + fb3b6b9 commit 692e5c1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ build/

# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .ruby-version
# .ruby-gemset
# as rbenv
.ruby-version
.ruby-gemset
# or ASDF-VM
.tool-versions

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc
Expand Down
6 changes: 5 additions & 1 deletion ext/commonmarker/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ fn iterate_extension_options(comrak_options: &mut ComrakOptions, options_hash: R
comrak_options.extension.description_lists = TryConvert::try_convert(value)?;
}
Ok(Cow::Borrowed(EXTENSION_FRONT_MATTER_DELIMITER)) => {
comrak_options.extension.front_matter_delimiter = try_convert_string(value);
if let Some(option) = try_convert_string(value) {
if !option.is_empty() {
comrak_options.extension.front_matter_delimiter = Some(option);
}
}
}
Ok(Cow::Borrowed(EXTENSION_SHORTCODES)) => {
comrak_options.extension.shortcodes = TryConvert::try_convert(value)?;
Expand Down
2 changes: 1 addition & 1 deletion lib/commonmarker/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module Config
header_ids: "",
footnotes: false,
description_lists: false,
front_matter_delimiter: nil,
front_matter_delimiter: "",
shortcodes: true,
},
format: [:html].freeze,
Expand Down
2 changes: 1 addition & 1 deletion lib/commonmarker/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Commonmarker
VERSION = "1.0.0.pre10"
VERSION = "1.0.0.pre11"
end
9 changes: 9 additions & 0 deletions test/frontmatter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,13 @@ def test_frontmatter_does_not_interfere_with_codeblock

assert_equal(expected, Commonmarker.to_html(md, plugins: nil))
end

def test_frontmatter_custom_delimiter
md = "---\nyaml: true\nage: 42\n---\n# Title 1"
expected = <<~HTML
<h1>Title 1</h1>
HTML

assert_equal(expected, Commonmarker.to_html(md, options: { extension: { front_matter_delimiter: "---" } }))
end
end

0 comments on commit 692e5c1

Please sign in to comment.