Skip to content
Permalink
Browse files

Merge branch 'fix-highlight-shortcode-local'

  • Loading branch information...
kaushalmodi committed Jun 16, 2019
2 parents 85dfa23 + f1ec1c7 commit 5eb33859e9649996b4b29bd09bd17a6caf27810b
@@ -91,6 +91,15 @@ void do();
{{< /highlight >}}`,
`(?s)<div class="highlight"><pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java"`,
},
{` {{< highlight emacs-lisp >}}
(message "hello")
(message "hello again")
{{< /highlight >}}`,
`(?s)<div class="highlight"><pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-emacs-lisp" data-lang="emacs-lisp">\(message <span style="font-style:italic">&#34;hello&#34;</span>\)
\(message <span style="font-style:italic">&#34;hello again&#34;</span>\)</code></pre></div>`,
},
{`{{< highlight java "style=friendly" >}}
void do();
{{< /highlight >}}`,

Some generated files are not rendered by default. Learn more.

@@ -1 +1,22 @@
{{ if len .Params | eq 2 }}{{ highlight (trim .Inner "\n\r") (.Get 0) (.Get 1) }}{{ else }}{{ highlight (trim .Inner "\n\r") (.Get 0) "" }}{{ end }}
{{- $code := (trim .Inner "\n\r") -}}
{{- $lang := .Get 0 -}}
{{- $options := .Get 1 | default "" -}}
{{- $code_ending_in_line_with_spaces := (findRE "[\\r\\n][[:blank:]]+$" $code) -}}
{{/* Ref: https://github.com/gohugoio/hugo/issues/4717#issuecomment-449375012 */}}
{{- with $code_ending_in_line_with_spaces -}}
{{- $code = (replace $code "\r" "") -}} {{/* Windows -> Unix style line endings for ease in further parsing */}}
{{- $offset := (trim (index . 0) "\n") -}}
{{- $lines := (split $code "\n") -}}
{{- $num_lines := (len $lines) -}}
{{- $scratch := newScratch -}}
{{- $scratch.Add "lines_minus_offset" (slice) -}}
{{- range $i, $line := $lines -}}
{{- $line_minus_offset := (strings.TrimPrefix $offset $line) -}}
{{- if (lt $i (sub $num_lines 1)) -}} {{/* Do not add the last blank line */}}
{{- $scratch.Add "lines_minus_offset" (slice $line_minus_offset) -}}
{{- end -}}
{{- end -}}
{{- $code = (delimit ($scratch.Get "lines_minus_offset") "\n") -}}
{{- $scratch.Delete "lines_minus_offset" -}}
{{- end -}}
{{- highlight $code $lang $options -}}

0 comments on commit 5eb3385

Please sign in to comment.
You can’t perform that action at this time.