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
(Coming Update: Nested Query Improvement)
m (added percentage sign)
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{revdate}}
+
{{revdate}}{{NavMacroDocs}}
 
{{main|Macro Guide}}
 
{{main|Macro Guide}}
  
[[HTML]] Entities can be useful in creating [[macros]], [[Building Character Sheets]], and [[Help:Contents|wiki editing]].
+
'''[[HTML]] Entities''' (a.k.a. ''HTML Escape Characters'') can be useful to escape HTML characters so they aren't processed prematurely. This is useful in creating [[macros]], [[Building Character Sheets]], and [[Help:Contents|wiki editing]].
  
 
<onlyinclude>
 
<onlyinclude>
When creating some complicated [[macros]], usually involving [[Macro Guide#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/Escape Characters 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 13: Line 13:
 
! Character || Replacement
 
! Character || Replacement
 
|-
 
|-
| <code>&#124;</code> (pipe) || <code>&amp;#124;</code>
+
| <code>&#124;</code> (pipe) || <code>&amp;#124;</code>, (<code>&amp;vert;</code>)
 
|-
 
|-
| <code>,</code>|| <code>&amp;#44;</code>
+
| <code>,</code>|| <code>&amp;#44;</code>, (<code>&amp;comma;</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>, (<code>&amp;equals;</code>)
 
|-
 
|-
| <code>_</code> || <code>&amp;#95;</code>
+
| <code>_</code> || <code>&amp;#95;</code>, (<code>&amp;lowbar;</code>)
 
|-
 
|-
| <code><nowiki>(</nowiki></code> || <code>&amp;#40;</code>
+
| <code><nowiki>(</nowiki></code> || <code>&amp;#40;</code>, (<code>&amp;lpar;</code>)
 
|-
 
|-
| <code><nowiki>)</nowiki></code> || <code>&amp;#41;</code>
+
| <code><nowiki>)</nowiki></code> || <code>&amp;#41;</code>, (<code>&amp;rpar;</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>, (<code>&amp;grave;</code>)
 +
|-
 +
| {{c|*}}(asterisk)|| <code>&amp;#42;</code>, (<code>&amp;ast;</code>)
 +
|-
 +
| {{c|!}} || <code>&amp;#33;</code>, (<code>&amp;excl;</code>)
 +
|-
 +
| {{c|"}}(doublequote)|| <code>&amp;#34;</code>, (<code>&amp;quot;</code>)
 +
|-
 +
| {{c|#}} || <code>&amp;#35;</code>, (<code>&amp;num;</code>)
 +
|-
 +
| {{c|-}}(hyphen) || <code>&amp;#45;</code>, (<code>&amp;dash;</code>)
 +
|-
 +
| {{c|@}} || <code>&amp;#64;</code>, (<code>&amp;commat;</code>)
 +
|-
 +
| {{c|%}} || <code>&amp;#37;</code>, (<code>&amp;percnt;</code>)
 
|}
 
|}
 
</onlyinclude>
 
</onlyinclude>
  
 
==Examples==
 
==Examples==
* [[Macro_Guide#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. This is essentially to prevent the Roll Query from closing at the first <code>}</code> it encounters.
By using HTML entities to replace all <code>}</code> inside "Choose a Roll", it will now correctly process where the query ends.  
+
<pre>?{Choose a Roll|
<pre style="overflow:auto;white-space:pre-wrap;">
+
?{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;) |
Line 57: Line 69:
 
</pre>
 
</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>
 +
 +
==Nested Query Improvement==
 +
An fix for macros to not needing to use HTML Entities for nested macros was tried in 2021{{source|https://app.roll20.net/forum/permalink/10260308/}}, but it was seemingly shelved at some point. There might be new try with this as part of Jumpgate updates. [[User:1223200|1223200]] ([[User talk:1223200|talk]]) 11:40, 28 September 2024 (UTC)
  
==Coming Update: Nested Query Improvement==
 
 
[https://app.roll20.net/forum/permalink/10260308/ Now on Dev Server: Roll Query Improvements!] July 20th, 2021
 
[https://app.roll20.net/forum/permalink/10260308/ 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 [[Dice Reference/Roll Query|Roll Query]] handling in macros.
+
Some, if not all, character substitutions might become redundant, when roll20 improves nested [[Dice Reference/Roll Query|Roll Query]] handling in macros.
  
 
:''Now on the [[Dev Server]]({{Pro}}-users) for testing, improved roll query parsing!''
 
:''Now on the [[Dev Server]]({{Pro}}-users) for testing, improved roll query parsing!''
Line 67: Line 85:
 
:''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.''
 
:''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.''
  
<br><br>
+
==Related==
 +
* [[Roll Queries & Nesting]]
 +
* [https://www.web2generators.com/html-based-tools/online-html-entities-encoder-and-decoder HTML Character Encoder/Decoder]
 +
* [https://www.urlencoder.org/ URL encoding]
 +
* [https://techstacker.com/how-to-escape-html/ How to Escape HTML Characters]
 +
 
 
[[Category:Macros]]
 
[[Category:Macros]]
 
[[Category:API]]
 
[[Category:API]]
 
[[Category:Character Sheet Creation]]
 
[[Category:Character Sheet Creation]]
[[Category:Wiki Administration]]
+
[[Category:Wiki Editing]]

Latest revision as of 17:36, 6 October 2024

Main Page: Macro Guide

HTML Entities (a.k.a. HTML Escape Characters) can be useful to escape HTML characters so they aren't processed prematurely. This is 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/Escape Characters that are commonly useful to escape when creating advanced Roll20 macros. See HTML Entities or special character for more:

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


[edit] 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}

[edit] Nested Query Improvement

An fix for macros to not needing to use HTML Entities for nested macros was tried in 2021, but it was seemingly shelved at some point. There might be new try with this as part of Jumpgate updates. Andreas J. (talk) 11:40, 28 September 2024 (UTC)

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

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.

[edit] Related