Jump to content

Template:Hbc-hl: Difference between revisions

From KDE Community Wiki
Ashark (talk | contribs)
Do not use quotes in template parameter value
Ashark (talk | contribs)
Enable style after the TemplateStyles extension was installed (see Bug 474964).
 
(13 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 sintax.
* 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.


== Usage ==
== Parameters ==


* {{ic|1}} or {{ic|lang}}: the language of code block, to apply highlighting
* {{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|output}}: the code in the bottom pane
* {{ic|3}} or {{ic|code}}: the code in the bottom pane


<nowiki>{{hc-hl|lang=c++|main.h|#include <stdio.h>}}</nowiki>
== Usage examples ==


  <nowiki>{{hc-hl|c++|head=main.h|output=#include <stdio.h>}}</nowiki>
With full parameter names:
  <nowiki>
{{hbc-hl|lang=python|head=script.py|code=
def quick_sort(arr):
less = []}}</nowiki>


See [https://pygments.org/languages/ here] for supported values for {{ic|lang}}.
Without naming parameters:
<nowiki>
{{hbc-hl|python|script.py|
def quick_sort(arr):
less = []}}</nowiki>


== Example ==
== Result ==


{{hc-hl|lang=c++|head=main.h|output=#include <stdio.h>}}</noinclude><includeonly><pre<noinclude></noinclude> style="margin-bottom: 0; border-bottom:none; padding-bottom:0.8em;">{{{head|{{{2|{{META Error}}}}}}}}</pre<noinclude></noinclude>><!-- The line break is needed, otherwise the wiki will generate extraneous paragraphs inside the 2nd pre block -->
{{hbc-hl|lang=python|head=script.py|code=def quick_sort(arr):
<syntaxhighlight<noinclude></noinclude> lang="{{{lang|{{{1|{{META Error}}}}}}}}" style="margin-top: 0; border-top-style:dashed; padding-top: 0.8em;">{{{output|{{{3|{{META Error}}}}}}}}</syntaxhighlight<noinclude></noinclude>></includeonly><noinclude><!-- The &lt;noinclude>&lt;/noinclude> hack is needed to allow wiki markup inside the pre tags; reference: http://www.gossamer-threads.com/lists/wiki/mediawiki/118688#118688 --></noinclude>
less = []}}
 
== See also ==
 
* [https://pygments.org/languages/ List of supported values for {{ic|lang}} parameter].
 
</noinclude><includeonly>{{#tag:pre|{{{head|{{{2|{{META Error}}}}}}}}|style="margin-bottom: 0; border-bottom:none; padding-bottom:0.8em;"}}
{{#tag:syntaxhighlight|
{{{code|{{{3|{{META Error}}}}}}}}
|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