Template:Codesample
This template uses TemplateStyles: |
<syntaxhighlight> with fancy colors and an optional title
Parameter | Description | Type | Status | |
---|---|---|---|---|
Title | name | Title (name) of this code sample. Often a filename | String | suggested |
Programming language | lang | Name of lexer to use for highlighting
| String | suggested |
Code | code 1 | Code sample to render | String | required |
Highlighted lines | highlight | Line(s) in example to highlight. Comma separated list of line numbers | String | optional |
Show line numbers | line | Enable line numbers for sample | Boolean | optional |
Starting line number | start | Starting line number when line numbers are shown. Note: Does not effect line numbers used for highlights.
| Number | optional |
Color scheme | scheme | Color scheme to use. "dark" and "light" will apply solarized color schemes. Anything else will use syntaxhighlight extension defaults.
| String | optional |
Examples
echo "hello world!"
echo "hello world!"
$ echo "hello world!"
{{Codesample}}
---
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: /(.*)
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}
.