chipsenkbeil / vimwiki-rs

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

"failed to write cache: key must be a string" on comments containing "::" #122

Closed brennen closed 3 years ago

brennen commented 3 years ago

I've got comments of the following form in a diary entry from some years back:

%% mark :: 2017-01-04T15:27:39-0700

I think I was messing around with timestamping stuff in my worklog for the day or something. Anyway, this causes a "failed to write cache: key must be a string" error, and unexpectedly renders the comment as a definition list (also with the tag rendering from #120).

Input:

== comments ==

%% this is a comment

%% this is a comment with embedded:colons:in

%% mark :: 2017-01-04T15:27:39-0700

Output:

<div id="comments"><h2 id="comments" class="header"><a href="#comments">comments</a></h2></div>
<p></p>
<p></p>
<dl>
<dt></dt>
<dd>2017-01-04T15<span id="comments-27"></span><span class="tag" id="27">27</span>39-0700</dd>
</dl>
brennen commented 3 years ago

Additionally, noting explicitly that it feels a little weird that comments render as empty paragraphs:

Input:

== comments ==

%% this is a comment

%% another comment

Output:

<div id="comments"><h2 id="comments" class="header"><a href="#comments">comments</a></h2></div>
<p></p>
<p></p>

Or I guess maybe the blank lines between the comments render as empty paras?

== comments ==
%% this is a comment
%% another comment

Gives:

<div id="comments"><h2 id="comments" class="header"><a href="#comments">comments</a></h2></div>
<p> </p>
chipsenkbeil commented 3 years ago

I should revise html output of empty paragraphs to be nothing.

Separately, comments are supposed to be the first thing processed when it comes to inline content. I'll have to write up some tests based on your examples and figure out what's up.

Thanks for these!

chipsenkbeil commented 3 years ago

I think https://github.com/chipsenkbeil/vimwiki-rs/commit/35498bf42be6a28c2f9d72680eda09a99f4e455a solves the "key must be a string" error. Those should never be a true problem, by the way, as it just prevents caching from happening but not the actual conversion to html.

As for the comment becoming a definition list, I think I'll need to revise the parser a little bit. Definition list has higher priority than paragraph and the term (what comes before ::) allows pretty much any character including %%; so, I think it's eating the comment.

chipsenkbeil commented 3 years ago

@brennen give https://github.com/chipsenkbeil/vimwiki-rs/commit/d339b69c13eadb63db60b62cd26db3a1d0c0dbeb a go to see if that fixes the issue.

brennen commented 3 years ago

No more error message and the comments aren't rendered as definition lists, looks good!