Skip to content

Commit

Permalink
fix: markdown linking to head issue(#1053)
Browse files Browse the repository at this point in the history
  • Loading branch information
bajrangCoder committed Oct 20, 2024
1 parent c88c85f commit 1b18580
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"js-base64": "^3.7.7",
"jszip": "^3.10.1",
"markdown-it": "^14.1.0",
"markdown-it-anchor": "^9.2.0",
"mime-types": "^2.1.35",
"minimatch": "^9.0.4",
"mustache": "^4.2.0",
Expand Down
13 changes: 10 additions & 3 deletions src/lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import alert from "dialogs/alert";
import box from "dialogs/box";
import fsOperation from "fileSystem";
import markdownIt from "markdown-it";
import anchor from "markdown-it-anchor";
import mimeType from "mime-types";
import mustache from "mustache";
import browser from "plugins/browser";
Expand Down Expand Up @@ -266,9 +267,15 @@ async function run(

case ".md":
if (file) {
const html = markdownIt({ html: true }).render(
file.session.getValue(),
);
const html = markdownIt({ html: true })
.use(anchor, {
slugify: (s) =>
s
.trim()
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-"),
})
.render(file.session.getValue());
const doc = mustache.render($_markdown, {
html,
filename,
Expand Down

0 comments on commit 1b18580

Please sign in to comment.