diff --git a/ReactNativeClient/lib/htmlUtils.js b/ReactNativeClient/lib/htmlUtils.js index e13db1c07..77414eafe 100644 --- a/ReactNativeClient/lib/htmlUtils.js +++ b/ReactNativeClient/lib/htmlUtils.js @@ -52,6 +52,7 @@ const htmlUtils = { for (const anchor of anchors) { const href = anchor.getAttribute('href'); + if (!href) continue; const newHref = urlUtils.prependBaseUrl(href, baseUrl); anchor.setAttribute('href', newHref); } diff --git a/ReactNativeClient/lib/services/rest/Api.js b/ReactNativeClient/lib/services/rest/Api.js index b473753af..b9f0d3be6 100644 --- a/ReactNativeClient/lib/services/rest/Api.js +++ b/ReactNativeClient/lib/services/rest/Api.js @@ -437,9 +437,10 @@ class Api { if (requestNote.body_html) { if (requestNote.convert_to === 'html') { const style = await this.buildNoteStyleSheet_(requestNote.stylesheets); + const minify = require('html-minifier').minify; + const styleTag = style.length ? '' + '\n' : ''; - const minify = require('html-minifier').minify; output.body = minify(styleTag + requestNote.body_html, { // Remove all spaces and, especially, newlines from tag attributes, as that would // break the rendering. @@ -447,6 +448,7 @@ class Api { // Need to remove all whitespaces because whitespace at a beginning of a line // means a code block in Markdown. collapseWhitespace: true, + minifyCSS: true, }); output.body = htmlUtils.prependBaseUrl(output.body, baseUrl); output.markup_language = Note.MARKUP_LANGUAGE_HTML;