Documents in Markdown: a document can be written in Markdown with Write and Preview or in the rich text editor and switched either way, pictures pasted or dropped into the Markdown are kept as files, New Document starts in the way last used, Import Markdown Files beside Upload makes a document from each .md file, a Markdown button beside PDF downloads a document as a .md file, and Markdown pasted into a document's rich text editor goes in as formatting; versions, restore, copy and the API carry the Markdown, and the API's document create and update no longer escape values twice; database 4.2.3 adds documents.document_markdown and document_versions.document_version_markdown, and league/commonmark 2.10 and league/html-to-markdown 5.2 are added to libs/vendor through composer; 26.12.3 changelog entries

This commit is contained in:
johnnyq
2026-11-29 00:48:15 -05:00
parent a84c3eca79
commit 8b4fa5a1a0
484 changed files with 43707 additions and 63 deletions

View File

@@ -59,6 +59,25 @@ if (isset($_POST['vault_unlock'])) {
exit;
}
/*
* Markdown for a document's editors (js/document_markdown.js, functions/markdown.php): Markdown as
* the HTML it shows as - its Preview, switching it to the rich text editor, and Markdown pasted
* into that editor - and the rich text editor's HTML as Markdown, switching the other way.
* Changes nothing; answers {html}, or {markdown, kept, dropped}.
*/
if (isset($_GET['markdown_to_html']) || isset($_GET['html_to_markdown'])) {
header('Content-Type: application/json');
$text = (string) ($_POST[isset($_GET['markdown_to_html']) ? 'markdown' : 'html'] ?? '');
if (strlen($text) > 16 * 1024 * 1024) {
exit(json_encode(['error' => 'That is too long to convert - over 16 MB.']));
}
if (isset($_GET['markdown_to_html'])) {
exit(json_encode(['html' => markdownToHtml($text)]));
}
$markdown = htmlToMarkdown($text, $markdown_notes);
exit(json_encode(['markdown' => $markdown, 'kept' => $markdown_notes['kept'], 'dropped' => $markdown_notes['dropped']]));
}
/*
* The host in a New / Edit Certificate form, checked when asked: connect,
* take the certificate it serves and say what it is - OK, for another name,