File tree Expand file tree Collapse file tree 5 files changed +40
-13
lines changed
content/learning-paths/cross-platform/_example-learning-path
themes/arm-design-system-hugo-theme/layouts
partials/general-formatting Expand file tree Collapse file tree 5 files changed +40
-13
lines changed Original file line number Diff line number Diff line change @@ -83,12 +83,26 @@ Specify that line_numbers are true in the following way:
8383\`\`\`bash { line_numbers = "true" } \
8484echo 'hello world' \
8585echo ‘I am line two’ \
86- \`\`\`
86+ \`\`\`
87+
88+ ```bash { line_numbers = "true" }
89+ echo ‘hello world’
90+ echo ‘I am line two’
91+ ```
92+
93+ In some cases, the line numbering should not start from one but from another
94+ value, e.g. if the code excerpt is extracted from a larger file. Use the
95+ ` line_start ` attribute to achieve this:
8796
88- ```bash { line_numbers = "true" }
89- echo ‘hello world’
90- echo ‘I am line two’
91- ```
97+ \`\`\` bash { line_numbers = "true" line_start = "10" } \
98+ echo 'hello world' \
99+ echo ‘I am line two’ \
100+ \`\`\`
101+
102+ ``` bash { line_numbers = "true" line_start = "10" }
103+ echo ‘hello world’
104+ echo ‘I am line eleven’
105+ ```
92106
93107### Output Lines
94108
Original file line number Diff line number Diff line change 66```
77*/}}
88{{partial "general-formatting/prismjs-codeblock.html" (dict "input_from" "normal" "code" .Inner "language" .Type
9- "line_numbers" .Attributes.line_numbers "output_lines" .Attributes.output_lines "command_line" .Attributes.command_line)
10- }}
9+ "line_numbers" .Attributes.line_numbers "output_lines" .Attributes.output_lines "command_line" .Attributes.command_line "line_start" .Attributes.line_start )
10+ }}
Original file line number Diff line number Diff line change 1414 code Str: echo('Hello world')....
1515 language Str: python
1616 line_numbers Bool: true or false
17+ line_start Str: 123
1718 output_lines Str: 5 or 1-4, 9
1819 command_line Str: "root@localhost"
1920*/}}
4243 {{$output_present = true}}
4344{{end}}
4445
45-
4646<!-- Start with the 'pre' element, then 'code' element, then the code content -->
4747< pre
48- {{if .command_line}}
49- class ="command-line "
50- data-user = {{ trim (index (split (index (split .command_line "|") 0) "@") 0 ) " "}}
51- data-host= {{ trim (index (split (index (split .command_line "|") 0) "@") 1 ) " "}}
52- data-output={{ trim (index (split .command_line "|") 1) " "}}
48+ {{if or (.command_line) (.line_start)}}
49+ {{if and (.command_line) (.line_start)}}
50+ class ="command-line line-numbers "
51+ {{else if .command_line}}
52+ class ="command-line "
53+ {{else if .line_start}}
54+ class ="line-numbers "
55+ {{end}}
56+ {{if .command_line}}
57+ data-user = {{ trim (index (split (index (split .command_line "|") 0) "@") 0 ) " "}}
58+ data-host= {{ trim (index (split (index (split .command_line "|") 0) "@") 1 ) " "}}
59+ data-output={{ trim (index (split .command_line "|") 1) " "}}
60+ {{end}}
61+ {{if .line_start}}
62+ data-start="{{.line_start}} "
63+ {{end}}
5364 {{end}}
5465>
5566 < code class ='language-{{.language}}
Original file line number Diff line number Diff line change 2727{{ else }}
2828{{ with $.Get "language" }} {{ $tab = merge $tab (dict "language" ($.Get "language")) }} {{ end }}
2929{{ with $.Get "line_numbers" }} {{ $tab = merge $tab (dict "line_numbers" ($.Get "line_numbers")) }} {{ end }}
30+ {{ with $.Get "line_start" }} {{ $tab = merge $tab (dict "line_start" ($.Get "line_start")) }} {{ end }}
3031{{ with $.Get "output_lines" }} {{ $tab = merge $tab (dict "output_lines" ($.Get "output_lines")) }} {{ end }}
3132{{ with $.Get "command_line" }} {{ $tab = merge $tab (dict "command_line" ($.Get "command_line")) }} {{ end }}
3233{{ with $.Inner }}
Original file line number Diff line number Diff line change 2323 "code" $element.content
2424 "language" $element.language
2525 "line_numbers" $element.line_numbers
26+ "line_start" $element.line_start
2627 "output_lines" $element.output_lines
2728 "command_line" $element.command_line) }}
2829 {{- end -}}
You can’t perform that action at this time.
0 commit comments