Skip to content

Instantly share code, notes, and snippets.

@jdutant
jdutant / fixSubLists.lua
Last active February 27, 2023 20:32
Fix badly formed HTML sublists with Pandoc
--[[ fixSubLists.lua Fix badly formed HTML sublists in Pandoc
Apple Notes (via AppleScript) produces badly formed HTML
for sublists:
<ul>
<li>Level 1 element 1</li>
<ul>
<li>Level 2 element 1</li>
<li>Level 2 element 2</li>
@jdutant
jdutant / labelled-lists.html
Created February 1, 2023 18:35
Replace list bullets with text from span/labels in HTML / CSS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Label list via CSS</title>
<style type="text/css">
body {
margin: 20px 100px;
border: 1px solid gray;
@jdutant
jdutant / urlEncode.lua
Created January 14, 2023 00:04
UTF-8-safe URL encoding and decoding in Lua
--- urlEncode: URL-encode a string.
-- @param str string
-- @param spaceToPlus bool (optional) convert spaces to `+`
local function urlEncode(str, spaceToPlus)
-- safe characters: 0-9a-zA-Z%-._~
-- as per RFC 3986, Section 2.3 <https://www.rfc-editor.org/rfc/rfc3986#section-2.3>
-- %w matches UTF-8 starting bytes but they should be encoded,
-- so we use the explicit charset 0-9a-zA-Z instead.
local charset = '0-9a-zA-Z%-._~'
if spaceToPlus then