On Sat, Jan 5, 2013 at 8:30 PM, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote:


You know, I always felt Ddoc was a strange sublanguage bolted onto D. An
elegant solution would be to have macros be D code, but I have nothing
to propose here.

I learned with time that ddoc's macro system is quite coherent and well designed.


Here is my first try for a LaTeX-generating list of Ddoc macros. I'm sure a LaTeX guru would find some of these quite dangerous :)
The final, global, appearance should be mostly defined in the DDOC macro.

I wonder how to have ddoc produce code highlighting that's compatible with LaTex. 

- Curly braces are a bit special in LaTex, hence using \texttt{} does not work well.
- But using \begin{verbatim} \end{verbatim} disable the coloring code produced by Ddoc.

For my own docs, I use pygmentize... Else I suppose the listings could also work.

I gather some hypothesis (namely, that the end output will be HTML) are a bit hardwired in Ddoc.

Anyway:

B=\textbf{$0}
I=\textit{$0}
U=\underline{$0}
P= $0

DL=\begin{description}
$0
\end{description}
DT=\item[$0]
DD=$0
TABLE=\begin{tabular}[2]{l|l}
$0
\end{tabular}
TR=$0 \\
TH=$0 &
TD=$0
OL=\begin{enumerate}
$0
\end{enumerate}
UL=\begin{itemize}
$0
\end{itemize}
LI=\item $0
BIG=\large{$0}
SMALL=\small{$0}
BR=\newline
LINK=\url{$0}
LINK2=\href{$1}{$+}
RED={\color{red}$0}
BLUE={\color{blue}$0}
GREEN={\color{green}$0}
YELLOW={\color{yellow}$0}
BLACK={\color{black}$0}
WHITE={\color{white}$0}
D_CODE=\begin{verbatim}
$0
\end{verbatim}
DDOC=\documentclass[11pt]{article}
\usepackage{color}

\usepackage{hyperref}
\begin{document}
\title{$(TITLE)}
\date{}
\maketitle

$(BODY)
\end{document}