So, for example, I copy/paste the second paragraph, above, into a vi (editor) session.
Then I copy the URL to the post containing it.
Then, in the editor, in "command mode", I execute these keystrokes with the cursor on the line containing the text:
!!y1 https://miso.town/post?id=29
which transforms the text to the right sequence of text and tags to result in this when displayed to you:
Take creating a multi-line "quote" of some lines of<br>> content, with the option to associate a URL with it, doing<br>> so in a way that helps the Midnight Pub post rendering<br>> code path "do the right thing" (i.e. what I want it to<br>> do) with respect to keeping the text to no more than 60<br>> columns, while having line breaks that *don't* cause the<br>> aforementioned code path to essentially double line break<br>> the lines by wrapping then all in html paragraph tags....<br>><br>> - https://miso.town/post?id=29
Fun!
("y1" is the name of the script... the '!!' tells vi to run the script against selected standard input, replacing it with the standard output of the command)
WOOOW! This looks absolutely amazing! I love how it's simple to read with the columns being cut when too long, and how the link to the post stands out to see more. All of that done in vi with bash + lua? Darn. If you ever feel like, I'd love to see the script so I could use it as well. Cheers sir, you made my day!
This is to see of code/pre tags work in Midnight Pub posts.
So here are the two pieces of code whose high-level description (when combined) transforms text into Mignight Pub friendly text/tags (huh... but I see I used two Lua scripts - not one Lua and one bash as first reported);
The "y1" script:
<pre><code>#! /usr/bin/env lua<br>local lines = {}<br>for line in io.stdin:lines() do<br>table.insert(lines, line)<br>end<br>local url = ''<br>if arg[1] then<br>url = ' ' .. arg[1]<br>end<br>local handle = io.popen('fmt -60 | quote-br' .. url, 'w')<br>handle:write(table.concat(lines, ' '))<br>handle:close()<br>local num_url_spaces = 30<br>if arg[1] then<br>io.stdout:write('><br>>')<br>for i=1,num_url_spaces do<br>io.stdout:write(' ')<br>end<br>print('- ' .. arg[1])<br>end<br></code></pre>
The "quote-br" script called by the "y1" script:
<pre><code>#! /usr/bin/env lua<br>local lines = {}<br>for line in io.stdin:lines() do<br>table.insert(lines, '> ' .. line .. '<br>')<br>end<br>io.stdout:write(table.concat(lines, ''))<br></code></pre>