Aha! Even better. ...though, since replacements does bring along other substitutions, it's good to keep both approaches in the toolbox just in case.
-Dan On Wed, Nov 6, 2013 at 2:59 PM, Stuart Rackham <[email protected]> wrote: > > > On 07/11/13 09:44, Dan Allen wrote: > > One more trick building on what Stuart suggested. > > > > :replacements.U\+2603: ☃ > > > > [source,javascript] > > [presubs="none"] > > [postsubs="replacements"] > > ---- > > var str = 'U+2603'; > > ---- > > > > (I tried to use \u2603 but the source highlighter grabs the \u). > > Which got me thinking, and I realized that the built-in character entity > replacement works so long as you postsubs the replacements i.e. this > works for all character entities without the need to define any > replacements or attributes: > > [source,javascript] > [postsubs="replacements"] > ---- > var str = '🐄'; > ---- > > The ampersand *is* escaped in the filter but it works because the > built-in character entity replacement replaces escaped ampersands. > > Cheers, Stuart > > > > > -Dan > > > > > > > > On Wed, Nov 6, 2013 at 1:18 PM, Dan Allen <[email protected] > > <mailto:[email protected]>> wrote: > > > > > > > > > > On Wed, Nov 6, 2013 at 12:41 PM, Stuart Rackham <[email protected] > > <mailto:[email protected]>> wrote: > > > > On 07/11/13 00:24, Dan Allen wrote: > > > Hey Axel & Stuart, > > > > > > Another way is to enable the attributes subs on the listing > block. > > > > > > By default, a listing block has the subs specialcharacters and > > callouts. > > > You can modify this set as follows: > > > > > > [source,javascript] > > > [subs="specialcharacters,attributes,callouts"] > > > ---- > > > ... = '{cow}'; > > > ---- > > > > > > Another option is to enable macros and use a pass:[] macro to > > allow the > > > char reference to go through untouched. However, I've observed > > conflicts > > > between escaped placeholders and syntax highlighting. > > > > You need to use postsubs instead of subs to ensure it's done > > after the > > highlighter has executed (subs is an alias for presubs), > > > > > > Ah, right. > > > > > > > > but that still > > won't fix it because Attribute Entry values are substituted for > > special > > characters (see 'Attribute Entries' > > (http://asciidoc.org/userguide.html#X18)). > > > > Neither will putting pass:[🐄] in the listing because, > > again, the > > highlighter will escape the ampersand. > > > > The only way I can think of to ensure the ampersand is not > > escaped is to > > use a replacement e.g. > > > > :replacements.COW: 🐄 > > > > [source,javascript] > > [presubs="none"] > > [postsubs="replacements"] > > ---- > > var str = 'COW'; > > ---- > > > > > > There's another way very similar to this approach: > > > > :cow: pass:[] > > > > [source,javascript] > > [postsubs="attributes"] > > ---- > > var str = '{cow}'; > > ---- > > > > That's probably the safest way since it doesn't add global word > > replacements. > > > > (Attributes truly are life savers). > > > > -Dan > > > > -- > > Dan Allen | http://google.com/profiles/dan.j.allen > > > > > > > > > > -- > > Dan Allen | http://google.com/profiles/dan.j.allen > > > > -- > > You received this message because you are subscribed to the Google > > Groups "asciidoc" group. > > To unsubscribe from this group and stop receiving emails from it, send > > an email to [email protected]. > > To post to this group, send email to [email protected]. > > Visit this group at http://groups.google.com/group/asciidoc. > > For more options, visit https://groups.google.com/groups/opt_out. > > -- > You received this message because you are subscribed to the Google Groups > "asciidoc" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/asciidoc. > For more options, visit https://groups.google.com/groups/opt_out. > -- Dan Allen | http://google.com/profiles/dan.j.allen -- You received this message because you are subscribed to the Google Groups "asciidoc" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/asciidoc. For more options, visit https://groups.google.com/groups/opt_out.
