mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-10-28 02:31:38 +08:00
feat(docs-edit): don't include HTML wrappers
This commit is contained in:
parent
9c0c1bad2d
commit
460014e54f
@ -99,6 +99,7 @@ async function exportData(noteId: string, format: "html" | "markdown", outputPat
|
|||||||
|
|
||||||
const exportOpts: AdvancedExportOptions = {};
|
const exportOpts: AdvancedExportOptions = {};
|
||||||
if (format === "html") {
|
if (format === "html") {
|
||||||
|
exportOpts.skipHtmlTemplate = true;
|
||||||
exportOpts.customRewriteLinks = (originalRewriteLinks, getNoteTargetUrl) => {
|
exportOpts.customRewriteLinks = (originalRewriteLinks, getNoteTargetUrl) => {
|
||||||
return (content: string, noteMeta: NoteMeta) => {
|
return (content: string, noteMeta: NoteMeta) => {
|
||||||
content = content.replace(/src="[^"]*api\/images\/([a-zA-Z0-9_]+)\/[^"]*"/g, (match, targetNoteId) => {
|
content = content.replace(/src="[^"]*api\/images\/([a-zA-Z0-9_]+)\/[^"]*"/g, (match, targetNoteId) => {
|
||||||
|
|||||||
@ -26,6 +26,11 @@ import type { NoteMetaFile } from "../meta/note_meta.js";
|
|||||||
type RewriteLinksFn = (content: string, noteMeta: NoteMeta) => string;
|
type RewriteLinksFn = (content: string, noteMeta: NoteMeta) => string;
|
||||||
|
|
||||||
export interface AdvancedExportOptions {
|
export interface AdvancedExportOptions {
|
||||||
|
/**
|
||||||
|
* If `true`, then only the note's content will be kept. If `false` (default), then each page will have its own <html> template.
|
||||||
|
*/
|
||||||
|
skipHtmlTemplate?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a custom function to rewrite the links found in HTML or Markdown notes. This method is called for every note imported, if it's of the right type.
|
* Provides a custom function to rewrite the links found in HTML or Markdown notes. This method is called for every note imported, if it's of the right type.
|
||||||
*
|
*
|
||||||
@ -316,7 +321,7 @@ async function exportToZip(taskContext: TaskContext, branch: BBranch, format: "h
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (noteMeta.format === "html" && typeof content === "string") {
|
if (noteMeta.format === "html" && typeof content === "string") {
|
||||||
if (!content.substr(0, 100).toLowerCase().includes("<html")) {
|
if (!content.substr(0, 100).toLowerCase().includes("<html") && !zipExportOptions?.skipHtmlTemplate) {
|
||||||
if (!noteMeta?.notePath?.length) {
|
if (!noteMeta?.notePath?.length) {
|
||||||
throw new Error("Missing note path.");
|
throw new Error("Missing note path.");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user