www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Ddoc embedded D source

Just a couple of things I've learned the hard way that others might find
useful.

Firstly, the document processor color codes everything it sees as 'embedded
D source'. I didn't want this so I have a macro called 'CODE' defined to do
my formatting. 

However, I tripped over this usage ...


 $(CODE
 -------
 Line one
 -------
 Line two
 -------
 )

I was trying to format this text using my style sheet, however I got this
output ...

 $(CODE
 <pre class="d_code">Line one
 </pre>
 
 Line two
 <pre class="d_code"></pre>

It took me awhile to realize that DDoc sees everything *inside* pairs of
dashed lines as embedded code and thus applies its own DDOC_CODE macro. I
have three dashed lines here so the last one is not paired. Thus DDoc saw
it as equivalent to ...

 $(CODE
 $(DDOC_CODE
 Line one
 )
 Line two
 $(DDOC_CODE
 )

Making my CODE macro have a missing final parenthesis. My work around for
this was to create a DASHES macro so now I have ...

 $(CODE
 $(DASHES)
 Line one
 $(DASHES)
 Line two
 $(DASHES)
 )

which gives me 

 <pre class="code">----------
 Line one
 ----------
 Line two
 ----------
 </pre>

and that's fine now.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
4/10/2005 4:25:00 PM
Oct 03 2005