forked from laurent22/joplin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
418 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<en-note> | ||
<h1 style="box-sizing:inherit;font-family:"Guardian TextSans Web", "Helvetica Neue", 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<en-note> | ||
<h1 style="box-sizing:inherit;font-family:"Guardian TextSans Web", "Helvetica Neue", 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
<span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">I'll highlight some text.</span> | ||
<span style="background-color: rgb(255, 250, 165);-evernote-highlight:true;">I'll highlight some text.</span> | ||
<br/> | ||
<span style="--en-highlight:yellow;background-color: #ffef9e;">this text is yellow</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
==I'll highlight some text.== | ||
==I'll highlight some text.== | ||
==this text is yellow== |
1 change: 1 addition & 0 deletions
1
packages/app-cli/tests/html_to_html/anchor_missing_href.dest.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a data-from-md href='#'>test</a> |
1 change: 1 addition & 0 deletions
1
packages/app-cli/tests/html_to_html/anchor_missing_href.src.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a>test</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
|
||
const { setupDatabaseAndSynchronizer, switchClient, supportDir } = require('./testing/test-utils.js'); | ||
const shim = require('./shim').default; | ||
const { enexXmlToHtml } = require('./import-enex-html-gen.js'); | ||
const cleanHtml = require('clean-html'); | ||
|
||
const fileWithPath = (filename) => | ||
`${supportDir}/../enex_to_html/${filename}`; | ||
|
||
const audioResource = { | ||
filename: 'audio test', | ||
id: '9168ee833d03c5ea7c730ac6673978c1', | ||
mime: 'audio/x-m4a', | ||
size: 82011, | ||
title: 'audio test', | ||
}; | ||
|
||
// All the test HTML files are beautified ones, so we need to run | ||
// this before the comparison. Before, beautifying was done by `enexXmlToHtml` | ||
// but that was removed due to problems with the clean-html package. | ||
const beautifyHtml = (html) => { | ||
return new Promise((resolve) => { | ||
try { | ||
cleanHtml.clean(html, { wrap: 0 }, (...cleanedHtml) => resolve(cleanedHtml.join(''))); | ||
} catch (error) { | ||
console.warn(`Could not clean HTML - the "unclean" version will be used: ${error.message}: ${html.trim().substr(0, 512).replace(/[\n\r]/g, ' ')}...`); | ||
resolve([html].join('')); | ||
} | ||
}); | ||
}; | ||
|
||
/** | ||
* Tests the importer for a single note, checking that the result of | ||
* processing the given `.enex` input file matches the contents of the given | ||
* `.html` file. | ||
* | ||
* Note that this does not test the importing of an entire exported `.enex` | ||
* archive, but rather a single node of such a file. Thus, the test data files | ||
* (e.g. `./enex_to_html/code1.enex`) correspond to the contents of a single | ||
* `<note>...</note>` node in an `.enex` file already extracted from | ||
* `<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}`; | ||
|
||
it(testTitle, (async () => { | ||
const enexInput = await shim.fsDriver().readFile(inputFile); | ||
const expectedOutput = await shim.fsDriver().readFile(outputFile); | ||
const actualOutput = await beautifyHtml(await enexXmlToHtml(enexInput, options.resources)); | ||
expect(actualOutput).toEqual(expectedOutput); | ||
})); | ||
}; | ||
|
||
describe('EnexToHtml', function() { | ||
beforeEach(async (done) => { | ||
await setupDatabaseAndSynchronizer(1); | ||
await switchClient(1); | ||
done(); | ||
}); | ||
|
||
compareOutputToExpected({ | ||
testName: 'checklist-list', | ||
}); | ||
|
||
compareOutputToExpected({ | ||
testName: 'svg', | ||
}); | ||
|
||
compareOutputToExpected({ | ||
testName: 'en-media--image', | ||
resources: [{ | ||
filename: '', | ||
id: '89ce7da62c6b2832929a6964237e98e9', // Mock id | ||
mime: 'image/jpeg', | ||
size: 50347, | ||
title: '', | ||
}], | ||
}); | ||
|
||
compareOutputToExpected({ | ||
testName: 'en-media--audio', | ||
resources: [audioResource], | ||
}); | ||
|
||
compareOutputToExpected({ | ||
testName: 'attachment', | ||
resources: [{ | ||
filename: 'attachment-1', | ||
id: '21ca2b948f222a38802940ec7e2e5de3', | ||
mime: 'application/pdf', // Any non-image/non-audio mime type will do | ||
size: 1000, | ||
}], | ||
}); | ||
|
||
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 = []; | ||
// const inputFile = fileWithPath('en-media--image.enex'); | ||
// const enexInput = await shim.fsDriver().readFile(inputFile); | ||
// const promisedOutput = enexXmlToHtml(enexInput, resources); | ||
|
||
// promisedOutput.then(() => { | ||
// // Promise should not be resolved | ||
// expect(false).toEqual(true); | ||
// }, (reason) => { | ||
// expect(reason) | ||
// .toBe('Hash with no associated resource: 89ce7da62c6b2832929a6964237e98e9'); | ||
// }); | ||
// })); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.