From 952a4daa66175f782ea68295359d8681b1b99f63 Mon Sep 17 00:00:00 2001 From: Andy Jackson Date: Wed, 3 May 2023 13:05:56 +0100 Subject: [PATCH] Support section elements as well as div.section --- sphinx_comments/__init__.py | 4 ++-- tests/test_comments/utterances.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sphinx_comments/__init__.py b/sphinx_comments/__init__.py index 9faeff1..42a774b 100644 --- a/sphinx_comments/__init__.py +++ b/sphinx_comments/__init__.py @@ -77,8 +77,8 @@ def activate_comments(app, config): script.setAttribute("label", "{label}"); script.setAttribute("crossorigin", "{crossorigin}"); - sections = document.querySelectorAll("div.section"); - if (sections !== null) {{ + sections = document.querySelectorAll("div.section,section"); + if (sections !== null && sections.length > 0) {{ section = sections[sections.length-1]; section.appendChild(script); }} diff --git a/tests/test_comments/utterances.html b/tests/test_comments/utterances.html index af5ae70..1ab7e05 100644 --- a/tests/test_comments/utterances.html +++ b/tests/test_comments/utterances.html @@ -23,8 +23,8 @@ script.setAttribute("label", "💬 comment"); script.setAttribute("crossorigin", "anonymous"); - sections = document.querySelectorAll("div.section"); - if (sections !== null) { + sections = document.querySelectorAll("div.section,section"); + if (sections !== null && sections.length > 0) { section = sections[sections.length-1]; section.appendChild(script); }