Template:NB: Difference between revisions

From VASP Wiki
No edit summary
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
<!--
Creates a box with VASP color palette.
USAGE: {{BOX|style|message|firstword}}
style is one of: tip, deprecated, note, warning, important
otherwise draws just a black box.
-->
{{#switch: {{{1}}}
{{#switch: {{{1}}}
  | tip        = {{{!}} style="border: 3px solid #2FB5AB; padding: 10px; background: #F3FCFB"
  | mind      = {{{3|}}}{{{!}} style="border: 0px solid #2FB5AB; padding: 5px; background: #F3FCFB"
   {{!}} '''<span style="color: #2FB5AB;">{{{4|Tip:}}}</span>''' {{{2}}}
   {{!}} '''<span style="color: #2FB5AB;">{{{4|Mind:}}}</span>''' {{{2}}}
   {{!}}}
   {{!}}}
  | deprecated = {{{!}} style="border: 3px solid #808080; padding: 10px; background: #F7F7F7"
  | deprecated = {{{3|}}}{{{!}} style="border: 0px solid #808080; padding: 5px; background: #F7F7F7"
   {{!}} '''<span style="color: #808080;">{{{4|Deprecated:}}}</span>''' {{{2}}}
   {{!}} '''<span style="color: #808080;">{{{4|Deprecated:}}}</span>''' {{{2}}}
   {{!}}}
   {{!}}}
  | note      = {{{!}} style="border: 3px solid #2C68FC; padding: 10px; background: #F0F4FF"
  | tip        = {{{3|}}}{{{!}} style="border: 0px solid #2C68FC; padding: 5px; background: #F0F4FF"
   {{!}} '''<span style="color: #2C68FC;">{{{4|Note:}}}</span>''' {{{2}}}
   {{!}} '''<span style="color: #2C68FC;">{{{4|Tip:}}}</span>''' {{{2}}}
   {{!}}}
   {{!}}}
  | warning    = {{{!}} style="border: 3px solid #A82C35; padding: 10px; background: #FCF3F4"
  | warning    = {{{3|}}}{{{!}} style="border: 0px solid #A82C35; padding: 5px; background: #FCF3F4"
   {{!}} '''<span style="color: #A82C35;">{{{4|Warning:}}}</span>''' {{{2}}}
   {{!}} '''<span style="color: #A82C35;">{{{4|Warning:}}}</span>''' {{{2}}}
   {{!}}}
   {{!}}}
  | important  = {{{!}} style="border: 3px solid #4C265F; padding: 10px; background: #F8F4FB"
  | important  = {{{3|}}}{{{!}} style="border: 0px solid #4C265F; padding: 5px; background: #F8F4FB"
   {{!}} '''<span style="color: #4C265F;">{{{4|Important:}}}</span>''' {{{2}}}
   {{!}} '''<span style="color: #4C265F;">{{{4|Important:}}}</span>''' {{{2}}}
   {{!}}}
   {{!}}}
  | #default  = {{{!}} style="border: 3px solid #000000; padding: 10px; background: #FFFFFF"
  | #default  = {{{3|}}}{{{!}} style="border: 1px solid #000000; padding: 5px; background: #FFFFFF"
   {{!}} {{{2}}}
   {{!}} {{{2}}}
   {{!}}}
   {{!}}}
}}
}}<noinclude>
== Purpose ==
This template draws various colored boxes which can be filled with user content. Should be used to replace instances of '''N.B.:''' or similar.
 
== Parameters ==
 
<nowiki> {{NB|<style>|<message>|<<indent>>|<<firstword>>}}</nowiki>
 
* <code>style</code>: One of <code>tip,deprecated,mind,warning,important</code>, selects the box style, i.e. the color and the first word (see examples below). If <code>style</code> is not any of the words in the list, a black box without first word is drawn.
* <code>message</code>: The content of the box (after the first word).
* <code>indent</code>: ('''optional''') Allows to indent the whole box with regular colon sign. Use multiple ":" signs to get any level of indentation. Can be left empty if no indentation is needed but <code>firstword</code> is required. Any other character than ":" may produce unexpected results!
* <code>firstword</code>: ('''optional''') Overrides the default first word for any of the predefined styles.
 
 
== Examples ==
 
=== Regular usage ===
 
Without optional arguments these boxes are available:
 
<nowiki> {{NB|tip|This is the clever way of doing it!}}
 
{{NB|deprecated|This feature is deprecated and will be removed in the next release}}
 
{{NB|mind|You can manually set this via '''SOME_TAG'''}}
 
{{NB|warning|Never do this at home!}}
 
{{NB|important|You should really consider this!}}
 
{{NB|none|Just a box.}}</nowiki>
will produce
{{NB|tip|This is the clever way of doing it!}}
 
{{NB|deprecated|This feature is deprecated and will be removed in the next release}}
 
{{NB|mind|You can manually set this via '''SOME_TAG'''}}
 
{{NB|warning|Never do this at home!}}
 
{{NB|important|You should really consider this!}}
 
{{NB|none|Just a box.}}
 
=== Special features ===
 
Replacing the first word while sticking to the <code>warning</code> color scheme (note the empty third argument):
 
<nowiki> {{NB|warning|Really, really don't do this!||CAUTION!!!}}</nowiki>
{{NB|warning|Really, really don't do this!||CAUTION!!!}}
----
Indenting with default first word:
 
<nowiki> {{NB|tip|This is indented one level.|:}}
{{NB|tip|This is indented two levels.|::}}</nowiki>
{{NB|tip|This is indented one level.|:}}
{{NB|tip|This is indented two levels.|::}}
 
=== Problems and workarounds ===
 
The <code>message</code> cannot contain the "=" character because this has a special meaning for named template parameters. Therefore, we have to use the <code><nowiki>{{=}}</nowiki></code> template instead:
 
<nowiki>{{NB|tip|We highly recommend '''MY_TAG''' {{=}} 42}}</nowiki>
{{NB|tip|We highly recommend '''MY_TAG''' {{=}} 42}}
 
----
Note that using an indented box within a list requires the text after the box to be indented manually:
 
<nowiki> * First item
{{NB|tip|Second item is also great!|:}}
:Some more text belonging to first item
* Second item</nowiki>
* First item
{{NB|tip|Second item is also great!|:}}
:Some more text belonging to first item
* Second item
----
Unfortunately, when using numbered lists the item counter is reset when a box is inserted and requires manual setting of the start value with the <code>li value</code> tag:
 
<nowiki> # Option A
{{NB|warning|Option B should be avoided!|:}}
:Some more text belonging to first option
# <li value="2"> Option B</nowiki>
# Option A
{{NB|warning|Option B should be avoided!|:}}
:Some more text belonging to first option
# <li value="2"> Option B
 
</noinclude>

Latest revision as of 16:14, 14 October 2021

{{{2}}}

Purpose

This template draws various colored boxes which can be filled with user content. Should be used to replace instances of N.B.: or similar.

Parameters

 {{NB|<style>|<message>|<<indent>>|<<firstword>>}}
  • style: One of tip,deprecated,mind,warning,important, selects the box style, i.e. the color and the first word (see examples below). If style is not any of the words in the list, a black box without first word is drawn.
  • message: The content of the box (after the first word).
  • indent: (optional) Allows to indent the whole box with regular colon sign. Use multiple ":" signs to get any level of indentation. Can be left empty if no indentation is needed but firstword is required. Any other character than ":" may produce unexpected results!
  • firstword: (optional) Overrides the default first word for any of the predefined styles.


Examples

Regular usage

Without optional arguments these boxes are available:

 {{NB|tip|This is the clever way of doing it!}}

 {{NB|deprecated|This feature is deprecated and will be removed in the next release}}

 {{NB|mind|You can manually set this via '''SOME_TAG'''}}

 {{NB|warning|Never do this at home!}}

 {{NB|important|You should really consider this!}}

 {{NB|none|Just a box.}}

will produce

Tip: This is the clever way of doing it!


Deprecated: This feature is deprecated and will be removed in the next release


Mind: You can manually set this via SOME_TAG


Warning: Never do this at home!


Important: You should really consider this!


Just a box.

Special features

Replacing the first word while sticking to the warning color scheme (note the empty third argument):

 {{NB|warning|Really, really don't do this!||CAUTION!!!}}
CAUTION!!! Really, really don't do this!

Indenting with default first word:

 {{NB|tip|This is indented one level.|:}}
 {{NB|tip|This is indented two levels.|::}}
Tip: This is indented one level.
Tip: This is indented two levels.

Problems and workarounds

The message cannot contain the "=" character because this has a special meaning for named template parameters. Therefore, we have to use the {{=}} template instead:

{{NB|tip|We highly recommend '''MY_TAG''' {{=}} 42}}
Tip: We highly recommend MY_TAG = 42

Note that using an indented box within a list requires the text after the box to be indented manually:

 * First item
 {{NB|tip|Second item is also great!|:}}
 :Some more text belonging to first item
 * Second item
  • First item
Tip: Second item is also great!
Some more text belonging to first item
  • Second item

Unfortunately, when using numbered lists the item counter is reset when a box is inserted and requires manual setting of the start value with the li value tag:

 # Option A
 {{NB|warning|Option B should be avoided!|:}}
 :Some more text belonging to first option
 # <li value="2"> Option B
  1. Option A
Warning: Option B should be avoided!
Some more text belonging to first option
  1. Option B