Whitespace stripping to make generated HTML more readable
This commit is contained in:
parent
e0c548e404
commit
f8a8c06266
|
@ -12,15 +12,15 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<link rel="stylesheet" href="{{ $reveal_cdn }}/css/reveal.min.css">
|
||||
<!-- Theme used for presentation -->
|
||||
{{ $theme := or .Page.Params.reveal_hugo.theme .Site.Params.reveal_hugo.theme .Site.Data.reveal_hugo.defaults.theme "black" }}
|
||||
{{ $custom_theme := or .Page.Params.reveal_hugo.custom_theme .Site.Params.reveal_hugo.custom_theme }}
|
||||
{{ if $custom_theme }}
|
||||
{{- $theme := or .Page.Params.reveal_hugo.theme .Site.Params.reveal_hugo.theme .Site.Data.reveal_hugo.defaults.theme "black" -}}
|
||||
{{- $custom_theme := or .Page.Params.reveal_hugo.custom_theme .Site.Params.reveal_hugo.custom_theme -}}
|
||||
{{- if $custom_theme -}}
|
||||
<link rel="stylesheet" href="{{ $custom_theme | relURL }}" id="theme">
|
||||
{{ else }}
|
||||
{{ else -}}
|
||||
<link rel="stylesheet" href="{{ $reveal_cdn }}/css/theme/{{ $theme }}.css" id="theme">
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
<!-- Theme used for syntax highlighting of code -->
|
||||
{{ $highlight_theme := or .Page.Params.reveal_hugo.highlight_theme .Site.Params.reveal_hugo.highlight_theme .Site.Data.reveal_hugo.defaults.highlight_theme "default" }}
|
||||
{{- $highlight_theme := or .Page.Params.reveal_hugo.highlight_theme .Site.Params.reveal_hugo.highlight_theme .Site.Data.reveal_hugo.defaults.highlight_theme "default" -}}
|
||||
<link rel="stylesheet" href="{{ $highlight_cdn }}/styles/{{ $highlight_theme }}.min.css">
|
||||
<!-- Printing and PDF exports -->
|
||||
<script>
|
||||
|
@ -33,10 +33,10 @@
|
|||
<!--[if lt IE 9]>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
|
||||
<![endif]-->
|
||||
{{ partial "reveal-hugo/head" . }}
|
||||
{{- partial "reveal-hugo/head" . -}}
|
||||
</head>
|
||||
<body>
|
||||
{{ block "main" . }}{{ end }}
|
||||
{{- block "main" . -}}{{- end -}}
|
||||
<script type="application/json" id="reveal-hugo-page-params">{{ jsonify .Page.Params.reveal_hugo | safeJS }}</script>
|
||||
<script type="application/json" id="reveal-hugo-site-params">{{ jsonify .Site.Params.reveal_hugo | safeJS }}</script>
|
||||
<script type="application/json" id="reveal-hugo-defaults">{{ jsonify .Site.Data.reveal_hugo.defaults | safeJS }}</script>
|
||||
|
@ -73,7 +73,6 @@
|
|||
var revealHugoPageParams = JSON.parse(document.getElementById('reveal-hugo-page-params').innerHTML);
|
||||
var revealHugoSiteParams = JSON.parse(document.getElementById('reveal-hugo-site-params').innerHTML);
|
||||
var revealHugoDefaults = JSON.parse(document.getElementById('reveal-hugo-defaults').innerHTML);
|
||||
|
||||
// See all options - https://github.com/hakimel/reveal.js#configuration
|
||||
var options = Object.assign({},
|
||||
camelize(revealHugoDefaults),
|
||||
|
@ -81,8 +80,8 @@
|
|||
camelize(revealHugoPageParams),
|
||||
revealHugoDependencies);
|
||||
Reveal.initialize(options);
|
||||
|
||||
</script>
|
||||
|
||||
{{ partial "reveal-hugo/body" . }}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
<!-- Don't process empty content files -->
|
||||
{{- if ne (len .Content) 0 -}}
|
||||
<!-- Remove the <hr /> tag generated by blackfriday for footnotes -->
|
||||
{{ $content := replace .Content "<div class=\"footnotes\">\n\n<hr />" "<div class=\"footnotes\">" }}
|
||||
{{- $content := replace .Content "<div class=\"footnotes\">\n\n<hr />" "<div class=\"footnotes\">" -}}
|
||||
<!-- Split the processed content by <hr /> tag -->
|
||||
{{- range (split $content "<hr />") -}}
|
||||
<!-- Only wrap in <section> tag if not already wrapped by shortcode -->
|
||||
{{- if in . "data-noprocess" -}}
|
||||
{{- . | safeHTML -}}
|
||||
{{- else -}}
|
||||
<section>
|
||||
{{- . | safeHTML -}}
|
||||
{{- else }}
|
||||
<section>
|
||||
{{- . | safeHTML }}
|
||||
</section>
|
||||
{{ end -}}
|
||||
</section>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
|
|
@ -1,26 +1,23 @@
|
|||
{{ .Scratch.Set "slides" slice }}
|
||||
|
||||
{{ if trim .Inner "\n" }}
|
||||
{{ .Scratch.Add "slides" .Inner }}
|
||||
{{ end }}
|
||||
|
||||
{{ if .Get "content" }}
|
||||
{{ $lookup := split (.Get "content") "." }}
|
||||
{{ $html := index .Page.Site.Data (index $lookup 0) (index $lookup 1) | markdownify }}
|
||||
{{ $slides := split $html "<hr />" }}
|
||||
{{ $scratch := .Scratch }}
|
||||
{{ range $slides }}
|
||||
{{ $scratch.Add "slides" . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ $attributes := slice "background-color" "background-image" "background-size" "background-position" "background-repeat" "transition" "transition-speed" "background-iframe" "background-interactive" "background-video" "background-video-loop" "background-video-muted" }}
|
||||
{{ $params := . }}
|
||||
{{ range .Scratch.Get "slides" }}
|
||||
{{- .Scratch.Set "slides" slice -}}
|
||||
{{- if trim .Inner "\n" -}}
|
||||
{{- .Scratch.Add "slides" .Inner -}}
|
||||
{{- end -}}
|
||||
{{- if .Get "content" -}}
|
||||
{{- $lookup := split (.Get "content") "." -}}
|
||||
{{- $html := index .Page.Site.Data (index $lookup 0) (index $lookup 1) | markdownify -}}
|
||||
{{- $slides := split $html "<hr />" -}}
|
||||
{{- $scratch := .Scratch -}}
|
||||
{{- range $slides -}}
|
||||
{{- $scratch.Add "slides" . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $attributes := slice "background-color" "background-image" "background-size" "background-position" "background-repeat" "transition" "transition-speed" "background-iframe" "background-interactive" "background-video" "background-video-loop" "background-video-muted" -}}
|
||||
{{- $params := . -}}
|
||||
{{- range .Scratch.Get "slides" -}}
|
||||
<section data-noprocess
|
||||
{{- range $attribute := $attributes -}}
|
||||
{{- with $params.Get $attribute }} data-{{ $attribute | safeHTMLAttr }}="{{ . }}"{{ end -}}
|
||||
{{- end -}}>
|
||||
{{ . | safeHTML }}
|
||||
</section>
|
||||
{{ end }}
|
||||
{{- end -}}
|
Loading…
Reference in New Issue