|
|
| (8 intermediate revisions by one other user not shown) |
| Line 1: |
Line 1: |
| <br><code style="padding: {{{2|1em}}};">{{{1}}}</code><br><br><noinclude>
| | {{{2|}}}{| style="width:100%; table-layout: fixed; border-spacing: 0; padding: 0; margin: 0; background-color: var(--vCB-bg); color: var(--vdefault-text); border-width: 1px; border-style: solid; border-color: var(--vCB-border);" |
| | |{{#tag:pre|{{{1}}}|style="margin: 0; padding: {{{3|1em}}}; background: none; border: none; white-space: pre; overflow-x: auto; font-family: monospace;"}} |
| | |}<noinclude> |
|
| |
|
| == Purpose == | | == Purpose == |
| 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. | | 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> | | <nowiki> MY_SPECIAL_TAG = A B C |
| | MY_OTHER_TAG = 1</nowiki> |
|
| |
|
| will print as: | | will print as: |
|
| |
|
| MY_SPECIAL_TAG = A B C | | MY_SPECIAL_TAG = A B C |
| | MY_OTHER_TAG = 1 |
|
| |
|
| 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.}} | | 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|Currently, this template does not support nested templates, i.e., other templates like [[Template:TAG]] do not get properly expanded inside the code block.}} |
|
| |
|
| == Parameters == | | == Parameters == |
|
| |
|
| <nowiki> {{CB|<content>|<<padding>>}}</nowiki> | | <nowiki> {{CB|<content>|<<indent>>|<<padding>>}}</nowiki> |
|
| |
|
| * <code>content</code>: The content of the code block. | | * <code>content</code>: The content of the code block. |
| | * <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>padding</code> is required. Any other character than ":" may produce unexpected results! |
| * <code>padding</code>: ('''optional''') Specifies the padding of the code box, the default is <code>1em</code>. | | * <code>padding</code>: ('''optional''') Specifies the padding of the code box, the default is <code>1em</code>. |
|
| |
|
| Line 23: |
Line 28: |
| Without optional arguments the following example | | Without optional arguments the following example |
|
| |
|
| <nowiki>::{{CB|MY_SPECIAL_TAG {{=}} A B C}}</nowiki> | | <nowiki>{{CB|MY_SPECIAL_TAG {{=}} A B C}}</nowiki> |
|
| |
|
| gives: | | gives: |
|
| |
|
| ::{{CB|MY_SPECIAL_TAG {{=}} A B C}}
| | {{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.:
| | This should be very close to the regular preformatted text boxes we can obtain via MediaWiki syntax. Here are two examples for indentation levels: |
|
| |
|
| <nowiki>::{{CB|MY_SPECIAL_TAG {{=}} A B C|0.5em}}</nowiki> | | <nowiki>{{CB|MY_SPECIAL_TAG {{=}} A B C|:}}</nowiki> |
| | <nowiki>{{CB|MY_SPECIAL_TAG {{=}} A B C|::}}</nowiki> |
|
| |
|
| results in: | | results in: |
|
| |
|
| ::{{CB|MY_SPECIAL_TAG {{=}} A B C|0.5em}} | | {{CB|MY_SPECIAL_TAG {{=}} A B C|:}} |
| | {{CB|MY_SPECIAL_TAG {{=}} A B C|::}} |
|
| |
|
| == Problems and workarounds ==
| | Note that the boxes are correctly indented one and two levels. The padding can be reduced with the optional argument, e.g.: |
|
| |
|
| 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.
| | <nowiki>{{CB|MY_SPECIAL_TAG {{=}} A B C|:|0.5em}}</nowiki> |
| | <nowiki>{{CB|MY_SPECIAL_TAG {{=}} A B C|::|0.5em}}</nowiki> |
|
| |
|
| == Ideas for improvement ==
| | gives this: |
|
| |
|
| {| style="white-space: pre; width: auto; table-layout: fixed; overflow-x: auto; font-family: monospace; line-height: 1em; border-spacing: 0; padding-left: 0.8em; padding-right: 0; padding-top: 0; padding-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; margin-bottom: 0; background-color: #f8f9fa; color: #000; border: 1px solid #eaecf0; border-width: 1px; border-style: solid; border-color: rgb(234, 236, 240); border-width: 1px; border-style: solid; border-color: rgb(234, 236, 240);" | | {{CB|MY_SPECIAL_TAG {{=}} A B C|:|0.5em}} |
| | style="width: 100%; overflow-x: auto" |{{TAGBL|BEXT}} {{=}} B1 B2 B3 ! in eV
| | {{CB|MY_SPECIAL_TAG {{=}} A B C|::|0.5em}} |
| |} | |
|
| |
|
| | Finally, the padding can also be specified without any indentation: |
|
| |
|
| {| style="white-space: pre; width: 100%; table-layout: fixed; overflow-x: auto; font-family: monospace; line-height: 1em; border-spacing: 0; padding-left: 0.8em; padding-right: 0; padding-top: 0; padding-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; margin-bottom: 0; background-color: #f8f9fa; color: #000; border: 1px solid #eaecf0; border-width: 1px; border-style: solid; border-color: rgb(234, 236, 240); border-width: 1px; border-style: solid; border-color: rgb(234, 236, 240);"
| | <nowiki>{{CB|MY_SPECIAL_TAG {{=}} A B C||0.5em}}</nowiki> |
| |<div style="width: 100%; overflow-x: auto; float: left">{{TAGBL|BEXT}} {{=}} B1 B2 B3 ! in eV</div>
| |
| |}
| |
|
| |
|
| | shows as: |
|
| |
|
| {| style="white-space: pre; width: 100%; table-layout: fixed; overflow: auto; font-family: monospace; line-height: 1em; border-spacing: 0; padding-left: 0.8em; padding-right: 0; padding-top: 0; padding-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; margin-bottom: 0; background-color: #f8f9fa; color: #000; border: 1px solid #eaecf0; border-width: 1px; border-style: solid; border-color: rgb(234, 236, 240); border-width: 1px; border-style: solid; border-color: rgb(234, 236, 240);" | | {{CB|MY_SPECIAL_TAG {{=}} A B C||0.5em}} |
| |<div style="width: 100%; overflow: auto; float: left">{{TAG|ML_MODE}} Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
| |
| Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
| |
| | |
| Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet,</div>
| |
| |} | |
| | |
| | |
| {| style="white-space: pre; width: 100%; table-layout: fixed; overflow: auto; font-family: monospace; line-height: 1em; padding-left: 0.8em; padding-right: 0; padding-top: 0; padding-bottom: 0; margin: 0; background-color: #f8f9fa; color: #000; border: 1px solid #eaecf0; border-width: 1px; border-style: solid; border-color: rgb(234, 236, 240); border-width: 1px; border-style: solid; border-color: rgb(234, 236, 240);"
| |
| |
| |
| <div style="width: 100%; overflow: auto">{{TAG|ML_MODE}} Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
| |
| Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
| |
| | |
| Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet,</div>
| |
| |}
| |
|
| |
|
| | == Problems and workarounds == |
|
| |
|
| {{TAG|ML_MODE}} Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
| | The <code>content</code> cannot contain the "=" or "|" character because this has a special meaning for named template parameters. Therefore, we have to use the <code><nowiki>{{=}}</nowiki></code> and <code><nowiki>{{!}}</nowiki></code> template, respectively. |
| Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
| |
|
| |
| Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet,
| |
| </noinclude> | | </noinclude> |
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
MY_OTHER_TAG = 1
will print as:
MY_SPECIAL_TAG = A B C
MY_OTHER_TAG = 1
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: Currently, this template does not support nested templates, i.e., other templates like Template:TAG do not get properly expanded inside the code block.
|
Parameters
{{CB|<content>|<<indent>>|<<padding>>}}
content: The content of the code block.
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 padding is required. Any other character than ":" may produce unexpected results!
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:
This should be very close to the regular preformatted text boxes we can obtain via MediaWiki syntax. Here are two examples for indentation levels:
{{CB|MY_SPECIAL_TAG {{=}} A B C|:}}
{{CB|MY_SPECIAL_TAG {{=}} A B C|::}}
results in:
Note that the boxes are correctly indented one and two levels. The padding can be reduced with the optional argument, e.g.:
{{CB|MY_SPECIAL_TAG {{=}} A B C|:|0.5em}}
{{CB|MY_SPECIAL_TAG {{=}} A B C|::|0.5em}}
gives this:
Finally, the padding can also be specified without any indentation:
{{CB|MY_SPECIAL_TAG {{=}} A B C||0.5em}}
shows as:
Problems and workarounds
The content cannot contain the "=" or "|" character because this has a special meaning for named template parameters. Therefore, we have to use the {{=}} and {{!}} template, respectively.