Skip to content

Commit

Permalink
Fix unquoted languages in YAML front matter
Browse files Browse the repository at this point in the history
Fixes #156.
  • Loading branch information
valentjn committed Feb 12, 2023
1 parent 046d733 commit 55f37e4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<action type="fix" issue="#134">
Fix false positives when using siunitx (LaTeX)
</action>
<action type="fix" issue="#156">
Fix unquoted languages in YAML front matter not parsed correctly
</action>
<action type="fix" issue="#178" due-to="Stanley F (@sfo)">
Fix plural dummy in German languages
</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class MarkdownFragmentizer(codeLanguageId: String) : CodeFragmentizer(codeLangua

companion object {
private val YAML_FRONT_MATTER_REGEX = Regex(
"\\A---[ \t]*$.*?^lang:[ \t]+(?:\"(.+)\"|'(.+)'|(.+))$.*?^---[ \t]*$",
setOf(RegexOption.MULTILINE, RegexOption.DOT_MATCHES_ALL),
"\\A---[ \t]*$(?s).*?(?-s)^lang:[ \t]+(?:\"(.+)\"|'(.+)'|(.+))$(?s).*?(?-s)^---[ \t]*$",
RegexOption.MULTILINE,
)

private val COMMENT_REGEX = Regex(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class MarkdownFragmentizerTest {
"""
---
lang: 'de-DE'
abc: def
---
This is a test.
Expand All @@ -61,6 +62,7 @@ class MarkdownFragmentizerTest {
"""
---
lang: de-DE
abc: def
---
This is a test.
Expand Down

0 comments on commit 55f37e4

Please sign in to comment.