diff --git a/layouts/partials/body.html b/layouts/partials/body.html
index 121f729b21..532fd516c1 100644
--- a/layouts/partials/body.html
+++ b/layouts/partials/body.html
@@ -1,3 +1,3 @@
{{- $page := .page }}
{{- $content := .content }}
-{{- partial "output-partial.html" (dict "base" "article" "page" $page "parameter" (dict "page" $page "content" $content)) }}
\ No newline at end of file
+{{- partial "single-article.html" (dict "page" $page "content" $content) }}
\ No newline at end of file
diff --git a/layouts/partials/body.print.html b/layouts/partials/body.print.html
index fe2147b8ea..869c997450 100644
--- a/layouts/partials/body.print.html
+++ b/layouts/partials/body.print.html
@@ -1,3 +1,3 @@
{{- $page := .page }}
{{- $content := .content }}
-{{- partial "nestedArticle.html" $page }}
\ No newline at end of file
+{{- partial "nested-article.html" (dict "page" $page) }}
\ No newline at end of file
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index 44844420b4..928c3810bd 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -7,7 +7,7 @@
-{{- $wantsMathJax := or (and (eq (.Scratch.Get "relearnOutputFormat") "HTML") (.Page.Store.Get "selfHasMathJax")) (and (eq (.Scratch.Get "relearnOutputFormat") "PRINT") (.Page.Store.Get "nestedHasMathJax")) }}
+{{- $wantsMathJax := or (.Page.Store.Get "selfHasMathJax") (and (.Page.Store.Get (printf "%sIsNested" ((.Scratch.Get "relearnOutputFormat") | lower))) (.Page.Store.Get "nestedHasMathJax")) }}
{{- if $wantsMathJax }}
{{- if isset .Params "mathjaxinitialize" }}
{{- $.Scratch.Set "mathJaxInitialize" .Params.mathJaxInitialize }}
@@ -48,7 +48,7 @@
{{- end }}
{{- end }}
-{{- $wantsMermaid := or (and (eq (.Scratch.Get "relearnOutputFormat") "HTML") (.Page.Store.Get "selfHasMermaid")) (and (eq (.Scratch.Get "relearnOutputFormat") "PRINT") (.Page.Store.Get "nestedHasMermaid")) }}
+{{- $wantsMermaid := or (.Page.Store.Get "selfHasMermaid") (and (.Page.Store.Get (printf "%sIsNested" ((.Scratch.Get "relearnOutputFormat") | lower))) (.Page.Store.Get "nestedHasMermaid")) }}
{{- if $wantsMermaid }}
{{- if isset .Params "custommermaidurl" }}
@@ -78,7 +78,7 @@
useMermaid( JSON.parse({{ $.Scratch.Get "mermaidInitialize" }}) );
{{- end }}
-{{- $wantsSwagger := or (and (eq (.Scratch.Get "relearnOutputFormat") "HTML") (.Page.Store.Get "selfHasSwagger")) (and (eq (.Scratch.Get "relearnOutputFormat") "PRINT") (.Page.Store.Get "nestedHasSwagger")) }}
+{{- $wantsSwagger := or (.Page.Store.Get "selfHasSwagger") (and (.Page.Store.Get (printf "%sIsNested" ((.Scratch.Get "relearnOutputFormat") | lower))) (.Page.Store.Get "nestedHasSwagger")) }}
{{- if $wantsSwagger }}
{{- if isset .Params "customswaggerurl" }}
diff --git a/layouts/partials/nestedArticle.html b/layouts/partials/nested-article.html
similarity index 51%
rename from layouts/partials/nestedArticle.html
rename to layouts/partials/nested-article.html
index 134e783180..55fcda8032 100644
--- a/layouts/partials/nestedArticle.html
+++ b/layouts/partials/nested-article.html
@@ -1,39 +1,43 @@
-{{- $currentNode := . }}
-{{- $isActive := .IsHome }}
-{{- $isShortcut := false }}
-{{- $r_url := .RelPermalink }}
-{{- with .Site.Menus.shortcuts }}
- {{- range sort . "Weight" }}
- {{- $s_url := .URL | relLangURL }}
- {{- if (eq $s_url $r_url) }}
- {{- $isShortcut = true }}
+{{- $page := .page }}
+{{- $page.Page.Store.Set (printf "%sIsNested" (($page.Scratch.Get "relearnOutputFormat") | lower)) true }}
+{{- with $page }}
+ {{- $currentNode := . }}
+ {{- $isActive := .IsHome }}
+ {{- $isShortcut := false }}
+ {{- $r_url := .RelPermalink }}
+ {{- with .Site.Menus.shortcuts }}
+ {{- range sort . "Weight" }}
+ {{- $s_url := .URL | relLangURL }}
+ {{- if (eq $s_url $r_url) }}
+ {{- $isShortcut = true }}
+ {{- end }}
{{- end }}
{{- end }}
-{{- end }}
-{{- $pages := .Site.Home.Sections }}
-{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
-{{- $currentOrdersectionsby := .Site.Home.Params.ordersectionsby | default $defaultOrdersectionsby }}
-{{- if $isShortcut }}
- {{- template "section-print" dict "sect" . "currentnode" $currentNode }}
-{{- else }}
- {{- if $isActive }}
+ {{- $pages := .Site.Home.Sections }}
+ {{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
+ {{- $currentOrdersectionsby := .Site.Home.Params.ordersectionsby | default $defaultOrdersectionsby }}
+ {{- if $isShortcut }}
{{- template "section-print" dict "sect" . "currentnode" $currentNode }}
- {{- if or $pages }}
-
- {{- end }}
- {{- end }}
- {{- if eq $currentOrdersectionsby "title" }}
- {{- range $pages.ByTitle }}
- {{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
- {{- end }}
{{- else }}
- {{- range $pages.ByWeight }}
- {{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
+ {{- if $isActive }}
+ {{- template "section-print" dict "sect" . "currentnode" $currentNode }}
+ {{- if or $pages }}
+
+ {{- end }}
{{- end }}
- {{- end }}
- {{- if $isActive }}
- {{- if $pages }}
-
+ {{- if eq $currentOrdersectionsby "title" }}
+ {{- range $pages.ByTitle }}
+ {{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
+ {{- end }}
+ {{- else }}
+ {{- range $pages.ByWeight }}
+ {{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
+ {{- end }}
+ {{- end }}
+ {{- if $isActive }}
+ {{- if $pages }}
+
+ {{- end }}
{{- end }}
{{- end }}
{{- end }}
@@ -87,13 +91,7 @@
{{- define "section-print" }}
{{- $currentNode := .currentnode }}
{{- with .sect }}
- {{- $currentNode.Page.Store.Set "nestedHasMathJax" (or ($currentNode.Page.Store.Get "nestedHasMathJax") (.Page.Store.Get "selfHasMathJax")) }}
- {{- $currentNode.Page.Store.Set "nestedHasMermaid" (or ($currentNode.Page.Store.Get "nestedHasMermaid") (.Page.Store.Get "selfHasMermaid")) }}
- {{- $currentNode.Page.Store.Set "nestedHasSwagger" (or ($currentNode.Page.Store.Get "nestedHasSwagger") (.Page.Store.Get "selfHasSwagger")) }}
- {{/* if we have a relative link in a print page, our print URL is one level to deep; so we are making it absolute to our page by prepending the page's permalink */}}
- {{- $link_prefix := strings.TrimRight "/" .Page.RelPermalink }}
{{- $content := partial "content.html" . }}
- {{- $content = replaceRE "((?:src|href)\\s*=(?:\\s*[\"']\\s*)?)(\\.[^\"'\\s>]*|[\\w]+[^\"'\\s>:]*)([\"'\\s>])" (printf "${1}%s/${2}${3}" $link_prefix) $content }}
- {{- partial "output-partial.html" (dict "base" "article" "page" . "parameter" (dict "page" . "content" $content)) }}
+ {{- partial "output-partial.html" (dict "base" "output-article" "page" . "parameter" (dict "page" . "content" $content)) }}
{{- end }}
{{- end }}
\ No newline at end of file
diff --git a/layouts/partials/output-article.html b/layouts/partials/output-article.html
new file mode 100644
index 0000000000..487c8ef566
--- /dev/null
+++ b/layouts/partials/output-article.html
@@ -0,0 +1,12 @@
+{{- $page := .page }}
+{{- $content := .content }}
+{{- $r_url := .RelPermalink }}
+{{- with $page.OutputFormats.Get (($page.Scratch.Get "relearnOutputFormat") | lower) }}
+ {{- $s_url := .RelPermalink }}
+ {{- if not (eq $s_url $r_url) }}
+ {{/* if we have a relative link in output formats with a path setting, our URLs are one level to deep; so we are making them absolute to our page by prepending the page's permalink */}}
+ {{- $link_prefix := strings.TrimRight "/" $page.Page.RelPermalink }}
+ {{- $content = replaceRE "((?:src|href)\\s*=(?:\\s*[\"']\\s*)?)(\\.[^\"'\\s>]*|[\\w]+[^\"'\\s>:]*)([\"'\\s>])" (printf "${1}%s/${2}${3}" $link_prefix) $content }}
+ {{- end }}
+{{- end }}
+{{- partial "output-partial.html" (dict "base" "article" "page" $page "parameter" (dict "page" $page "content" $content)) }}
\ No newline at end of file
diff --git a/layouts/partials/page-meta.hugo b/layouts/partials/page-meta.hugo
index b3d01279fb..75ca38a4dd 100644
--- a/layouts/partials/page-meta.hugo
+++ b/layouts/partials/page-meta.hugo
@@ -2,22 +2,9 @@
{{- $currentNode.Scratch.Delete "relearnIsSelfFound" }}
{{- $currentNode.Scratch.Delete "relearnPrevPage" }}
{{- $currentNode.Scratch.Delete "relearnNextPage" }}
-{{- $currentNode.Scratch.Delete "relearnSubPages" }}
{{- $currentNode.Scratch.Delete "relearnIsHiddenNode" }}{{/* the node itself is flagged as hidden */}}
{{- $currentNode.Scratch.Delete "relearnIsHiddenStem" }}{{/* the node or one of its parents is flagged as hidden */}}
{{- $currentNode.Scratch.Delete "relearnIsHiddenFrom" }}{{/* the node is hidden from the current page */}}
-{{- $wantsMathjax := or (and (ne $currentNode.Params.disableMathjax nil) (not $currentNode.Params.disableMathjax)) (and (ne .Site.Params.disableMathjax nil) (not .Site.Params.disableMathjax)) }}
-{{- if $wantsMathjax }}
- {{- $currentNode.Page.Store.Set "selfHasMathjax" true }}
-{{- end }}
-{{- $wantsMermaid := or (and (ne $currentNode.Params.disableMermaid nil) (not $currentNode.Params.disableMermaid)) (and (ne .Site.Params.disableMermaid nil) (not .Site.Params.disableMermaid)) }}
-{{- if $wantsMermaid }}
- {{- $currentNode.Page.Store.Set "selfHasMermaid" true }}
-{{- end }}
-{{- $wantsSwagger := or (and (ne .Params.disableSwagger nil) (not .Params.disableSwagger)) (and (ne .Site.Params.disableSwagger nil) (not .Site.Params.disableSwagger)) }}
-{{- if $wantsSwagger }}
- {{- $currentNode.Page.Store.Set "selfHasSwagger" true }}
-{{- end }}
{{- template "relearn-structure" dict "node" .Site.Home "currentnode" $currentNode "hiddenstem" false "hiddencurrent" false "defaultOrdersectionsby" .Site.Params.ordersectionsby }}
{{- define "relearn-structure" }}
{{- $currentNode := .currentnode }}
@@ -26,6 +13,7 @@
{{- $isAncestor := and (not $isSelf) (.node.IsAncestor $currentNode) }}
{{- $isOther := and (not $isDescendant) (not $isSelf) (not $isAncestor) }}
+ {{- $isChildren := and (.node.Parent) (eq $currentNode.RelPermalink .node.Parent.RelPermalink) }}
{{- if $isSelf }}
{{- $currentNode.Scratch.Set "relearnIsSelfFound" true }}
{{- end}}
@@ -49,24 +37,32 @@
{{- end}}
{{- end }}
- {{- $currentNode.Scratch.Set "relearnSubPages" .node.Pages }}
+ {{- $pages := .node.Pages }}
{{- if .node.IsHome }}
- {{- $currentNode.Scratch.Set "relearnSubPages" .node.Sections }}
+ {{- $pages = .node.Sections }}
{{- else if .node.Sections }}
- {{- $currentNode.Scratch.Set "relearnSubPages" (.node.Pages | union .node.Sections) }}
+ {{- $pages = (.node.Pages | union .node.Sections) }}
{{- end }}
- {{- $pages := ($currentNode.Scratch.Get "relearnSubPages") }}
-
{{- $defaultOrdersectionsby := .defaultOrdersectionsby }}
{{- $currentOrdersectionsby := .node.Params.ordersectionsby | default $defaultOrdersectionsby }}
-
{{- if eq $currentOrdersectionsby "title"}}
- {{- range $pages.ByTitle }}
- {{- template "relearn-structure" dict "node" . "currentnode" $currentNode "hiddenstem" $hidden_stem "hiddencurrent" $hidden_from_current "defaultOrdersectionsby" $defaultOrdersectionsby }}
- {{- end}}
+ {{- $pages := $pages.ByTitle }}
{{- else}}
- {{- range $pages.ByWeight }}
- {{- template "relearn-structure" dict "node" . "currentnode" $currentNode "hiddenstem" $hidden_stem "hiddencurrent" $hidden_from_current "defaultOrdersectionsby" $defaultOrdersectionsby }}
- {{- end}}
+ {{- $pages := $pages.ByWeight }}
+ {{- end }}
+ {{- range $pages }}
+ {{- template "relearn-structure" dict "node" . "currentnode" $currentNode "hiddenstem" $hidden_stem "hiddencurrent" $hidden_from_current "defaultOrdersectionsby" $defaultOrdersectionsby }}
+ {{- end}}
+
+ {{- if $isSelf }}
+ {{- $currentNode.Page.Store.Set "selfHasMathjax" (or ($currentNode.Page.Store.Get "selfHasMathJax") (and (ne $currentNode.Params.disableMathjax nil) (not $currentNode.Params.disableMathjax)) (and (ne .Site.Params.disableMathjax nil) (not .Site.Params.disableMathjax))) }}
+ {{- $currentNode.Page.Store.Set "selfHasMermaid" (or ($currentNode.Page.Store.Get "selfHasMermaid") (and (ne $currentNode.Params.disableMermaid nil) (not $currentNode.Params.disableMermaid)) (and (ne .Site.Params.disableMermaid nil) (not .Site.Params.disableMermaid))) }}
+ {{- $currentNode.Page.Store.Set "selfHasSwagger" (or ($currentNode.Page.Store.Get "selfHasSwagger") (and (ne $currentNode.Params.disableSwagger nil) (not $currentNode.Params.disableSwagger)) (and (ne .Site.Params.disableSwagger nil) (not .Site.Params.disableSwagger))) }}
+ {{- end }}
+
+ {{- if $isChildren }}
+ {{- $currentNode.Page.Store.Set "nestedHasMathJax" (or ($currentNode.Page.Store.Get "nestedHasMathJax") (.node.Page.Store.Get "selfHasMathJax") (.node.Page.Store.Get "nestedfHasMathJax")) }}
+ {{- $currentNode.Page.Store.Set "nestedHasMermaid" (or ($currentNode.Page.Store.Get "nestedHasMermaid") (.node.Page.Store.Get "selfHasMermaid") (.node.Page.Store.Get "nestedfHasMermaid")) }}
+ {{- $currentNode.Page.Store.Set "nestedHasSwagger" (or ($currentNode.Page.Store.Get "nestedHasSwagger") (.node.Page.Store.Get "selfHasSwagger") (.node.Page.Store.Get "nestedHasSwagger")) }}
{{- end }}
{{- end }}
\ No newline at end of file
diff --git a/layouts/partials/single-article.html b/layouts/partials/single-article.html
new file mode 100644
index 0000000000..a892bdc5ab
--- /dev/null
+++ b/layouts/partials/single-article.html
@@ -0,0 +1,4 @@
+{{- $page := .page }}
+{{- $content := .content }}
+{{- $page.Page.Store.Set (printf "%sIsNested" (($page.Scratch.Get "relearnOutputFormat") | lower)) false }}
+{{- partial "output-partial.html" (dict "base" "output-article" "page" $page "parameter" (dict "page" $page "content" $content)) }}
\ No newline at end of file