# Epub output errors in new 3.4. release

**URL:** <https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562>\
**Category:** Scrivener for macOS\
**Tags:** bug, compile, ebooks\
**Created:** [December 12, 2024, 11:08am UTC](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562 "2024-12-12T11:08:34Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ds](https://forum.literatureandlatte.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@ds](https://forum.literatureandlatte.com/u/ds)\
**Post date:** [December 12, 2024, 11:08am UTC](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562/1 "2024-12-12T11:08:35Z")

</div>

I’m getting the following error when I open the epub created by the new 3.4 release in Sigil:

 ![image](https://forum.literatureandlatte.com/uploads/default/original/3X/f/8/f8a59815f0efd832bbbd7a3c805360305ad70adc.png)

Here is the offending HTML in body30.xhtml:

```nohighlight
<p class="ps15">Perhaps the decision to delegate the search for serialization deals was due to the rejection by the American Nature Association in the previous letter. Subsequent correspondence does reveal that there was one successful serialization deal.<a href="footnotes.xhtml#fn48" class="fn-marker" id="fn48">48</a></div></p>

```

The error Sigil reports is “Opening and ending tag mismatch: p line 26 and div”. There does indeed seem to be a stranded div end tag.

Looking at the other offending file, I find in both cases the problem is the last paragraph in the file and both end with a footnote–perhaps a clue. Here is the end chunk of the other file:

```nohighlight
<p class="ps11">Major Wood had placed Grey Owl at Lake Ajawaan in 1931 and had Beaver Lodge built to meet his specifications. Wood later defended him when officials in Ottawa raised doubts about the value of retaining his services. He was with Grey Owl when he died on 13 April 1938, reporting &quot;At 8.25 in the morning, he died very quietly, and pictures taken show that the congestion in his lungs [pneumonia] was very slight, which all goes to prove that he had absolutely no resistance whatever.&quot; After Grey Owl’s death, Wood was one of the diehards that refused to believe the allegations against him for some time. After finally giving in, Wood wrote “I care not whether he was an Englishman, Irishman, Scotsman or Negro. He was a great man with a great mind, and with great objectives which he ever kept before him.”<a href="footnotes.xhtml#fn82" class="fn-marker" id="fn82">82</a></div></p>

</body>
</html>

```

---

<div class="post-metadata">

**Author:** ![AmberV](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/amberv/32/13021_2.png) [@AmberV](https://forum.literatureandlatte.com/u/AmberV)\
**Post date:** [December 12, 2024, 4:22pm UTC](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562/2 "2024-12-12T16:22:36Z")

</div>

Can you spot any other ingredients in the mix that might be involved? I’ve run a quick check of both footnote types (inline/linked), positioned as the final text in a section, and do not run into any HTML containment errors like you demonstrate here.

This is my test project, maybe give that a look and see what I’d need to do to modify it to reproduce the bug, or send a snippet copy of your own project (you can DM me that to keep it out of the public forum, by clicking on my avatar and then the Message button). All I would need is one chunk in the binder that shows it happening, so a stripped down Save As copy of the project is fine, and would keep the project and compile settings intact.

[final\_footnote\_bug.zip](https://forum.literatureandlatte.com/uploads/short-url/seSzUHNs4y1eVWJOApicpXqXF3P.zip) (28.5 KB)

This almost certainly is a side-effect of a fix we made to footnotes in 3.4, that resolved cases where empty lines in footnotes would end up printing those lines into the source text where the footnote came from, breaking paragraphs in half and so forth. So code that is stripping newlines _might_ be a factor here if too much is being stripped in some scenarios.

* * *

Oh wait, I did just notice there is a problem with the final paragraph. It’s not a validity level problem according to ePubCheck and Sigil, but it isn’t good form. Basically the last paragraph is not a paragraph (`<p>...</p>`). So we should fix that, but it would be nice to have your condition in on the ticket as well, as they are undoubtedly related.

---

<div class="post-metadata">

**Author:** ![ds](https://forum.literatureandlatte.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@ds](https://forum.literatureandlatte.com/u/ds)\
**Post date:** [February 5, 2025, 11:12am UTC](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562/3 "2025-02-05T11:12:45Z")

</div>

Is a release with a fix on the horizon?

---

<div class="post-metadata">

**Author:** ![AmberV](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/amberv/32/13021_2.png) [@AmberV](https://forum.literatureandlatte.com/u/AmberV)\
**Post date:** [February 5, 2025, 11:46am UTC](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562/4 "2025-02-05T11:46:54Z")

</div>

To reiterate, the problem I found is a minor issue that won’t throw a validity error in the checks I’ve tried. I have logged it, but I still do not know how to reproduce the problem you described.

---

<div class="post-metadata">

**Author:** ![ds](https://forum.literatureandlatte.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@ds](https://forum.literatureandlatte.com/u/ds)\
**Post date:** [February 5, 2025, 12:11pm UTC](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562/5 "2025-02-05T12:11:31Z")

</div>

Sigil error reports:

 ![image](https://forum.literatureandlatte.com/uploads/default/original/3X/8/f/8f3b34b7ee14191f8d8b8ee5f56d18bbd7a3f771.jpeg)  
 ![image](https://forum.literatureandlatte.com/uploads/default/original/3X/6/3/63da915d2c85c528931906b982031e822f1dbed5.png)

---

<div class="post-metadata">

**Author:** ![ds](https://forum.literatureandlatte.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@ds](https://forum.literatureandlatte.com/u/ds)\
**Post date:** [February 5, 2025, 12:14pm UTC](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562/6 "2025-02-05T12:14:12Z")

</div>

I already identified the root cause: a footnote appearing as the last element in the document.

```nohighlight
<a href="footnotes.xhtml#fn101" class="fn-marker" id="fn101">101</a></div></p>

```

The p and the div need to be swapped. Here is Sigil’s fix:

```nohighlight
<a href="footnotes.xhtml#fn101" class="fn-marker" id="fn101">101</a></p>
</div>

```

---

<div class="post-metadata">

**Author:** ![AmberV](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/amberv/32/13021_2.png) [@AmberV](https://forum.literatureandlatte.com/u/AmberV)\
**Post date:** [February 5, 2025, 12:22pm UTC](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562/7 "2025-02-05T12:22:25Z")

</div>

Yes, I did see the result you posted before, but again, I don’t know how to get that result. Please read [my earlier post](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562/2), which outlines precisely what I found, and requests further information on how to reproduce what you saw.

---

<div class="post-metadata">

**Author:** ![ds](https://forum.literatureandlatte.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@ds](https://forum.literatureandlatte.com/u/ds)\
**Post date:** [February 5, 2025, 4:37pm UTC](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562/8 "2025-02-05T16:37:18Z")

</div>

Steps to reproduce:

- Open Scrivener.
- File \> New Project \> Non-fiction \> General Nonfiction.
- In Forward, type “test”.
- Insert \> Footnote, type test.
- Compile for epub.
- Open file in Sigil.

Result:

 ![image](https://forum.literatureandlatte.com/uploads/default/original/3X/d/e/de41fc6662fad624116b2ec37a8fd4af78ffcf01.jpeg)

---

<div class="post-metadata">

**Author:** ![AmberV](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/amberv/32/13021_2.png) [@AmberV](https://forum.literatureandlatte.com/u/AmberV)\
**Post date:** [February 5, 2025, 7:15pm UTC](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562/9 "2025-02-05T19:15:17Z")

</div>

Very strange, I get a different result from you. Here is the test I created using this checklist\[1\]:  
[footnote\_error.zip](https://forum.literatureandlatte.com/uploads/short-url/ujzOadWwyXpYd8TMMKJfi4IeESs.zip) (267.2 KB)

What version of macOS are you using?

* * *

1. The only differences were clearing out the unnecessary binder clutter and setting automatic backups off, but only after creating the ePub with it.

---

<div class="post-metadata">

**Author:** ![MimeticMouton](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/mimeticmouton/32/34_2.png) [@MimeticMouton](https://forum.literatureandlatte.com/u/MimeticMouton)\
**Post date:** [February 5, 2025, 7:58pm UTC](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562/10 "2025-02-05T19:58:51Z")

</div>

@AmberV OK, I can reproduce it (macOS 15.3) with your test project by applying a paragraph style (I used “Centered Text”) to the footnoted text. Just compiling the “Forward” document alone is sufficient; the combination seems to be the div coming from the section layout and the paragraph style at the end, which then does wrap the last paragraph in the `<p>` tag for the class, and that lands in the wrong place for the closing `</div>` when there’s also a footnote at the end.

---

<div class="post-metadata">

**Author:** ![AmberV](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/amberv/32/13021_2.png) [@AmberV](https://forum.literatureandlatte.com/u/AmberV)\
**Post date:** [February 5, 2025, 8:11pm UTC](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562/11 "2025-02-05T20:11:40Z")

</div>

Adding that step works for me as well, thanks!

To make sure there isn’t another route to the bug:

- Is using a styled paragraph something you were doing as well, @ds?
- To reduce the chance of default formatting settings containing a trigger:
  1. Go into `Project ▸ Project Settings...` under Formatting, and enable the **Use different default formatting for new documents in this project** setting. Leave the formatting itself as provided, by the template.
  2. Click OK, and use the `Documents ▸ Convert ▸ Text to Default Formatting...` menu command in the “Foreward” section (all checkboxes disabled).
  3. Compile again with these settings.

* * *

For example, it looks like other conditions that might cause the final paragraph to be handled manually, can cause it. Normal paragraphs just get `<p>...</p>`, and Scrivener doesn’t really do much itself about them. But a styled paragraph gets `<p class="centered">...</p>`, for example. A paragraph with unusual alignment (like justification) might get `<p class="ps2">...</p>`.

---

<div class="post-metadata">

**Author:** ![ds](https://forum.literatureandlatte.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@ds](https://forum.literatureandlatte.com/u/ds)\
**Post date:** [February 5, 2025, 8:59pm UTC](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562/12 "2025-02-05T20:59:53Z")

</div>

The problem can’t be due to any customizations in my project, because the steps I took to reproduce the problem use a new project with an unchanged project format.

---

<div class="post-metadata">

**Author:** ![AmberV](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/amberv/32/13021_2.png) [@AmberV](https://forum.literatureandlatte.com/u/AmberV)\
**Post date:** [February 5, 2025, 9:15pm UTC](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562/13 "2025-02-05T21:15:41Z")

</div>

Right, but your default formatting settings might be different from mine, which is a variable that most any new project will exhibit (especially our default templates, which leave the project setting disabled on purpose so that your defaults will always carry through). Changing the project to use its own formatting, and resetting the formatting to something we would both be using, would help illuminate whether something in your settings is causing it. If so, we could then take a look at what might do so.

To go back to your original report, where the opening `<p>` element is given, we do see a serial CSS class being applied to the paragraph, which is where I’m coming from with this. That would _typically_ only happen if the final paragraph has some special formatting applied to it that makes it different from other paragraphs in the section, but that kind of action would stand out as a necessary ingredient. So perhaps some form of formatting that can be applied globally via default settings is triggering that condition when it shouldn’t (and that would in and of itself probably be a different bug).

---

<div class="post-metadata">

**Author:** ![ds](https://forum.literatureandlatte.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@ds](https://forum.literatureandlatte.com/u/ds)\
**Post date:** [February 6, 2025, 8:07am UTC](https://forum.literatureandlatte.com/t/epub-output-errors-in-new-3-4-release/144562/15 "2025-02-06T08:07:33Z")

</div>

Simply adding a space or line break after the footnote anchor works around the problem:  
 ![image](https://forum.literatureandlatte.com/uploads/default/original/3X/f/a/fa94e88246493419feeb0e3fbab57263c3f27bfc.png)
