Skip to content

Fix autolink rendering in djot-reader.lua - #22

Merged
jgm merged 1 commit into
jgm:mainfrom
karlb:fix/autolink-url-email-handlers
Apr 27, 2026
Merged

Fix autolink rendering in djot-reader.lua#22
jgm merged 1 commit into
jgm:mainfrom
karlb:fix/autolink-url-email-handlers

Conversation

@karlb

@karlb karlb commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

The pandoc reader had no handlers for url and email AST nodes emitted by the parser for autolinks (<https://example.com> / <foo@example.com>), so any document containing one aborted with "attempt to call a nil value".

Both nodes carry .destination and string-content children — the exact shape Renderer:link already consumes — so aliasing is sufficient. Closes #21.

I didn't see a natural place to fit a test for this. The following would work, but feels a bit weird:

diff --git a/Makefile b/Makefile
index 727ee79..f0aef94 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,11 @@ ci: testall install
        pandoc -t djot-writer.lua m.txt -o m.dj
        pandoc -f djot-reader.lua m.dj -o m.html
        rm m.dj m.html
+       printf 'See <https://example.com> and <foo@example.com>.\n' \
+         | pandoc -f djot-reader.lua -t html > autolinks.html
+       grep -q 'href="https://example.com"' autolinks.html
+       grep -q 'href="mailto:foo@example.com"' autolinks.html
+       rm autolinks.html
 .PHONY: ci
 
 fuzz:

The pandoc reader had no handlers for `url` and `email` AST nodes
emitted by the parser for autolinks (`<https://example.com>` /
`<foo@example.com>`), so any document containing one aborted with
"attempt to call a nil value".

Both nodes carry `.destination` and string-content children — the
exact shape `Renderer:link` already consumes — so aliasing is
sufficient. Closes jgm#21.
@karlb

karlb commented Apr 27, 2026

Copy link
Copy Markdown
Contributor Author

The CI failures seem to be unrelated to this PR. I pushed #23 to fix the CI. That's LLM generated, but looks fine to me.

@jgm
jgm merged commit cbd3485 into jgm:main Apr 27, 2026
5 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

djot-reader.lua crashes on autolinks

2 participants