Template:Hbc-hl: Difference between revisions
(Do not use quotes in template parameter value) |
(Seems hack does not work for non-pre tag. Use [https://www.mediawiki.org/wiki/Help:Magic_words#Miscellaneous tags] template instead.) |
||
Line 14: | Line 14: | ||
* {{ic|3}} or {{ic|output}}: the code in the bottom pane | * {{ic|3}} or {{ic|output}}: the code in the bottom pane | ||
<nowiki>{{hc-hl|lang= | <nowiki>{{hc-hl|lang=python|script.py| | ||
def quick_sort(arr): | |||
less = []}}</nowiki> | |||
<nowiki>{{hc-hl| | <nowiki>{{hc-hl|python|head=script.py|output=output= | ||
def quick_sort(arr): | |||
less = []}}</nowiki> | |||
See [https://pygments.org/languages/ here] for supported values for {{ic|lang}}. | See [https://pygments.org/languages/ here] for supported values for {{ic|lang}}. | ||
Line 22: | Line 26: | ||
== Example == | == Example == | ||
{{hc-hl|lang= | {{hc-hl|lang=python|head=script.py|output=def quick_sort(arr): | ||
less = []}}</noinclude><includeonly>{{#tag:pre|{{{head|{{{2|{{META Error}}}}}}}}|style="margin-bottom: 0; border-bottom:none; padding-bottom:0.8em;"}}<!-- The line break is needed, otherwise the wiki will generate extraneous paragraphs inside the 2nd pre block --> | |||
{{#tag:syntaxhighlight| | |||
{{{output|{{{3|{{META Error}}}}}}}} | |||
|lang="{{{lang|{{{1|{{META Error}}}}}}}}"|style="margin-bottom: 0; border-bottom:none; padding-bottom:0.8em;"}}</includeonly> |
Revision as of 02:21, 28 September 2023
Page Template:Hc-hl/styles.css has no content.
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 sintax.
- Use Template:bc for block code without header.
- Use Template:ic for inline code.
Usage
1
orlang
: the language of code block, to apply highlighting2
orhead
: the code in the top pane3
oroutput
: the code in the bottom pane
{{hc-hl|lang=python|script.py| def quick_sort(arr): less = []}}
{{hc-hl|python|head=script.py|output=output= def quick_sort(arr): less = []}}
See here for supported values for lang
.