chipsenkbeil / vimwiki-rs

Rust library and tooling to parse, render, and modify vimwiki text and files.
56 stars 2 forks source link

All strings with embeded `:[a-z0-9]:` treated as containing tags #120

Closed brennen closed 3 years ago

brennen commented 3 years ago

First noticed this with RFC 3339 timestamps, which I've got all over the place. Also happens with foo:bar:baz.

I think this behavior is strictly correct according to the docs:

A tag is a sequence of non-space characters between two colons: :tag-example:

...but the plugin actually only matches sets of tags that start and end with :, with whitespace on either side. Which seems correct - it'd be weird to have to escape timestamps, MAC addresses, ipv6 addresses, or other types of namespaced identifiers that embed colons.

Input:

== not tags ==

2021-05-30 12:35:03.913609534-07:00

2021-05-30 15:41:15-06:00

15:41:15

foo:bar:baz

Output:

<div id="not tags"><h2 id="not tags" class="header"><a href="#not tags">not tags</a></h2></div>
<p>2021-05-30 12<span id="not tags-35"></span><span class="tag" id="35">35</span><span id="not tags-03.913609534-07"></span><span class="tag" id="03.913609534-07">03.913609534-07</span>00</p>
<p>2021-05-30 15<span id="not tags-41"></span><span class="tag" id="41">41</span><span id="not tags-15-06"></span><span class="tag" id="15-06">15-06</span>00</p>
<p>15<span id="not tags-41"></span><span class="tag" id="41">41</span>15</p>
<p>foo<span id="not tags-bar"></span><span class="tag" id="bar">bar</span>baz</p>
chipsenkbeil commented 3 years ago

Good catch. Should be easy enough to update the parser for this one.

brennen commented 3 years ago

FWIW I think plugin behavior is defined in the neighborhood of autoload/vimwiki/vars.vim +532.

chipsenkbeil commented 3 years ago

@brennen check out https://github.com/chipsenkbeil/vimwiki-rs/commit/ffb7d249f91caa49bf7988a1511e52a5beaafa04 to see if that solves the unexpected parsing of tags.

brennen commented 3 years ago

Yep, looks fixed to me.