Repository navigation
Description
Leftovers from #1879 (PR #1911): minor review findings and plan items deferred by the loop.
- r1-pre1 (minor, review r1,
docxcore/src/markdown.rs:333): Markdown export: escape hyperlink destinations (spaces, parentheses) - plan-p1 (minor, plan v2 out of scope): Html import: bookmarks for and id targets of anchor links
- plan-p2 (minor, plan v2 out of scope): HTML import: Hyperlink character style on imported links
- plan-p3 (minor, plan v2 out of scope): HTML import: resolve relative links against
- plan-p4 (minor, plan v2 out of scope): HTML import: link title/target and hyperlinked pictures
r1-pre1
The Markdown export (docxcore/src/markdown.rs, inlines_to_md, ~line 333) writes a hyperlink as
format!("[{inner}]({url})") with the target or #anchor unescaped. A destination with a space
(an anchor my section, as HTML import's link_of percent-decodes href="#my%20section") is not
read as a link by CommonMark, and a URL with an unbalanced ) (https://x.test/a)b) is cut at the
first ). RTF, PDF and docx writers escape their output; Markdown does not.
Fix: wrap the destination in <…> (escaping </>), or percent-encode space and parentheses
there. Pre-existing; found by revmux round 1 of #1879 (HTML import links), which adds a new source
of such targets.
plan-p1
HTML import (#1879) makes href="#name" an anchor link (w:anchor), but nothing makes the
bookmark it names: <a name="x"> and elements with id="x" are not imported as bookmarks, so an
imported anchor link jumps nowhere. Needs a bookmark-name mapping shared by link anchors and
bookmarks (Word's rule: at most 40 characters, starting with a letter, no spaces), written as
w:bookmarkStart/w:bookmarkEnd. See docs/claude/html-import.md, "HTML import links (#1879)",
Known limits.
plan-p2
Imported HTML links (#1879) carry their look as direct formatting (underline, colour 0563C1) because
the Markdown package HtmlImport::package builds defines no Hyperlink character style. Word's own
HTML import applies w:rStyle="Hyperlink". Defining the style in the package and using it (with the
page's CSS still overriding) would match Word. See docs/claude/html-import.md, links section.
plan-p3
HTML import (#1879) leaves relative hrefs (page.html, /x, //host/x) as plain text, since
there is no base to resolve them against. Honour <base href> (and, for a page opened from disk,
perhaps the page's own URL) to resolve them into absolute allowed-scheme links.
Activity