diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a31393e..e5fe7f60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ All notable changes to this project will be documented in this file. * [#126](https://github.com/mickael-menu/zk/issues/126) Embedded image links shown as not found. * [#152](https://github.com/mickael-menu/zk/issues/152) Incorrect timezone for natural dates. * [#170](https://github.com/mickael-menu/zk/issues/170) Broken wiki links in subdirectories. +* [#185](https://github.com/mickael-menu/zk/issues/185) Don't parse a Markdown table header as a colon tag. ## 0.9.0 diff --git a/internal/adapter/markdown/extensions/tag.go b/internal/adapter/markdown/extensions/tag.go index e2c2b6fc..92d96ed7 100644 --- a/internal/adapter/markdown/extensions/tag.go +++ b/internal/adapter/markdown/extensions/tag.go @@ -226,7 +226,7 @@ func (p *colontagParser) Parse(parent ast.Node, block text.Reader, pc parser.Con } else if char == ':' { tag = strings.TrimSpace(tag) - if len(tag) == 0 { + if !isValidTag(tag) { break } tags = append(tags, tag) @@ -260,3 +260,19 @@ func isValidTagChar(r rune, excluded rune) bool { r == '&' || r == '+' || r == '=' || r == ':' || r == '#') } + +func isValidTag(tag string) bool { + if len(tag) == 0 { + return false + } + + // Prevent Markdown table syntax to be parsed a a colon tag, e.g. |:---:| + // https://github.com/mickael-menu/zk/issues/185 + for _, c := range tag { + if c != '-' { + return true + } + } + + return false +} diff --git a/tests/issue-185.tesh b/tests/issue-185.tesh new file mode 100644 index 00000000..d43dbfec --- /dev/null +++ b/tests/issue-185.tesh @@ -0,0 +1,12 @@ +# Markdown table syntax is parsed as colon tags +# https://github.com/mickael-menu/zk/issues/185 + +$ cd blank + +$ echo "[format.markdown] colon-tags = true" > .zk/config.toml +$ echo "|:---:|" > test.md + +$ zk tag list +2> +2>Found 0 tag +