Render reference links as superscripts and widen link/image/reference modals#87
Merged
ThisIs-Developer merged 6 commits intomainfrom May 6, 2026
Merged
Conversation
Agent-Logs-Url: https://github.com/ThisIs-Developer/Markdown-Viewer/sessions/99943a44-4124-43de-bc07-de65731f16a0 Co-authored-by: ThisIs-Developer <109382325+ThisIs-Developer@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ThisIs-Developer/Markdown-Viewer/sessions/99943a44-4124-43de-bc07-de65731f16a0 Co-authored-by: ThisIs-Developer <109382325+ThisIs-Developer@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ThisIs-Developer/Markdown-Viewer/sessions/99943a44-4124-43de-bc07-de65731f16a0 Co-authored-by: ThisIs-Developer <109382325+ThisIs-Developer@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ThisIs-Developer/Markdown-Viewer/sessions/99943a44-4124-43de-bc07-de65731f16a0 Co-authored-by: ThisIs-Developer <109382325+ThisIs-Developer@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ThisIs-Developer/Markdown-Viewer/sessions/99943a44-4124-43de-bc07-de65731f16a0 Co-authored-by: ThisIs-Developer <109382325+ThisIs-Developer@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ThisIs-Developer/Markdown-Viewer/sessions/99943a44-4124-43de-bc07-de65731f16a0 Co-authored-by: ThisIs-Developer <109382325+ThisIs-Developer@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
ThisIs-Developer
May 6, 2026 03:26
View session
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR improves how numeric Markdown reference links are rendered in the live preview (superscript-style markers, with reference definition lines removed), widens several modals, and updates preview sanitization to support blob: URLs so device-uploaded images render reliably.
Changes:
- Extract numeric reference definitions (
[n]: ...) from markdown prior to preview rendering and rewrite inline[n]markers into clickable superscript-style links. - Allow
blob:URLs through the preview sanitizer configuration to support locally uploaded images. - Increase modal width via a shared “wide” modal class and refine reference link typography.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| styles.css | Styles reference links as superscripts and increases the “wide modal” max width. |
| script.js | Extracts reference definitions, rewrites reference markers into links, and relaxes DOMPurify URI rules to allow blob:. |
| index.html | Applies the wide modal class to the reference and image modals. |
| desktop-app/resources/styles.css | Keeps desktop CSS in sync for reference link styling and modal widths. |
| desktop-app/resources/js/script.js | Keeps desktop JS in sync for reference parsing/linking and DOMPurify config. |
| desktop-app/resources/index.html | Keeps desktop HTML in sync for modal width changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1874
to
+1886
| const definitionRegex = /^\[(\d+)\]:\s*(?:<([^>\s]+)>|(\S+))(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]+)\)))?\s*$/gm; | ||
| const cleanedMarkdown = markdown.replace( | ||
| definitionRegex, | ||
| function(match, numberText, angleUrl, plainUrl, titleDouble, titleSingle, titleParen) { | ||
| const number = parseInt(numberText, 10); | ||
| if (Number.isNaN(number)) return match; | ||
| const url = (angleUrl || plainUrl || '').trim(); | ||
| if (!url) return match; | ||
| const title = titleDouble || titleSingle || titleParen || ''; | ||
| definitions.set(number, { url: url, title: title }); | ||
| return ''; | ||
| } | ||
| ); |
Comment on lines
+1873
to
+1875
| // Matches reference definitions: [1]: <url> "title", [1]: url 'title', or [1]: url (title) | ||
| const definitionRegex = /^\[(\d+)\]:\s*(?:<([^>\s]+)>|(\S+))(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]+)\)))?\s*$/gm; | ||
| const cleanedMarkdown = markdown.replace( |
Comment on lines
1931
to
+1943
| @@ -1891,10 +1938,50 @@ This is a fully client-side application. Your content never leaves your browser | |||
| const match = text.match(/^\[(\d+)\]$/); | |||
| if (match) number = parseInt(match[1], 10); | |||
| } | |||
| if (number && usedNumbers.has(number)) { | |||
| link.textContent = '[' + number + ']'; | |||
| link.classList.add('reference-link'); | |||
| if (number && referenceDefinitions.has(number)) { | |||
| applyReferenceStyle(link, number); | |||
| } | |||
Comment on lines
+1874
to
+1886
| const definitionRegex = /^\[(\d+)\]:\s*(?:<([^>\s]+)>|(\S+))(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]+)\)))?\s*$/gm; | ||
| const cleanedMarkdown = markdown.replace( | ||
| definitionRegex, | ||
| function(match, numberText, angleUrl, plainUrl, titleDouble, titleSingle, titleParen) { | ||
| const number = parseInt(numberText, 10); | ||
| if (Number.isNaN(number)) return match; | ||
| const url = (angleUrl || plainUrl || '').trim(); | ||
| if (!url) return match; | ||
| const title = titleDouble || titleSingle || titleParen || ''; | ||
| definitions.set(number, { url: url, title: title }); | ||
| return ''; | ||
| } | ||
| ); |
Comment on lines
+1873
to
+1875
| // Matches reference definitions: [1]: <url> "title", [1]: url 'title', or [1]: url (title) | ||
| const definitionRegex = /^\[(\d+)\]:\s*(?:<([^>\s]+)>|(\S+))(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]+)\)))?\s*$/gm; | ||
| const cleanedMarkdown = markdown.replace( |
Comment on lines
1931
to
+1943
| @@ -1891,10 +1938,50 @@ This is a fully client-side application. Your content never leaves your browser | |||
| const match = text.match(/^\[(\d+)\]$/); | |||
| if (match) number = parseInt(match[1], 10); | |||
| } | |||
| if (number && usedNumbers.has(number)) { | |||
| link.textContent = '[' + number + ']'; | |||
| link.classList.add('reference-link'); | |||
| if (number && referenceDefinitions.has(number)) { | |||
| applyReferenceStyle(link, number); | |||
| } | |||
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.
Preview rendering was showing reference definitions inline and not styling reference markers as small superscripts. Link/reference/image modals were too narrow, and uploaded images using blob URLs were not reliably rendered.
[n]: ...definitions from preview content and reuse them to rewrite inline[n]markers as clickable, superscript-style links.blob:URLs in preview to render device-uploaded images.Example (preview output for a reference definition):
Renders as a compact superscript-style
[1]link, without showing the definition line in preview.