mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-27 08:21:03 +02:00
Clipper: Generate better HTML so that it loads faster in text editor
This commit is contained in:
parent
fbb3543818
commit
feb5f17479
5
ElectronClient/app/package-lock.json
generated
5
ElectronClient/app/package-lock.json
generated
@ -6654,6 +6654,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"uglifycss": {
|
||||||
|
"version": "0.0.29",
|
||||||
|
"resolved": "https://registry.npmjs.org/uglifycss/-/uglifycss-0.0.29.tgz",
|
||||||
|
"integrity": "sha512-J2SQ2QLjiknNGbNdScaNZsXgmMGI0kYNrXaDlr4obnPW9ni1jljb1NeEVWAiTgZ8z+EBWP2ozfT9vpy03rjlMQ=="
|
||||||
|
},
|
||||||
"uid-safe": {
|
"uid-safe": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz",
|
||||||
|
@ -150,6 +150,7 @@
|
|||||||
"syswide-cas": "^5.1.0",
|
"syswide-cas": "^5.1.0",
|
||||||
"tar": "^4.4.4",
|
"tar": "^4.4.4",
|
||||||
"tcp-port-used": "^0.1.2",
|
"tcp-port-used": "^0.1.2",
|
||||||
|
"uglifycss": "0.0.29",
|
||||||
"url-parse": "^1.4.3",
|
"url-parse": "^1.4.3",
|
||||||
"uuid": "^3.2.1",
|
"uuid": "^3.2.1",
|
||||||
"valid-url": "^1.0.9",
|
"valid-url": "^1.0.9",
|
||||||
|
@ -440,9 +440,7 @@ class Api {
|
|||||||
const style = await this.buildNoteStyleSheet_(requestNote.stylesheets);
|
const style = await this.buildNoteStyleSheet_(requestNote.stylesheets);
|
||||||
const minify = require('html-minifier').minify;
|
const minify = require('html-minifier').minify;
|
||||||
|
|
||||||
const styleTag = style.length ? '<style>' + style.join('\n') + '</style>' + '\n' : '';
|
const minifyOptions = {
|
||||||
|
|
||||||
output.body = minify(styleTag + requestNote.body_html, {
|
|
||||||
// Remove all spaces and, especially, newlines from tag attributes, as that would
|
// Remove all spaces and, especially, newlines from tag attributes, as that would
|
||||||
// break the rendering.
|
// break the rendering.
|
||||||
customAttrCollapse: /.*/,
|
customAttrCollapse: /.*/,
|
||||||
@ -450,7 +448,18 @@ class Api {
|
|||||||
// means a code block in Markdown.
|
// means a code block in Markdown.
|
||||||
collapseWhitespace: true,
|
collapseWhitespace: true,
|
||||||
minifyCSS: true,
|
minifyCSS: true,
|
||||||
|
maxLineLength: 300,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uglifycss = require('uglifycss');
|
||||||
|
const styleString = uglifycss.processString(style.join('\n'), {
|
||||||
|
// Need to set a max length because Ace Editor takes forever
|
||||||
|
// to display notes with long lines.
|
||||||
|
maxLineLen: 200,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const styleTag = style.length ? '<style>' + styleString + '</style>' + '\n' : '';
|
||||||
|
output.body = styleTag + minify(requestNote.body_html, minifyOptions);
|
||||||
output.body = htmlUtils.prependBaseUrl(output.body, baseUrl);
|
output.body = htmlUtils.prependBaseUrl(output.body, baseUrl);
|
||||||
output.markup_language = Note.MARKUP_LANGUAGE_HTML;
|
output.markup_language = Note.MARKUP_LANGUAGE_HTML;
|
||||||
} else { // Convert to Markdown
|
} else { // Convert to Markdown
|
||||||
|
Loading…
Reference in New Issue
Block a user