Character Vault
Any Concept / Any System
Compendium
Your System Come To Life
Roll20 for Android
Streamlined for your Tablet
Roll20 for iPad
Streamlined for your Tablet

Personal tools

Difference between revisions of "HTML Entities"

From Roll20 Wiki

Jump to: navigation, search
(Examples)
m (+NavMacroDocs)
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
{{revdate}}
+
{{revdate}}{{NavMacroDocs}}
 
{{main|Macro Guide}}
 
{{main|Macro Guide}}
  
Line 7: Line 7:
 
When creating some complicated [[macros]], usually involving [[Nesting|nesting]], you will need to use [https://www.w3schools.com/html/html_entities.asp HTML entities] in parts of the code to trick the Roll20 system to make it behave like you want, or some advanced tricks won't work.
 
When creating some complicated [[macros]], usually involving [[Nesting|nesting]], you will need to use [https://www.w3schools.com/html/html_entities.asp HTML entities] in parts of the code to trick the Roll20 system to make it behave like you want, or some advanced tricks won't work.
  
Here are some HTML Entities that are commonly useful to escape when creating advanced Roll20 macros. See [https://www.freeformatter.com/html-entities.html HTML Entities] for full list:
+
Here are some HTML Entities that are commonly useful to escape when creating advanced Roll20 macros. See [https://www.freeformatter.com/html-entities.html HTML Entities] or [https://www.html.am/reference/html-special-characters.cfm special character] for more:
 
<div style="float:right">{{notebox| '''<code>&#124;</code>''', '''<code>&#125;</code>''', and '''<code>,</code>''' are the most common character that need to be replaced in nested macros.}}</div>
 
<div style="float:right">{{notebox| '''<code>&#124;</code>''', '''<code>&#125;</code>''', and '''<code>,</code>''' are the most common character that need to be replaced in nested macros.}}</div>
 
::{| class="wikitable"
 
::{| class="wikitable"
Line 17: Line 17:
 
| <code>,</code>|| <code>&amp;#44;</code>
 
| <code>,</code>|| <code>&amp;#44;</code>
 
|-
 
|-
| <code>&#123;</code>|| <code>&amp;lbrace;</code>, <code>&amp;#123;</code>
+
| <code>&#123;</code>|| <code>&amp;#123;</code>, (<code>&amp;lbrace;</code>)
 
|-
 
|-
| <code>&#125;</code>|| <code>&amp;rbrace;</code>, <code>&amp;#125;</code>  
+
| <code>&#125;</code>|| <code>&amp;#125;</code>, (<code>&amp;rbrace;</code>)
 
|-
 
|-
| <code>&</code> || <code>&amp;amp;</code>, <code>&amp;#38;</code>   
+
| <code>&</code> || <code>&amp;#38;</code>, (<code>&amp;amp;</code>)  
 
|-
 
|-
| <code>space</code> || <code>&amp;nbsp;</code>, <code>&amp;#160;</code>
+
| <code>space</code> || <code>&amp;#160;</code>, (<code>&amp;nbsp;</code>)
 
|-
 
|-
 
| <code>=</code> || <code>&amp;#61;</code>
 
| <code>=</code> || <code>&amp;#61;</code>
Line 33: Line 33:
 
| <code><nowiki>)</nowiki></code> || <code>&amp;#41;</code>
 
| <code><nowiki>)</nowiki></code> || <code>&amp;#41;</code>
 
|-
 
|-
| <code><nowiki>[</nowiki></code>  || <code>&amp;lbrack;</code>, <code>&amp;#91;</code>
+
| <code><nowiki>[</nowiki></code>  || <code>&amp;#91;</code>, (<code>&amp;lbrack;</code>)
 
|-
 
|-
| <code><nowiki>]</nowiki></code>  || <code>&amp;rbrack;</code>, <code>&amp;#93;</code>
+
| <code><nowiki>]</nowiki></code>  || <code>&amp;#93;</code>, (<code>&amp;rbrack;</code>)
 
|-
 
|-
| <code><nowiki><</nowiki></code> || <code>&amp;lt;</code>, <code>&amp;#60;</code>
+
| <code><nowiki><</nowiki></code> || <code>&amp;#60;</code>, (<code>&amp;lt;</code>)
 
|-
 
|-
| <code><nowiki>></nowiki></code> || <code>&amp;gt;</code>, <code>&amp;#62;</code>  
+
| <code><nowiki>></nowiki></code> || <code>&amp;#62;</code>, (<code>&amp;gt;</code>)
 
|-
 
|-
 
| <code><nowiki>`</nowiki></code>(backtick, grave accent) || <code>&amp;#96;</code>  
 
| <code><nowiki>`</nowiki></code>(backtick, grave accent) || <code>&amp;#96;</code>  
 
|-
 
|-
 
| {{c|*}}(asterisk)|| <code>&amp;#42;</code>
 
| {{c|*}}(asterisk)|| <code>&amp;#42;</code>
 +
|-
 +
| {{c|!}} || <code>&amp;#33;</code>
 
|-
 
|-
 
| {{c|"}}(doublequote)|| <code>&amp;#34;</code>
 
| {{c|"}}(doublequote)|| <code>&amp;#34;</code>
 
|-
 
|-
| {{c|!}} || <code>&amp;#33;</code>
+
| {{c|#}} || <code>&amp;#35;</code>
 +
|-
 +
| {{c|-}}(hyphen) || <code>&amp;#45;</code>
 +
|-
 +
| {{c|@}} || <code>&amp;#64;</code>
 
|}
 
|}
 
</onlyinclude>
 
</onlyinclude>
Line 54: Line 60:
 
{{main|Roll Queries & Nesting}}  
 
{{main|Roll Queries & Nesting}}  
  
By using HTML entities to replace all <code>}</code> inside "Choose a Roll", it will now correctly process where the query ends.  
+
By using HTML entities to replace all <code>}</code> inside "Choose a Roll", it will now correctly process where the query ends. This is essentially to prevent the Roll Query from closing at the first <code>}</code> it encounters.
<pre style="overflow:auto;white-space:pre-wrap;">
+
<pre>?{Choose a Roll|
?{Choose a Roll|
+
 
   STR,/roll 1d20 + 3 + (?{Modifier&amp;#125;) |
 
   STR,/roll 1d20 + 3 + (?{Modifier&amp;#125;) |
 
   DEX,/roll 1d20 + 2 + (?{Modifier&amp;#125;) |
 
   DEX,/roll 1d20 + 2 + (?{Modifier&amp;#125;) |
 
   CON,/roll 1d20 + 1 + (?{Modifier&amp;#125;) }
 
   CON,/roll 1d20 + 1 + (?{Modifier&amp;#125;) }
 +
</pre>
 +
 +
If your query options contains <code>|</code>, you need to replace them to prevent the query thinking it's a delimiter between options.
 +
<pre>
 +
?{Pick a pair|Alice&#124;Bob|Bob&#124;Charlie}
 
</pre>
 
</pre>
  

Revision as of 06:10, 14 July 2022

Main Page: Macro Guide

HTML Entities can be useful in creating macros, Building Character Sheets, and wiki editing.


When creating some complicated macros, usually involving nesting, you will need to use HTML entities in parts of the code to trick the Roll20 system to make it behave like you want, or some advanced tricks won't work.

Here are some HTML Entities that are commonly useful to escape when creating advanced Roll20 macros. See HTML Entities or special character for more:

Character Replacement
| (pipe) &#124;
, &#44;
{ &#123;, (&lbrace;)
} &#125;, (&rbrace;)
& &#38;, (&amp;)
space &#160;, (&nbsp;)
= &#61;
_ &#95;
( &#40;
) &#41;
[ &#91;, (&lbrack;)
] &#93;, (&rbrack;)
< &#60;, (&lt;)
> &#62;, (&gt;)
`(backtick, grave accent) &#96;
*(asterisk) &#42;
! &#33;
"(doublequote) &#34;
# &#35;
-(hyphen) &#45;
@ &#64;


Examples

Main Page: Roll Queries & Nesting

By using HTML entities to replace all } inside "Choose a Roll", it will now correctly process where the query ends. This is essentially to prevent the Roll Query from closing at the first } it encounters.

?{Choose a Roll|
  STR,/roll 1d20 + 3 + (?{Modifier&#125;) |
  DEX,/roll 1d20 + 2 + (?{Modifier&#125;) |
  CON,/roll 1d20 + 1 + (?{Modifier&#125;) }

If your query options contains |, you need to replace them to prevent the query thinking it's a delimiter between options.

?{Pick a pair|Alice|Bob|Bob|Charlie}

Coming Update: Nested Query Improvement

Now on Dev Server: Roll Query Improvements! July 20th, 2021

In the near future, some, if not all, character substitutions might become redundant, when roll20 improves nested Roll Query handling in macros.

Now on the Dev Server(
Pro
info-users) for testing, improved roll query parsing!
Recently, an update to our character sheet code broke a workaround that some sheets were using to implement nested roll queries. Rather than fixing this workaround, we did a little extra work to properly support nested queries. Now, you should be able to nest roll queries inside of each other without needing to use any character codes.

Related