www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Is there a macro for code snippets introduced with "---"?

reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Trying to to this:

//////////////// file.dd
This will be highlighted:

---
int i;
---

This should also be but it isn't:

$(MYMACRO
int j;
)

Macros:
MYMACRO = Code begins
---
$0
---
Code ends
//////////////// file.dd ends

The expansion doesn't result in highlighted code. Is there a macro 
equivalent for "---"?


Thanks,

Andrei
Jul 03 2017
next sibling parent reply Vladimir Panteleev <thecybershadow.lists gmail.com> writes:
On Monday, 3 July 2017 at 23:17:02 UTC, Andrei Alexandrescu wrote:
 Is there a macro equivalent for "---"?
D_CODE ?
Jul 03 2017
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.com> writes:
On 7/3/17 7:19 PM, Vladimir Panteleev wrote:
 On Monday, 3 July 2017 at 23:17:02 UTC, Andrei Alexandrescu wrote:
 Is there a macro equivalent for "---"?
D_CODE ?
That renders the code in constant-width font, but it's not colorized. -- Andrei
Jul 03 2017
prev sibling parent reply =?UTF-8?Q?S=c3=b6nke_Ludwig?= <sludwig outerproduct.org> writes:
Am 04.07.2017 um 01:17 schrieb Andrei Alexandrescu:
 Trying to to this:
 
 //////////////// file.dd
 This will be highlighted:
 
 ---
 int i;
 ---
 
 This should also be but it isn't:
 
 $(MYMACRO
 int j;
 )
 
 Macros:
 MYMACRO = Code begins
 ---
 $0
 ---
 Code ends
 //////////////// file.dd ends
 
 The expansion doesn't result in highlighted code. Is there a macro 
 equivalent for "---"?
 
 
 Thanks,
 
 Andrei
The problem is that syntax highlighting of code blocks happens at an earlier stage according to the spec (see "Phases of Processing" at http://dlang.org/spec/ddoc.html). I just checked and I'm actually doing it the other way around in DDOX, without encountering different results so far, so it may be realistic to change this for Ddoc, too.
Jul 03 2017
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 07/04/2017 12:37 AM, Sönke Ludwig wrote:
 The problem is that syntax highlighting of code blocks happens at an 
 earlier stage according to the spec (see "Phases of Processing" at 
 http://dlang.org/spec/ddoc.html).
 
 I just checked and I'm actually doing it the other way around in DDOX, 
 without encountering different results so far, so it may be realistic to 
 change this for Ddoc, too.
Thanks. I think the best way to do it is to have the earlier stage transform all sugar (---, backticks, tags with colons, ...) to standard macros, and then make one pass that expands macros. That gives maximum control to the user and allows us to e.g. improve the sugar easily. -- Andrei
Jul 04 2017