mirror of
https://github.com/lencx/ChatGPT.git
synced 2026-02-06 13:36:56 +00:00
feat: markdown export (#233)
This commit is contained in:
parent
4847bb6fac
commit
70aac07f8e
@ -1,5 +1,16 @@
|
||||
# UPDATE LOG
|
||||
|
||||
## v0.10.3
|
||||
|
||||
Fix:
|
||||
|
||||
- Incompatible configuration data causes program crashes (https://github.com/lencx/ChatGPT/issues/295)
|
||||
- Silent copy text
|
||||
|
||||
Feat:
|
||||
|
||||
- markdown export support distinguishes between users and bots (https://github.com/lencx/ChatGPT/issues/233)
|
||||
|
||||
## v0.10.2
|
||||
|
||||
Fix:
|
||||
|
||||
9
src-tauri/src/scripts/export.js
vendored
9
src-tauri/src/scripts/export.js
vendored
@ -137,7 +137,14 @@ function addActionsButtons(actionsArea, TryAgainButton) {
|
||||
}
|
||||
|
||||
async function exportMarkdown() {
|
||||
const data = ExportMD.turndown(document.querySelector("main div>div>div").innerHTML);
|
||||
const content = Array.from(document.querySelectorAll("main >div>div>div>div")).map(i => {
|
||||
let j = i.cloneNode(true);
|
||||
if (/dark\:bg-gray-800/.test(i.getAttribute('class'))) {
|
||||
j.innerHTML = `<blockquote>${i.innerHTML}</blockquote>`;
|
||||
}
|
||||
return j.innerHTML;
|
||||
}).join('<hr />');
|
||||
const data = ExportMD.turndown(content);
|
||||
const { id, filename } = getName();
|
||||
await invoke('save_file', { name: `notes/${id}.md`, content: data });
|
||||
await invoke('download_list', { pathname: 'chat.notes.json', filename, id, dir: 'notes' });
|
||||
|
||||
4
src-tauri/src/scripts/markdown.export.js
vendored
4
src-tauri/src/scripts/markdown.export.js
vendored
@ -2,7 +2,9 @@ var ExportMD = (function () {
|
||||
if (!TurndownService || !turndownPluginGfm) return;
|
||||
const hljsREG = /^.*(hljs).*(language-[a-z0-9]+).*$/i;
|
||||
const gfm = turndownPluginGfm.gfm
|
||||
const turndownService = new TurndownService()
|
||||
const turndownService = new TurndownService({
|
||||
hr: '---'
|
||||
})
|
||||
.use(gfm)
|
||||
.addRule('code', {
|
||||
filter: (node) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user