diff --git a/se/se_epub.py b/se/se_epub.py index 4390a3cf..14e4c0f0 100644 --- a/se/se_epub.py +++ b/se/se_epub.py @@ -962,6 +962,15 @@ def generate_loi(self) -> str: if not has_block: entry = deepcopy(figcaption[0]) + if isinstance(entry, se.easy_xml.EasyXmlElement): + # Remove endnote references. + for noteref in entry.xpath("a[contains(@epub:type, 'noteref')]"): + noteref.remove() + + # For other links, keep only the contents. + for a in entry.xpath("a"): + a.unwrap() + a = se.easy_xml.EasyXmlElement("") a.set_attr("href", f"{file_path.name}#{figure_id}") diff --git a/tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-1.xhtml b/tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-1.xhtml index c8161528..31239fd7 100644 --- a/tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-1.xhtml +++ b/tests/draft_commands/build-loi/test-1/golden/src/epub/text/chapter-1.xhtml @@ -51,6 +51,16 @@ Alt is preferred over figcaption with block element.

Figure 9

+ +
+ +
Endnote references in figcaption are removed.8
+
+ +
+ +
Other hyperlinks are converted to text. See Chapter 2.
+
diff --git a/tests/draft_commands/build-loi/test-1/golden/src/epub/text/loi.xhtml b/tests/draft_commands/build-loi/test-1/golden/src/epub/text/loi.xhtml index bfbb59d0..0520f14c 100644 --- a/tests/draft_commands/build-loi/test-1/golden/src/epub/text/loi.xhtml +++ b/tests/draft_commands/build-loi/test-1/golden/src/epub/text/loi.xhtml @@ -50,6 +50,16 @@ Alt is preferred over figcaption with block element.

+
  • +

    + Endnote references in figcaption are removed. +

    +
  • +
  • +

    + Other hyperlinks are converted to text. See Chapter 2. +

    +
  • Unable to auto-generate LoI text for #f-0. diff --git a/tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-1.xhtml b/tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-1.xhtml index c8161528..31239fd7 100644 --- a/tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-1.xhtml +++ b/tests/draft_commands/build-loi/test-1/in/src/epub/text/chapter-1.xhtml @@ -51,6 +51,16 @@ Alt is preferred over figcaption with block element.

    Figure 9

    + +
    + +
    Endnote references in figcaption are removed.8
    +
    + +
    + +
    Other hyperlinks are converted to text. See Chapter 2.
    +