Difference between revisions of "Template:Code/doc"
From Roll20 Wiki
Andreas J. (Talk | contribs) m |
Andreas J. (Talk | contribs) m |
||
(4 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
{{documentation subpage|override=code/doc|Code}} | {{documentation subpage|override=code/doc|Code}} | ||
− | + | {{tlx|code}} is a shorthand to more easily write inline code and highlight variables on the wiki. {{tlx|c}} is an even smaller shorthand. For more complex content you'll still likely need to use <code><nowiki><code></nowiki></code>+<code><nowiki><nowiki></nowiki></code>-elements, as some special characters causes problem with the template that doesn't happen when using <code><nowiki><code></nowiki></code>+<code><nowiki><nowiki></nowiki></code>. | |
+ | There have been attempt to make the template more robust against this, but seems there is no simple way to put a template variable inside a nowiki element, as anything inside gets ignored. | ||
+ | |||
+ | See: [[Help:Contents#Displaying_Macros_and_Code|Displaying Macros and Code]] for details. | ||
'''Example 1.''' | '''Example 1.''' | ||
− | any words before {{code|/r 1d6+4}}, or words, {{ | + | any words before {{code|/r 1d6+4}}, or words, {{c|/roll 1d6+4}} |
− | <pre>any words before {{code|/r 1d6+4}}, or words, {{ | + | <pre>any words before {{code|/r 1d6+4}}, or words, {{c|/roll 1d6+4}}</pre> |
'''Example 2.''' | '''Example 2.''' | ||
− | You can even write code that include problematic elements that the wiki could mistake for wiki syntax, such as {{code|{{title=@{character_name}}}}} without the need of using nowiki element the code block. However, wiki links would still show up so nowiki is needed if inline rolls are present: {{code|<nowiki>Inline roll [[1d6+4]] would usually turn into a wiki link</nowiki> }} | + | You can even write code that include problematic elements that the wiki could mistake for wiki syntax, such as {{code|{{title=@{character_name} }}}} without the need of using nowiki element the code block. However, wiki links would still show up so nowiki is needed if inline rolls are present: {{code|<nowiki>Inline roll [[1d6+4]] would usually turn into a wiki link</nowiki> }} |
<pre data-language="bash" style="white-space: pre-wrap;"> | <pre data-language="bash" style="white-space: pre-wrap;"> | ||
− | You can even write code that include problematic elements that the wiki could mistake for wiki syntax, such as {{code|{{title=@{character_name}}}}} without the need of using nowiki element the code block. However, wiki links would still show up so nowiki is needed if inline rolls are present: {{code|<nowiki>Inline roll [[1d6+4]] would usually turn into a wiki link</nowiki> }}</pre> | + | You can even write code that include problematic elements that the wiki could mistake for wiki syntax, such as {{code|{{title=@{character_name} }}}} without the need of using nowiki element the code block. However, wiki links would still show up so nowiki is needed if inline rolls are present: {{code|<nowiki>Inline roll [[1d6+4]] would usually turn into a wiki link</nowiki> }}</pre> |
+ | |||
+ | '''Example 3.''' | ||
+ | |||
+ | Any text that contains |(pipe) or =(equal sign) need to be escaped with nowiki elements, making use of the template | ||
+ | |||
+ | {{code|<nowiki><input type="text" name="attr_class" value="fighter" ></nowiki>}} | ||
+ | <pre>{{code|<nowiki><input type="text" name="attr_class" value="fighter" ></nowiki>}}</pre> |
Latest revision as of 06:36, 29 September 2024
This is a documentation subpage for Code. It contains usage information, categories and other content that is not part of the original template page. |
{{code}}
is a shorthand to more easily write inline code and highlight variables on the wiki. {{c}}
is an even smaller shorthand. For more complex content you'll still likely need to use <code>
+<nowiki>
-elements, as some special characters causes problem with the template that doesn't happen when using <code>
+<nowiki>
.
There have been attempt to make the template more robust against this, but seems there is no simple way to put a template variable inside a nowiki element, as anything inside gets ignored.
See: Displaying Macros and Code for details.
Example 1.
any words before /r 1d6+4
, or words, /roll 1d6+4
any words before {{code|/r 1d6+4}}, or words, {{c|/roll 1d6+4}}
Example 2.
You can even write code that include problematic elements that the wiki could mistake for wiki syntax, such as {{title=@{character_name} }}
without the need of using nowiki element the code block. However, wiki links would still show up so nowiki is needed if inline rolls are present: Inline roll [[1d6+4]] would usually turn into a wiki link
You can even write code that include problematic elements that the wiki could mistake for wiki syntax, such as {{code|{{title=@{character_name} }}}} without the need of using nowiki element the code block. However, wiki links would still show up so nowiki is needed if inline rolls are present: {{code|Inline roll [[1d6+4]] would usually turn into a wiki link }}
Example 3.
Any text that contains |(pipe) or =(equal sign) need to be escaped with nowiki elements, making use of the template
<input type="text" name="attr_class" value="fighter" >
{{code|<input type="text" name="attr_class" value="fighter" >}}