Codex
, CommonDoc
and Scriba
were built with extensibility in mind. Here is an example
I've published in the #poftheday post.
It adds a new type of node into the markup language:
POFTHEDAY> (common-doc:define-node twitter (common-doc:markup)
()
(:tag-name "twitter"))
POFTHEDAY> (common-html.emitter::define-emitter (node twitter)
(let* ((username (common-doc:text (first (common-doc:children node))))
(url (format nil "https://twitter/~A" username))
(name (format nil "@~A" username)))
(common-html.emitter::with-tag ("a" node :attributes `(("href" . ,url)))
(write-string name
common-html.emitter::*output-stream*))))
POFTHEDAY> (common-doc.format:parse-document *format* "Hello @ twitter(bob)!")
#<COMMON-DOC:DOCUMENT "">
POFTHEDAY> (pandocl:emit * "hello.html")
#<COMMON-DOC:DOCUMENT "">
POFTHEDAY> (alexandria:read-file-into-string "hello.html")
"<!DOCTYPE html>
<html>
<head><title></title></head>
<body>
Hello <a href=\"https://twitter/bob\">@bob</a>!
</body>
</html>"
- NOTE1
-
I've intentionally added a space between
character and
twitter
node name in the snippet abover, because there is a bug in the Scriba parser which does not allow to use unknown Scriba tags in the code snippets. - NOTE2
- I've intended to add a sad "smile" at the end of the previos note, but seems Scriba doesnt' understand jokes.