From 98a1b921e3f79f5c807599aaf47165d4a36d7f3f Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Thu, 2 Jun 2022 08:46:26 -0700
Subject: [PATCH] HTML writer: fix bug with `--number-offset`.

This formerly caused section divs to be produced, even
when `--section-divs` was not specified.  Closes #8097.
---
 src/Text/Pandoc/Writers/HTML.hs | 2 ++
 test/command/8097.md            | 9 +++++++++
 2 files changed, 11 insertions(+)
 create mode 100644 test/command/8097.md

diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 59196a27a..769df7b0e 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -743,6 +743,8 @@ adjustNumbers opts doc =
      then doc
      else walk go doc
   where
+   go (Div (ident,"section":classes,kvs) lst) =
+     Div (ident,"section":classes,map fixnum kvs) lst
    go (Header level (ident,classes,kvs) lst) =
      Header level (ident,classes,map fixnum kvs) lst
    go x = x
diff --git a/test/command/8097.md b/test/command/8097.md
new file mode 100644
index 000000000..fa7089099
--- /dev/null
+++ b/test/command/8097.md
@@ -0,0 +1,9 @@
+```
+% pandoc --number-sec --number-offset=2 --wrap=none
+# One
+
+# two
+^D
+<h1 data-number="3" id="one"><span class="header-section-number">3</span> One</h1>
+<h1 data-number="4" id="two"><span class="header-section-number">4</span> two</h1>
+```