From 63ae5264a9d1cbe2c9678472a8fd58d52af9d023 Mon Sep 17 00:00:00 2001 From: Alexandre ZANNI <16578570+noraj@users.noreply.github.com> Date: Tue, 3 Oct 2023 22:37:09 +0200 Subject: [PATCH 1/5] fix front_matter_delimiter type fix #256 --- lib/commonmarker/config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commonmarker/config.rb b/lib/commonmarker/config.rb index 80a07b56..f2c9f54e 100644 --- a/lib/commonmarker/config.rb +++ b/lib/commonmarker/config.rb @@ -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, From b549b379b1a7f5e89a4aafad4c47eab1389940ba Mon Sep 17 00:00:00 2001 From: noraj Date: Tue, 3 Oct 2023 23:10:24 +0200 Subject: [PATCH 2/5] add test --- test/frontmatter_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/frontmatter_test.rb b/test/frontmatter_test.rb index db37ecaa..c328f17f 100644 --- a/test/frontmatter_test.rb +++ b/test/frontmatter_test.rb @@ -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 +

Title 1

+ HTML + + assert_equal(expected, Commonmarker.to_html(md, options: { extension: { front_matter_delimiter: "---" } })) + end end From c070f1bf6b21150eaf4caacc2e6a5c990ad56e7d Mon Sep 17 00:00:00 2001 From: noraj Date: Tue, 3 Oct 2023 23:10:45 +0200 Subject: [PATCH 3/5] ignore virtual environment ruby files --- .gitignore | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f9a79ac7..f5aa8904 100644 --- a/.gitignore +++ b/.gitignore @@ -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 From 539b5c0bd12e02a104d82ca73ef9d39cfff17067 Mon Sep 17 00:00:00 2001 From: "Garen J. Torikian" Date: Thu, 12 Oct 2023 19:20:59 -0400 Subject: [PATCH 4/5] only set value if it exists --- ext/commonmarker/src/options.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ext/commonmarker/src/options.rs b/ext/commonmarker/src/options.rs index 2586f9cc..c42d6880 100644 --- a/ext/commonmarker/src/options.rs +++ b/ext/commonmarker/src/options.rs @@ -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)?; From fb3b6b9d8eb32649327fd060aeed7d119cb7f5b1 Mon Sep 17 00:00:00 2001 From: "Garen J. Torikian" Date: Thu, 12 Oct 2023 19:21:39 -0400 Subject: [PATCH 5/5] :gem: bump to 1.0.0.pre11 --- lib/commonmarker/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commonmarker/version.rb b/lib/commonmarker/version.rb index 45ac4236..9b1122b9 100644 --- a/lib/commonmarker/version.rb +++ b/lib/commonmarker/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Commonmarker - VERSION = "1.0.0.pre10" + VERSION = "1.0.0.pre11" end