Thread overview
Is there a macro for code snippets introduced with "---"?
Jul 03, 2017
Vladimir Panteleev
Jul 04, 2017
Sönke Ludwig
July 03, 2017
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
July 03, 2017
On Monday, 3 July 2017 at 23:17:02 UTC, Andrei Alexandrescu wrote:
> Is there a macro equivalent for "---"?

D_CODE ?
July 03, 2017
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
July 04, 2017
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.
July 04, 2017
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