1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +02:00

Desktop, Mobile: Fixes #5687: Fixed issue with parts of HTML notes not being displayed in some cases

This commit is contained in:
Laurent Cozic 2021-11-09 18:33:28 +00:00
parent f8d9601ff7
commit 4deeed0d5c
7 changed files with 27 additions and 3 deletions

View File

@ -0,0 +1,3 @@
<en-note>
<h1 style="box-sizing:inherit;font-family:&quot;Guardian TextSans Web&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif;margin-top:0.2em;margin-bottom:0.35em;font-size:2.125em;font-weight:600;line-height:1.3;">Association Between mRNA Vaccination and COVID-19 Hospitalization and Disease Severity</h1>
</en-note>

View File

@ -0,0 +1,3 @@
<en-note>
<h1 style="box-sizing:inherit;font-family:&quot;Guardian TextSans Web&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif;margin-top:0.2em;margin-bottom:0.35em;font-size:2.125em;font-weight:600;line-height:1.3;">Association Between mRNA Vaccination and COVID-19 Hospitalization and Disease Severity</h1>
</en-note>

View File

@ -0,0 +1 @@
<a data-from-md href='#'>test</a>

View File

@ -0,0 +1 @@
<a>test</a>

View File

@ -41,6 +41,11 @@ const beautifyHtml = (html) => {
* `<content><![CDATA[...]]</content>`.
*/
const compareOutputToExpected = (options) => {
options = {
resources: [],
...options,
};
const inputFile = fileWithPath(`${options.testName}.enex`);
const outputFile = fileWithPath(`${options.testName}.html`);
const testTitle = `should convert from Enex to Html: ${options.testName}`;
@ -62,12 +67,10 @@ describe('EnexToHtml', function() {
compareOutputToExpected({
testName: 'checklist-list',
resources: [],
});
compareOutputToExpected({
testName: 'svg',
resources: [],
});
compareOutputToExpected({
@ -96,6 +99,10 @@ describe('EnexToHtml', function() {
}],
});
compareOutputToExpected({
testName: 'quoted-attributes',
});
// it('fails when not given a matching resource', (async () => {
// // To test the promise-unexpectedly-resolved case, add `audioResource` to the array.
// const resources = [];

View File

@ -39,7 +39,7 @@ const imageMimeTypes = [
'image/vnd.xiff',
];
const escapeQuotes = (str) => str.replace(/"/g, '"');
const escapeQuotes = (str) => str.replace(/"/g, '&quot;');
const attributesToStr = (attributes) =>
Object.entries(attributes)

View File

@ -192,6 +192,15 @@ class HtmlUtils {
}
}
// For some reason, entire parts of HTML notes don't show up in
// the viewer when there's an anchor tag without an "href"
// attribute. It doesn't always happen and it seems to depend on
// what else is in the note but in any case adding the "href"
// fixes it. https://github.com/laurent22/joplin/issues/5687
if (name.toLowerCase() === 'a' && !attrs['href']) {
attrs['href'] = '#';
}
let attrHtml = this.attributesHtml(attrs);
if (attrHtml) attrHtml = ` ${attrHtml}`;
const closingSign = this.isSelfClosingTag(name) ? '/>' : '>';