Update the browser, editor, settings, and installer
This commit is contained in:
@@ -3,8 +3,10 @@ import type { Token } from "markdown-it";
|
||||
import { inlineMathEnd } from "./inlineMath.ts";
|
||||
import { pluginHost } from "../plugins/registry.ts";
|
||||
import { hasTableDelimiter } from "../editor/markdownTable.ts";
|
||||
import { footnotes, renderFootnotes, type FootnoteEnvironment } from "../editor/footnotes.ts";
|
||||
|
||||
const markdown = new MarkdownIt({ html: false, linkify: true, breaks: false });
|
||||
markdown.use(footnotes);
|
||||
export const escapeHtml = markdown.utils.escapeHtml;
|
||||
|
||||
// Require a row delimiter so deleting a blank line cannot turn prose into cells.
|
||||
@@ -181,14 +183,17 @@ export function markdownImages(contents: string): string[] {
|
||||
if (token.children) visit(token.children);
|
||||
}
|
||||
}
|
||||
visit(markdown.parse(documentParts(contents).body, {}));
|
||||
const env: FootnoteEnvironment = {};
|
||||
visit(markdown.parse(documentParts(contents).body, env));
|
||||
for (const note of env.noteFootnotes?.values() ?? []) visit(note.tokens);
|
||||
return [...paths];
|
||||
}
|
||||
|
||||
export function renderMarkdownHtml(contents: string, urls: Map<string, string>): string {
|
||||
const { body, properties } = documentParts(contents);
|
||||
const metadata = properties ? `<details class="md-properties"><summary>Properties</summary><pre>${escapeHtml(properties)}</pre></details>\n` : "";
|
||||
return metadata + markdown.render(body, { urls });
|
||||
const env = { urls };
|
||||
return metadata + markdown.render(body, env) + renderFootnotes(markdown, env);
|
||||
}
|
||||
|
||||
export type MarkdownSection = { start: number; end: number; html: string };
|
||||
|
||||
Reference in New Issue
Block a user