Why I'm hesitating to switch to D
Adam Ruppe
destructionator at gmail.com
Thu Jun 30 07:31:26 PDT 2011
KennyTM~ wrote:
> Right. I agree this is one disadvantage in authoring the document.
> Although, in terms of readability, this is much better than
>
> $(TABLE
> $(TR
> $(TH Header)
> $(TH Header2)
Note that textual macros can do a *lot* better than this. If we
take advantage of recursive template expansion....
======
$ cat test73.d
/**
$(TABLE
$(HEADERS Something, Something Else, Something To End)
$(ROW This is it, So is this, And the third)
$(ROW This is it, So is this, And the third)
$(ROW This is it, So is this, And the third))
Macros:
TABLE=<table>$0</table>
TH=<th>$1</th>$(TH $+)
HEADERS=<tr>$(TH $1, $+)</tr>
TD=<td>$1</td>$(TD $+)
ROW=<tr>$(TD $1, $+)</tr>
*/
$ dmd -D test73.d
$ cat test73.html
<table> <tr><th>Something</th><th>Something Else</th><th>Something To
End</th></tr>
<tr><td> This is it</td><td>So is this</td><td>And the
third</td></tr>
<tr><td> This is it</td><td>So is this</td><td>And the
third</td></tr>
<tr><td> This is it</td><td>So is this</td><td>And the
third</td></tr></table>
=======
That's fairly readable in source and generates the html needed,
that looks pretty decent.
The default ddoc macros need more work than ddoc itself IMO.
More information about the Digitalmars-d
mailing list