chipsenkbeil / vimwiki-rs

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

Missing <pre> on some preformatted text blocks #118

Closed brennen closed 3 years ago

brennen commented 3 years ago

At 5443ff17.

As a summary: I've got some scripting to execute shell inline and pull in the results.

{{{exec-raw echo foo
foo
}}}

This is kind of edge case - the docs just specify stuff after the {{{ as "extra information", and in practice the vimscript implementation just drops it into the HTML after escaping entities, while the vim plugin itself treats it (or the last word in it?) as a filetype hint for syntax highlighting. That is: This might be my problem to fix; I'm overloading ill-defined behavior to suit a customization.

Still, I'd probably expect a <pre> tag here, maybe just one with <pre class="exec-raw echo foo"> or something based on how it behaves for a simpler case like {{{php?

Input:

This sets up an index used by [[file:~/.vimrc]]'s `dictionary` option:

{{{exec-raw cd ~/notes && make indices
sqlite3 metadata.db 'SELECT page FROM pages WHERE page NOT LIKE "log/%" AND page NOT LIKE "diary/%"' > vimwiki-index
pinboard tags | sort > pinboard-tag-index
sort vimwiki-index pinboard-tag-index | uniq > tag-index
wc -l tag-index
5230 tag-index
}}}

Check:

{{{exec-raw cd ~/notes && sqlite3 ~/notes/metadata.db 'select count(*) from pages; select count(*) from links;'
4515
19540
}}}

vimwiki-rs output:

<p>This sets up an index used by <a href="~/.vimrc.html">file:~/.vimrc</a>&#x27;s <code>dictionary</code> option:</p>
<p>{{{exec-raw cd ~/notes &amp;&amp; make indices pinboard tags | sort &gt; pinboard-tag-index sort vimwiki-index pinboard-tag-index | uniq &gt; tag-index wc -l tag-index 5040 tag-index }}}</p>
<p>Check:</p>
<p>{{{exec-raw cd ~/notes &amp;&amp; sqlite3 ~/notes/metadata.db &#x27;select count(<span id="scripts-) from pages; select count("></span><strong>) from pages; select count(</strong>) from links;&#x27; 3926 16531 }}}</p>

vimscript output:

<p>
This sets up an index used by <a href="/home/brennen/.vimrc">file:~/.vimrc</a>'s <code>dictionary</code> option:
</p>

<pre exec-raw cd ~/notes &amp;&amp; make indices>
pinboard tags | sort &gt; pinboard-tag-index
sort vimwiki-index pinboard-tag-index | uniq &gt; tag-index
wc -l tag-index
5040 tag-index
</pre>

<p>
Check:
</p>

<pre exec-raw cd ~/notes &amp;&amp; sqlite3 ~/notes/metadata.db 'select count(*) from pages; select count(*) from links;'>
3926
16531
</pre>
chipsenkbeil commented 3 years ago

I wasn't aware that this was a format acceptable for vimwiki code blocks. The reason it isn't outputting <pre> is because the parser doesn't recognize it as such.

Not that this would make much sense to you, but this is the parser for the start of a code block. It assumes {{{lang?( key="value")*.

brennen commented 3 years ago

I wasn't aware that this was a format acceptable for vimwiki code blocks. The reason it isn't outputting <pre> is because the parser doesn't recognize it as such.

That's probably reasonable. The behavior could probably stand to be better defined in the plugin and docs, but I'm essentially just wedging something into a corner case of the implementation. (It's possible a few others are doing something similar following my example, but it's never been an official thing.) I wouldn't worry about this one much; I can adjust accordingly.

Anyway, something like

{{{language exec="foo"
}}}

...wouldn't be quite as concise, but it has the advantage of being more explicit.

chipsenkbeil commented 3 years ago

@brennen you should be able to do it without a language as the language itself is optional.

{{{exec="foo"
}}}