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