Skip to content

Commit f5ede09

Browse files
bajrangCodergreptile-apps[bot]UnschooledGamer
authored
fix(markdown-preview): improve rendering and asset handling (#1966)
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Co-authored-by: Emmanuel Lobo <76094069+UnschooledGamer@users.noreply.github.com>
1 parent eef6d0a commit f5ede09

File tree

8 files changed

+2474
-95
lines changed

8 files changed

+2474
-95
lines changed

_typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ collapsable = "collapsable"
5252
styl = "styl"
5353
IZ = "IZ"
5454
shft = "shft"
55+
multline = "multline"

bun.lock

Lines changed: 257 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1262 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,15 @@
157157
"filesize": "^11.0.13",
158158
"html-tag-js": "^2.4.16",
159159
"jszip": "^3.10.1",
160+
"katex": "^0.16.39",
160161
"markdown-it": "^14.1.1",
161162
"markdown-it-anchor": "^9.2.0",
163+
"markdown-it-emoji": "^3.0.0",
162164
"markdown-it-footnote": "^4.0.0",
163165
"markdown-it-github-alerts": "^1.0.0",
164166
"markdown-it-task-lists": "^2.1.1",
167+
"markdown-it-texmath": "^1.0.0",
168+
"mermaid": "^11.13.0",
165169
"mime-types": "^3.0.1",
166170
"mustache": "^4.2.0",
167171
"picomatch": "^4.0.3",

src/lib/run.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import anchor from "markdown-it-anchor";
77
import MarkdownItGitHubAlerts from "markdown-it-github-alerts";
88
import mimeType from "mime-types";
99
import mustache from "mustache";
10+
import openMarkdownPreview from "pages/markdownPreview";
1011
import browser from "plugins/browser";
1112
import helpers from "utils/helpers";
1213
import Url from "utils/Url";
@@ -31,6 +32,15 @@ async function run(
3132
target = appSettings.value.previewMode,
3233
runFile = false,
3334
) {
35+
/** @type {EditorFile} */
36+
const activeFile = isConsole ? null : editorManager.activeFile;
37+
38+
if (!isConsole && Url.extname(activeFile?.filename || "") === ".md") {
39+
if (!(await activeFile?.canRun())) return;
40+
await openMarkdownPreview(activeFile);
41+
return;
42+
}
43+
3444
if (!isConsole && !runFile) {
3545
const { serverPort, previewPort, previewMode, disableCache, host } =
3646
appSettings.value;
@@ -46,8 +56,6 @@ async function run(
4656
}
4757
}
4858

49-
/** @type {EditorFile} */
50-
const activeFile = isConsole ? null : editorManager.activeFile;
5159
if (!isConsole && !(await activeFile?.canRun())) return;
5260

5361
if (!isConsole && !localStorage.__init_runPreview) {

0 commit comments

Comments
 (0)