💾 Archived View for midnight.pub › posts › 1880 captured on 2024-06-16 at 12:33:58. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2024-05-26)
-=-=-=-=-=-=-
The midnight.pub manual (https://midnight.pub/manual) has a "Post using your terminal" section. The script mentioned worked fine for simple cases, but content containing bash special characters was problematic, so I set off to create what I believe to be a better version in Lua, which follows below. The key was discovering curl's syntax for inhaling content from a file into a form variable (-F "variable=<file"), thereby bypassing trying to cram it into a pair of quotes and struggling with how to escape special shell characters.
As always, it's likely not to the reader's standards regarding indentation, line spacing between sections, absence of comments, etc... but it's been working great for me of late, so hopefully it's useful to you too (NOTE: I substituted two space characters for each tab character, because I'm "set ts=2" in vim, but didn't want it looking like the humongous 8 characters per tab character in your browser...)... also, its "help" mentions an "mp-cookie" script shown farther below.
The "midnight" script:
#! /usr/bin/env lua local function escape(line) line = string.gsub(line, '%