From a2696bfaf84fc1167373e0f7e3eb8f504520bb82 Mon Sep 17 00:00:00 2001 From: Guillaume Grossetie Date: Wed, 10 Jun 2020 17:59:37 +0200 Subject: [PATCH] Do not add the toc2 class if the document has no section --- app/js/converter.js | 1 + app/js/renderer.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/js/converter.js b/app/js/converter.js index 806a7f8b..b060f4bd 100644 --- a/app/js/converter.js +++ b/app/js/converter.js @@ -21,6 +21,7 @@ asciidoctor.browser.converter = (webExtension, Constants, Settings) => { title: doc.getDoctitle({ use_fallback: true }), doctype: doc.getDoctype(), attributes: { + hasSections: doc.hasSections(), tocPosition: doc.getAttribute('toc-position'), isSourceHighlighterEnabled: isSourceHighlighterEnabled(doc), isStemEnabled: isStemEnabled(doc), diff --git a/app/js/renderer.js b/app/js/renderer.js index d49f454c..0d4934d9 100644 --- a/app/js/renderer.js +++ b/app/js/renderer.js @@ -192,7 +192,7 @@ window.MathJax = { } updateContent(converterResponse.html) let tocClassNames = '' - if (attributes.tocPosition === 'left' || attributes.tocPosition === 'right') { + if (attributes.hasSections && (attributes.tocPosition === 'left' || attributes.tocPosition === 'right')) { tocClassNames = ` toc2 toc-${attributes.tocPosition}` const tocElement = document.getElementById('toc') if (tocElement !== null) {