Template:Codesample

From Bonkipedia
Revision as of 18:06, 12 November 2022 by ManfredoDo (talk | contribs) (1 revision imported: Template documentation pages)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Template documentation

<syntaxhighlight> with fancy colors and an optional title

Template parameters

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
Titlename

Title (name) of this code sample. Often a filename

Stringsuggested
Programming languagelang

Name of lexer to use for highlighting

Default
text
Example
shell-session
Stringsuggested
Codecode 1

Code sample to render

Stringrequired
Highlighted lineshighlight

Line(s) in example to highlight. Comma separated list of line numbers

Stringoptional
Show line numbersline

Enable line numbers for sample

Booleanoptional
Starting line numberstart

Starting line number when line numbers are shown. Note: Does not effect line numbers used for highlights.

Default
1
Numberoptional
Color schemescheme

Color scheme to use. "dark" and "light" will apply solarized color schemes. Anything else will use syntaxhighlight extension defaults.

Default
dark
Stringoptional

Examples

echo "hello world!"
echo "hello world!"
$ echo "hello world!"
{{Codesample}}
ingress.yaml
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: foo-redirect
  namespace: tool-foo
  labels:
    name: foo-redirect
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/permanent-redirect: https://bar.toolforge.org/$1$is_args$args
spec:
  rules:
    - host: foo.toolforge.org
      http:
        paths:
          - backend:
              serviceName: unused
              servicePort: 8000
            path: /(.*)
metadata
name: foo-redirect
  namespace: tool-foo
  labels:
    name: foo-redirect
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/permanent-redirect: https://bar.toolforge.org/$1$is_args$args

Adding a new color scheme

The scheme=... parameter will load a css sub-page to add styles matching the Pygments markup definitions. The easiest way to introduce a new scheme is to export it from Pygments itself: pygmentize -f html -S $style -a .wt-codesample-${style}.