Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/web/components/markdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ import { getScrollOffsets, type Offsets } from "./scroll.ts";
const MARKDOWN_CONTAINER_ID = "markdown-container-id";
const MARKDOWN_ELEMENT_ID = "markdown-element-id";

const IMAGE_PREFIX = "/__github_preview__/image/";

const pantsdown = new Pantsdown({
renderer: {
relativeImageUrlPrefix: "/__github_preview__/image/",
relativeImageUrlPrefix: IMAGE_PREFIX,
absoluteImageUrlPrefix: IMAGE_PREFIX,
detailsTagDefaultOpen: true,
},
});
Expand Down Expand Up @@ -67,6 +70,11 @@ export const Markdown = ({ className }: { className: string }) => {
const text = message.lines.join("\n");
const markdown = fileExt === "md" ? text : "```" + (fileExt ?? "") + `\n${text}`;

const path = message.currentPath.slice(0, message.currentPath.lastIndexOf("/") + 1);
pantsdown.setConfig({
renderer: { relativeImageUrlPrefix: IMAGE_PREFIX + path },
});

const { html, javascript } = pantsdown.parse(markdown);

// We create a tempElement so we can post-process html before actually
Expand Down
4 changes: 2 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docs/FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ https://github.com/wallpants/github-preview.nvim/assets/47203170/a3b03aac-2cd9-4

Relative image sources (example: `![image](./docs/github.svg)`) are resolved and rendered if found.

Images outside of the root of the workspace will not be resolved.

If using _Single-file mode_, images at the same level as the file or deeper can be resolved, but images in parent directories will not be resolved.

## 📌 Single-file mode

When the plugin starts, it attempts to find a `.git` directory to identify a repository root.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"isbinaryfile": "6.0.0",
"mermaid": "^11.15.0",
"opener": "^1.5.2",
"pantsdown": "2.2.4",
"pantsdown": "2.2.6",
"react": "^19.2.6",
"react-dom": "^19.2.6",
"reconnecting-websocket": "^4.4.0",
Expand Down