diff --git a/epub2md/html_converter.py b/epub2md/html_converter.py index f77f94c..910402a 100644 --- a/epub2md/html_converter.py +++ b/epub2md/html_converter.py @@ -936,6 +936,9 @@ class Renderer: blocks = self.render_note(note) or ["(leer)"] body = "\n\n".join(blocks) if note.label in self.md_ref_labels: + if f"{self.file}:{note.label}" in self.note_refs: + # also referenced from an HTML table (): give that link a target + body = f'' + body out.append(indent_block(body, f"[^{note.label}]: ", " ")) else: num = int(note.label.split("-")[1]) diff --git a/tests/test_qa_regressions.py b/tests/test_qa_regressions.py index fc52114..dfcbac0 100644 --- a/tests/test_qa_regressions.py +++ b/tests/test_qa_regressions.py @@ -59,3 +59,18 @@ def test_backlink_after_code_block_does_not_break_fence_end_of_book(convert): assert _fences_closed(notes), notes assert not re.search(r"\*\*\d+[:.]\*\* ```", notes), "Fence hinter Notennummer ist kein Codeblock" assert "[↩](001-k.md#fnref-001)" in notes + + +NOTE_IN_HTML_TABLE = ('
| Zelle1 | |
| a | b |
Text1.
' + '') + + +def test_note_referenced_from_html_table_and_text_has_target(convert): + """QA2-03: GFM: the HTML-table reference pointed to #fn-001, but only a [^fn-001] definition existed.""" + run = convert(Book(docs=[Doc("c.xhtml", NOTE_IN_HTML_TABLE)])) + text = run.chapter("001") + assert 'href="#fn-001"' in text and "Text[^fn-001]." in text + assert re.search(r'id="fn-001"', text), text + assert run.report["output_link_check"]["broken_count"] == 0