Template:Code/doc
- See also: Template:Samp
This template is an alternative way to use <code>...</code>
(i.e. the HTML <code>
element). You should avoid using this template in history sections, but it's fine if you do.
Parameters
Parameter | Behavior | Accepted values | Default |
---|---|---|---|
Anonymous parameters, i.e. parameters that don't have names. | These are the text that code will display as inline <code> elements. One <code> element will be used to wrap each of the anonymous parameters. |
Any text. | None |
d , delim or delimiter |
The delimiter to use between the <code> elements. |
or , and , br , list , or-list , and-list , & , , , none or any other text. or , and & & have a special behavior where the delimiter is different at the end, and , adds a space after the comma, but all other deimiters are simply placed between the <code> elements. |
(a single space)
|
wordbreak or wb |
If specified, long words in the <code> element will break into multiple lines. This might be required if you are dealing with URLs (see below). |
1 true , or any other non-empty string. |
(boolean) False |
Escape characters
Keep in mind pipes and equals signs are used to specifiy parameters in templates. If you want the text "number of cats = number of mice * 3 * multiplier" to be formatted propoerly, you must escape the =
. {{cd|=}}
gives an error because the equal sign if interpreted as assigning an empty string to the paramer whose name is an empty string.
Magic words
There are many ways to "escape" text on this wiki. First, we have magic words for the equals sign and pipe. And we can use the non-breaking space HTML entity for spaces.
Wikitext | Result | Result in Code |
---|---|---|
{{!}} |
||
{{=}} |
= | =
|
|
= |
|
You might also need to escape double curly braces, {{like these}}, and many other forms of formatting on this wiki. This can be done using <nowiki>...</nowiki>
, or by putting <nowiki/>
between the braces. Non-breaking space (
) works more often than <nowiki>
element does, so I suggest you use
.
Use the |delimiter=
parameter (aliases |delim=
or |d=
) to change the separator between each string. Set this value to the name in words of the delimiter, such as "and", "br", "or-list", "none", etc. When using a list delimiter, use |list-level=
to change the indentation (defaults to **
).
HTML entities
If you want to include spaces at the start of end of a <code>
element, you need to either escape it with <nowiki>...</nowiki>
or use
.
If you want to use <angle brackets>, <like this>, you might need to use more HTML entities. Usually, you won't need to do this, inless you are describing how to use HTML elements or HTML entities on the page where you're using this template.
Finally, in some rare instances, you will need to use the legendary &
, or even the mythical &amp;
.
Name | HTML | Result | Result in Code |
---|---|---|---|
Non-breaking space | |
| |
Less than | < |
< | <
|
Greater than | > |
> | >
|
Ampersand | & |
& | &
|
Examples
{{code|text}}
–text
{{code|1|2|3|4|5}}
–1
2
3
4
5
- Formatted ocde
- Comma delimiter
- And delimiter
- Or delimiter
- Escape character usage
Word Breaking
Header text A | Header text B | Header text C | Header text D | Header text E |
---|---|---|---|---|
Some text | Normally if you have a really long piece of text, like this, it doesn't cause any issues, because the text will break between the words into multiple lines. |
More text | More text | More text, extended to make my point. |
Normally if you have a really long piece of text, like this, it doesn't cause any issues, because the text will break between the words into multiple lines. |
Some text | More text | More text | More text, extended to make my point. |
Yet more text. | Yet more text. | Yet more text. | Yet more text. | Yet more text. |
However, if we have an extremely long URL (this example is not actually in the game), like minecraft/generation/overworld/structures/rare/experimental/trial_chambers/version_3/chambers/chamber_4/section_3/layer_3/step_1/loot_table/main_draw.json
, it will not break when used in a table and will end up making its column far too wide.
I have collapsed this table for your convenience. Good luck finding the collapse button after expanding it!
Header text A | Header text B | Header text C | Header text D | Header text E |
---|---|---|---|---|
Some text | minecraft/generation/overworld/structures/rare/experimental/trial_chambers/version_3/chambers/chamber_4/section_3/layer_3/step_1/loot_table/main_draw.json |
More text | More text | More text, extended to make my point. |
minecraft/generation/overworld/structures/rare/experimental/trial_chambers/version_3/chambers/chamber_4/section_3/layer_3/step_1/loot_table/main_draw.json |
Some text | More text | More text | More text, extended to make my point. |
Yet more text. | Yet more text. | Yet more text. | Yet more text. | Yet more text. |
As you can see, having our words break would be nice here. The easiest way to do this to use the wb
/wordbreak
parameter. It allows the line to break anywhere it needs to, even in the middle of a word. The table below shows what this does
Wiki text | Code result | Header text C | Header text D | Header text E |
---|---|---|---|---|
{{cd|minecraft/generation/overworld/structures/rare/experimental/trial_chambers/version_3/chambers/chamber_4/section_3/layer_3/step_1/loot_table/main_draw.json|wb=1}} |
minecraft/generation/overworld/structures/rare/experimental/trial_chambers/version_3/chambers/chamber_4/section_3/layer_3/step_1/loot_table/main_draw.json |
More text | More text | More text, extended to make my point. |
{{cd|minecraft/generation/overworld/structures/rare/experimental/trial_chambers/version_3/chambers/chamber_4/section_3/layer_3/step_1/loot_table/main_draw.json|wb=1}} |
minecraft/generation/overworld/structures/rare/experimental/trial_chambers/version_3/chambers/chamber_4/section_3/layer_3/step_1/loot_table/main_draw.json |
More text | More text | More text, extended to make my point. |
Yet more text. | Yet more text. | Yet more text. | Yet more text. | Yet more text. |