Open
Conversation
Markdown image references like  produce <img src="graphs/foo.svg"> in the HTML output. In multi-page mode, the <base> tag causes the browser to resolve these relative URLs from the site root instead of the page's directory, resulting in broken image links. Fix: - Html.relativize now detects <img> tags with relative src attributes and prefixes them with the current page path - relativizeLinks accepts the page Path instead of hardcoding #[] - All three call sites pass the actual page path
Replaces complex path relativization logic with simple leading slash removal for absolute URLs. Since the base tag already points to the site root, root-relative paths resolve correctly without needing traversal sequences. Reorders attribute processing to handle image source prefixing before general URL rewriting. This ensures originally-relative paths can still be distinguished from originally-absolute paths, allowing correct prefixing of user-authored image references.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #834
Problem
Two classes of URLs are broken in multi-page HTML output:
) resolve from the site root instead of the page directory, because<base href="./../../">shifts resolution./-verso-data/katex/...) are converted bypath.relativizeto../../-verso-data/..., which overshoots the root when combined with the<base>tag.Changes
VersoManual/Html.leanrwAttr: Replacepath.relativizewith simple/-stripping ((attr.snd.drop 1).toString). Since<base>already points to the site root, root-relative paths resolve correctly without../sequences.rwTag: For<img>tags with relativesrcpaths, prefix with the page path before callingrwAttr. This distinguishes user-authored relative URLs (need page-path prefix) from absolute URLs (just need/stripped). AddsisRelativeContentUrlhelper.VersoManual.leanrelativizeLinks: Now accepts aPathparameter and passes it toHtml.relativize, so the page path is available for image URL adjustment.emitFindHtml(#["find"]), single-page emitter, andemitPart.Result
graphs/foo.svgon pageVerification/Key-Theorems/)src="graphs/foo.svg"→ resolves to{root}/graphs/foo.svg(404)src="Verification/Key-Theorems/graphs/foo.svg"→ correctsrc="../../-verso-data/katex/katex.js"→ overshoots root (404)src="-verso-data/katex/katex.js"→ correcthref="../../Overview/"→ correctbook.css,-verso-search/*)