Template:Hbc-hl: Difference between revisions
(Move link to separate section to make it more visible) |
(Reformat headers to show examples) |
||
Line 8: | Line 8: | ||
* Use [[Template:ic]] for inline code. | * Use [[Template:ic]] for inline code. | ||
== | == Parameters == | ||
* {{ic|1}} or {{ic|lang}}: the language of code block | * {{ic|1}} or {{ic|lang}}: the language of code block | ||
* {{ic|2}} or {{ic|head}}: the code in the top pane | * {{ic|2}} or {{ic|head}}: the code in the top pane | ||
* {{ic|3}} or {{ic|code}}: the code in the bottom pane | * {{ic|3}} or {{ic|code}}: the code in the bottom pane | ||
<nowiki>{{hc-hl| | == Usage examples == | ||
Without naming parameters: | |||
<nowiki>Some text | |||
{{hc-hl|python|script.py| | |||
def quick_sort(arr): | def quick_sort(arr): | ||
less = []}} | less = []}} | ||
<nowiki>{{hc-hl|python|head=script.py|code= | text continues.</nowiki> | ||
With full parameter names: | |||
<nowiki>Some text | |||
{{hc-hl|lang=python|head=script.py|code= | |||
def quick_sort(arr): | def quick_sort(arr): | ||
less = []}}</nowiki> | less = []}} | ||
text continues.</nowiki> | |||
== Result == | |||
Some text | |||
{{hc-hl|lang=python|head=script.py|code=def quick_sort(arr): | {{hc-hl|lang=python|head=script.py|code=def quick_sort(arr): | ||
less = []}} | less = []}} | ||
text continues. | |||
== See also == | == See also == |
Revision as of 09:23, 29 September 2023
This page is a template, editing it will affect all the pages that make use of it, so users should be especially careful when editing it. For more details on how to use templates see "A Quick Guide to Templates"
Block code with header. With highlighted syntax.
- Use Template:hc for block code with header without highlighted syntax.
- Use Template:bc for block code without header.
- Use Template:ic for inline code.
Parameters
1
orlang
: the language of code block2
orhead
: the code in the top pane3
orcode
: the code in the bottom pane
Usage examples
Without naming parameters:
Some text {{hc-hl|python|script.py| def quick_sort(arr): less = []}} text continues.
With full parameter names:
Some text {{hc-hl|lang=python|head=script.py|code= def quick_sort(arr): less = []}} text continues.
Result
Some text
text continues.
See also
ToDo
Waiting for TemplateStyles extension to be installed: https://bugs.kde.org/show_bug.cgi?id=474964 After that, switch the content model of Template:Hc-hl/styles.css to Sanitized CSS. Uncomment templatestyles tag. (It was commented, so it is not shown literally until the extension setup is done). After that, template should work normally.