mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
tweaking html conversion process
This commit is contained in:
parent
d6ffae2035
commit
a460c40587
@ -1,16 +1,16 @@
|
|||||||
function convertAll2Html() {
|
function convertNoteToHtml(noteId, failedNotes) {
|
||||||
const failedNotes = [];
|
|
||||||
let counter = 1;
|
|
||||||
|
|
||||||
for (const noteId of globalAllNoteIds) {
|
|
||||||
console.log('Converting ' + counter + "/" + globalAllNoteIds.length);
|
|
||||||
counter++;
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: baseUrl + 'notes/' + noteId,
|
url: baseUrl + 'notes/' + noteId,
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
async: false,
|
async: false,
|
||||||
success: function (note) {
|
success: function (note) {
|
||||||
|
const noteNode = getNodeByKey(noteId);
|
||||||
|
|
||||||
|
if (noteNode.data.is_clone) {
|
||||||
|
// we shouldn't process notes twice
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
note.detail.note_text = notecase2html(note);
|
note.detail.note_text = notecase2html(note);
|
||||||
note.formatting = [];
|
note.formatting = [];
|
||||||
|
|
||||||
@ -18,8 +18,6 @@ function convertAll2Html() {
|
|||||||
delete link.type;
|
delete link.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(note.detail.note_text);
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: baseUrl + 'notes/' + noteId,
|
url: baseUrl + 'notes/' + noteId,
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
@ -42,8 +40,17 @@ function convertAll2Html() {
|
|||||||
failedNotes.push(noteId);
|
failedNotes.push(noteId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
function convertAll2Html() {
|
||||||
|
const failedNotes = [];
|
||||||
|
let counter = 1;
|
||||||
|
|
||||||
|
for (const noteId of globalAllNoteIds) {
|
||||||
|
console.log('Converting ' + counter + "/" + globalAllNoteIds.length);
|
||||||
|
counter++;
|
||||||
|
|
||||||
|
convertNoteToHtml(noteId, failedNotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Failed notes: ", failedNotes);
|
console.log("Failed notes: ", failedNotes);
|
||||||
|
@ -1,4 +1,16 @@
|
|||||||
|
const globalHtmlEnabled = true;
|
||||||
|
|
||||||
function html2notecase(contents, note) {
|
function html2notecase(contents, note) {
|
||||||
|
note.formatting = [];
|
||||||
|
note.links = [];
|
||||||
|
note.images = [];
|
||||||
|
|
||||||
|
if (globalHtmlEnabled) {
|
||||||
|
note.detail.note_text = contents;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// remove any possible extra newlines which might be inserted - all relevant new lines should be only in <br> and <p>
|
// remove any possible extra newlines which might be inserted - all relevant new lines should be only in <br> and <p>
|
||||||
contents = contents.replace(/(?:\r\n|\r|\n)/, '');
|
contents = contents.replace(/(?:\r\n|\r|\n)/, '');
|
||||||
|
|
||||||
@ -15,10 +27,6 @@ function html2notecase(contents, note) {
|
|||||||
|
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
|
||||||
note.formatting = [];
|
|
||||||
note.links = [];
|
|
||||||
note.images = [];
|
|
||||||
|
|
||||||
while (index < contents.length) {
|
while (index < contents.length) {
|
||||||
let curContent = contents.substr(index);
|
let curContent = contents.substr(index);
|
||||||
|
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
function notecase2html(note) {
|
function notecase2html(note) {
|
||||||
|
if (globalHtmlEnabled) {
|
||||||
|
return note.detail.note_text;
|
||||||
|
}
|
||||||
|
|
||||||
let noteText = note.detail.note_text;
|
let noteText = note.detail.note_text;
|
||||||
|
|
||||||
note.formatting.forEach(el => el.type = 'formatting');
|
note.formatting.forEach(el => el.type = 'formatting');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user