Jump to content

Template:Hbc-hl: Difference between revisions

From KDE Community Wiki
Ashark (talk | contribs)
m Fix typo
Ashark (talk | contribs)
Fix double output, replace parameter name output to code
Line 12: Line 12:
* {{ic|1}} or {{ic|lang}}: the language of code block, to apply highlighting
* {{ic|1}} or {{ic|lang}}: the language of code block, to apply highlighting
* {{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|output}}: the code in the bottom pane
* {{ic|3}} or {{ic|code}}: the code in the bottom pane


  <nowiki>{{hc-hl|lang=python|script.py|
  <nowiki>{{hc-hl|lang=python|script.py|
Line 18: Line 18:
less = []}}</nowiki>
less = []}}</nowiki>


  <nowiki>{{hc-hl|python|head=script.py|output=output=
  <nowiki>{{hc-hl|python|head=script.py|code=
def quick_sort(arr):
def quick_sort(arr):
less = []}}</nowiki>
less = []}}</nowiki>
Line 26: Line 26:
== Example ==
== Example ==


{{hc-hl|lang=python|head=script.py|output=def quick_sort(arr):
{{hc-hl|lang=python|head=script.py|code=def quick_sort(arr):
less = []}}
less = []}}


Line 38: Line 38:
</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 -->
</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|
{{#tag:syntaxhighlight|
{{{output|{{{3|{{META Error}}}}}}}}
{{{code|{{{3|{{META Error}}}}}}}}
|lang="{{{lang|{{{1|{{META Error}}}}}}}}"|style="margin-bottom: 0; border-bottom:none; padding-bottom:0.8em;"}}</includeonly>
|lang="{{{lang|{{{1|{{META Error}}}}}}}}"|style="margin-bottom: 0; border-bottom:none; padding-bottom:0.8em;"}}</includeonly>

Revision as of 13:38, 28 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.

Usage

  • 1 or lang: the language of code block, to apply highlighting
  • 2 or head: the code in the top pane
  • 3 or code: the code in the bottom pane
{{hc-hl|lang=python|script.py|
def quick_sort(arr):
	less = []}}
{{hc-hl|python|head=script.py|code=
def quick_sort(arr):
	less = []}}

See here for supported values for lang.

Example

Template:Hc-hl

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.