Existing Formats
Scriba
Scriba is a markup format with a syntax similar to that of Scribe, the late-seventies markup language.
@title(My Document)
@begin(section)
@title(Lists)
This is a list with two items:
@begin(list)
@item(As promised)
@item(Just two)
@end(list)
And this is an enumerated list:
@begin(enum)
@item(This is the first item)
@item(And this the second)
@end(enum)
The real numbers have these properties, among others:
@begin(deflist)
@term(Associative Law for Addition)
@def($(x + y) + z = x + (y + z)$)
@term(Commutative Law for Addition)
@def($x + y = y + x$)
@end(deflist)
@end(section)
Emacs Mode
The Scriba repository contains a file, scriba.el
, which implements an Emacs
mode for .scr
files. The following commands are defined:
Tab
- Insert an at sign.
C-c C-c b
- Prompts for a tag name and inserts the begin/end block with that name.
C-c C-c s
- Prompts for a title and inserts the section block.
C-c C-s b
- Inserts bold markup around the selection.
C-c C-s i
- Inserts italic markup around the selection.
C-c C-s u
- Inserts underline markup around the selection.
C-c C-s s
- Inserts strikethrough markup around the selection.
C-c C-s c
- Inserts code markup around the selection.
C-c C-s ^
- Inserts superscript markup around the selection.
C-c C-s v
- Inserts subscript markup around the selection.
VerTeX
VerTeX is a markup format with a TeX like syntax.
An example of VerTeX syntax is:
\title{My Document}
\section{
\title{Lists}
This is a list with two items:
\list{
\item{As promised}
\item{Just two)
}
And this is an enumerated list:
\enum{
\item{This is the first item}
\item{And this the second}
}
The real numbers have these properties, among others:
\deflist{
\term{Associative Law for Addition}
\def{$(x + y) + z = x + (y + z)$}
\term{Commutative Law for Addition}
\def{$x + y = y + x$}
}
}
One disadvantage of using VerTeX comes when writing documents with TeX (to be
rendered, say, by MathJax in the HTML
backend). Because TeX mathematics has operators which would be parsed as VerTeX
syntax (e.g. \int
, \sigma
), you either need to escape the slashes or use
the \verb
tag to enter verbatim text. For example:
The speed of light is $@verb(\frac{1}{\sqrt{\mu_0 \epsilon_0}})$.
The derivative of $\\log(x)$ is $\\frac{1}{x}$.
As such, documents using TeX extensively should consider Scriba.
The parser uses the
plump-tex
library.
Defining Formats
To define a new format, you simply subclass document-format
and define the
necessary mehods.
API
document-format
parse-document
(document-format input)
emit-document
(document-format document stream)
Examples
Here's how the VerTeX format is defined:
(defclass vertex (document-format)
()
(:documentation "The VerTeX format."))
(defmethod parse-document ((vertex vertex)
(string string))
"Return a VerTeX document parsed from a string."
(vertex.parser:parse-string string))
(defmethod parse-document ((vertex vertex)
(pathname pathname))
"Return a VerTeX document parsed from a file."
(vertex.parser:parse-file pathname))
(defmethod emit-document ((vertex vertex)
(node common-doc:document-node)
stream)
(vertex.emitter:emit-to-stream node stream))
(defmethod emit-document ((vertex vertex)
(doc common-doc:document)
stream)
(vertex.emitter:emit-to-stream doc stream))