Jump to content

Template:Hbc-hl: Difference between revisions

From KDE Community Wiki
Ashark (talk | contribs)
Reformat headers to show examples
Ashark (talk | contribs)
Enable style after the TemplateStyles extension was installed (see Bug 474964).
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
<!--templatestyles src="Template:Hc-hl/styles.css" /--><noinclude>{{DISPLAYTITLE:Template:hc-hl}}
<templatestyles src="Template:Hbc-hl/styles.css" /><noinclude>{{DISPLAYTITLE:Template:hbc-hl}}
{{Template}}
{{Template}}


Block code with header. With highlighted syntax.
Block code with header. With highlighted syntax.


* Use [[Template:hc]] for block code with header without highlighted syntax.
* Use [[Template:hbc]] for block code with header without highlighted syntax.
* Use [[Template:bc]] for block code without header.
* Use [[Template:bc]] for block code without header.
* Use [[Template:ic]] for inline code.
* Use [[Template:ic]] for inline code.
Line 16: Line 16:
== Usage examples ==
== Usage examples ==


Without naming parameters:
With full parameter names:
  <nowiki>Some text
  <nowiki>
 
{{hbc-hl|lang=python|head=script.py|code=
{{hc-hl|python|script.py|
def quick_sort(arr):
def quick_sort(arr):
less = []}}
less = []}}</nowiki>


text continues.</nowiki>
Without naming parameters:
 
  <nowiki>
With full parameter names:
{{hbc-hl|python|script.py|
  <nowiki>Some text
 
{{hc-hl|lang=python|head=script.py|code=
def quick_sort(arr):
def quick_sort(arr):
less = []}}
less = []}}</nowiki>
 
text continues.</nowiki>


== Result ==
== Result ==


Some text
{{hbc-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 ==
Line 47: Line 37:
* [https://pygments.org/languages/ List of supported values for {{ic|lang}} parameter].
* [https://pygments.org/languages/ List of supported values for {{ic|lang}} parameter].


== ToDo ==
</noinclude><includeonly>{{#tag:pre|{{{head|{{{2|{{META Error}}}}}}}}|style="margin-bottom: 0; border-bottom:none; padding-bottom:0.8em;"}}
 
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.
 
</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|
{{{code|{{{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>

Latest revision as of 21:40, 21 October 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.

Parameters

  • 1 or lang: the language of code block
  • 2 or head: the code in the top pane
  • 3 or code: the code in the bottom pane

Usage examples

With full parameter names:

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

Without naming parameters:

{{hbc-hl|python|script.py|
def quick_sort(arr):
	less = []}}

Result

script.py
def quick_sort(arr):
	less = []

See also