Template:CB: Difference between revisions

From VASP Wiki
(Created page with "{{{1}}}<noinclude> == Purpose == Create a code block which can be indented with the usual <code>:</code> indentation marker. == Parameters == <nowiki> {{CB|<content>|<<padding>>}}</nowiki> == Examples == Without optional arguments these boxes are available: <nowiki> {{CB|MY_SPECIAL_TAG = A B C}} {{CB|MY_SPECIAL_TAG = A B C}} </noinclude>")
 
No edit summary
Line 1: Line 1:
{{{1}}}<noinclude>
<br><code style="padding: {{{2|1em}}};">{{{1}}}</code><br><br><noinclude>


== Purpose ==
== Purpose ==
Create a code block which can be indented with the usual <code>:</code> indentation marker.
Create a code block which can be indented with the usual <code>:</code> indentation marker. Normally, a preformatted text block can be inserted with an additional space in the beginning, e.g.
 
<nowiki> MY_SPECIAL_TAG = A B C</nowiki>
 
will print as:
 
MY_SPECIAL_TAG = A B C
 
However, this syntax does not allow indenting, e.g., in lists. The <code>CB</code> (as in '''C'''ode '''B'''lock) template allows the box to be indented any level. {{NB|warning|Unfortunately, this currently works for single lines, multiple lines are unreadable.}}


== Parameters ==
== Parameters ==


  <nowiki> {{CB|<content>|<<padding>>}}</nowiki>
  <nowiki> {{CB|<content>|<<padding>>}}</nowiki>
* <code>content</code>: The content of the code block.
* <code>padding</code>: ('''optional''') Specifies the padding of the code box, the default is <code>1em</code>.


== Examples ==
== Examples ==


Without optional arguments these boxes are available:
Without optional arguments the following example
 
<nowiki>::{{CB|MY_SPECIAL_TAG {{=}} A B C}}</nowiki>
 
gives:
 
::{{CB|MY_SPECIAL_TAG {{=}} A B C}}
 
Note that the box is correctly indented two levels. The padding can be reduced with the optional argument, e.g.:
 
<nowiki>::{{CB|MY_SPECIAL_TAG {{=}} A B C|0.5em}}</nowiki>
 
results in:


<nowiki> {{CB|MY_SPECIAL_TAG = A B C}}
::{{CB|MY_SPECIAL_TAG {{=}} A B C|0.5em}}


{{CB|MY_SPECIAL_TAG = A B C}}
== Problems and workarounds ==


The <code>content</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.
</noinclude>
</noinclude>

Revision as of 12:56, 9 February 2024


{{{1}}}

Purpose

Create a code block which can be indented with the usual : indentation marker. Normally, a preformatted text block can be inserted with an additional space in the beginning, e.g.

 MY_SPECIAL_TAG = A B C

will print as:

MY_SPECIAL_TAG = A B C

However, this syntax does not allow indenting, e.g., in lists. The CB (as in Code Block) template allows the box to be indented any level.

Warning: Unfortunately, this currently works for single lines, multiple lines are unreadable.

Parameters

 {{CB|<content>|<<padding>>}}
  • content: The content of the code block.
  • padding: (optional) Specifies the padding of the code box, the default is 1em.

Examples

Without optional arguments the following example

::{{CB|MY_SPECIAL_TAG {{=}} A B C}}

gives:


MY_SPECIAL_TAG = A B C

Note that the box is correctly indented two levels. The padding can be reduced with the optional argument, e.g.:

::{{CB|MY_SPECIAL_TAG {{=}} A B C|0.5em}}

results in:


MY_SPECIAL_TAG = A B C

Problems and workarounds

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