mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Clipper: Set source URL and fixed issues with tables and urls
This commit is contained in:
parent
a8da469523
commit
f79d7b9626
@ -36,7 +36,7 @@ describe('HtmlToMd', function() {
|
||||
const htmlPath = basePath + '/' + htmlFilename;
|
||||
const mdPath = basePath + '/' + filename(htmlFilename) + '.md';
|
||||
|
||||
// if (htmlFilename !== 'anchor_with_newlines.html') continue;
|
||||
// if (htmlFilename !== 'table_with_colspan.html') continue;
|
||||
|
||||
const html = await shim.fsDriver().readFile(htmlPath);
|
||||
const expectedMd = await shim.fsDriver().readFile(mdPath);
|
||||
|
15
CliClient/tests/html_to_md/table_with_colspan.html
Normal file
15
CliClient/tests/html_to_md/table_with_colspan.html
Normal file
@ -0,0 +1,15 @@
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
Something that was originally spanning two columns
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
One
|
||||
</td>
|
||||
<td>
|
||||
Two
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
4
CliClient/tests/html_to_md/table_with_colspan.md
Normal file
4
CliClient/tests/html_to_md/table_with_colspan.md
Normal file
@ -0,0 +1,4 @@
|
||||
| | |
|
||||
| --- | --- |
|
||||
| Something that was originally spanning two columns | |
|
||||
| One | Two |
|
@ -26,6 +26,11 @@ describe('urlUtils', function() {
|
||||
expect(urlUtils.prependBaseUrl('', 'http://example.com/something')).toBe('http://example.com/something');
|
||||
expect(urlUtils.prependBaseUrl('testing.html', '')).toBe('testing.html');
|
||||
|
||||
// It shouldn't prepend anyting for these:
|
||||
expect(urlUtils.prependBaseUrl('mailto:emailme@example.com', 'http://example.com')).toBe('mailto:emailme@example.com');
|
||||
expect(urlUtils.prependBaseUrl('javascript:var%20testing=true', 'http://example.com')).toBe('javascript:var%20testing=true');
|
||||
expect(urlUtils.prependBaseUrl('http://alreadyabsolute.com', 'http://example.com')).toBe('http://alreadyabsolute.com');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
|
6
ElectronClient/app/package-lock.json
generated
6
ElectronClient/app/package-lock.json
generated
@ -4035,9 +4035,9 @@
|
||||
}
|
||||
},
|
||||
"joplin-turndown-plugin-gfm": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/joplin-turndown-plugin-gfm/-/joplin-turndown-plugin-gfm-1.0.5.tgz",
|
||||
"integrity": "sha512-B0gLGle6NJUlu3redq4wv99sYiAAiJmio0WPCXnD1O9uAkq6YAbOkVG6CW+JPJSKOizSTZidrVYdeDAl+mQ8dg=="
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/joplin-turndown-plugin-gfm/-/joplin-turndown-plugin-gfm-1.0.6.tgz",
|
||||
"integrity": "sha512-FLGejYMWvYNQbuAYuDAVQdcVB6X3zwmSEKSneAuXg2/3KAhdRFq6lqBf54hxan+iD3RISK8LhkmPFBLEGwVNtQ=="
|
||||
},
|
||||
"js-tokens": {
|
||||
"version": "3.0.2",
|
||||
|
@ -90,7 +90,7 @@
|
||||
"html-entities": "^1.2.1",
|
||||
"image-type": "^3.0.0",
|
||||
"joplin-turndown": "^4.0.4",
|
||||
"joplin-turndown-plugin-gfm": "^1.0.5",
|
||||
"joplin-turndown-plugin-gfm": "^1.0.6",
|
||||
"jssha": "^2.3.1",
|
||||
"katex": "^0.9.0-beta1",
|
||||
"levenshtein": "^1.0.5",
|
||||
|
@ -37,7 +37,7 @@ class ClipperServer {
|
||||
body: requestNote.body ? requestNote.body : '',
|
||||
};
|
||||
|
||||
if (requestNote.bodyHtml) {
|
||||
if (requestNote.bodyHtml) {
|
||||
// Parsing will not work if the HTML is not wrapped in a top level tag, which is not guaranteed
|
||||
// when getting the content from elsewhere. So here wrap it - it won't change anything to the final
|
||||
// rendering but it makes sure everything will be parsed.
|
||||
@ -54,6 +54,8 @@ class ClipperServer {
|
||||
output.parent_id = folder.id;
|
||||
}
|
||||
|
||||
if (requestNote.url) output.source_url = requestNote.url;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
@ -18,15 +18,13 @@ urlUtils.urlProtocol = function(url) {
|
||||
return parsed.protocol;
|
||||
}
|
||||
|
||||
const schemeRegex = /^[a-zA-Z0-9\+\-\.]+:\/\//
|
||||
urlUtils.prependBaseUrl = function(url, baseUrl) {
|
||||
baseUrl = rtrimSlashes(baseUrl).trim(); // All the code below assumes that the baseUrl does not end up with a slash
|
||||
url = url.trim();
|
||||
|
||||
if (!url) url = '';
|
||||
if (!baseUrl) return url;
|
||||
const matches = schemeRegex.exec(url);
|
||||
if (matches) return url; // Don't prepend the base URL if the URL already has a scheme
|
||||
if (urlUtils.urlProtocol(url)) return url; // Don't prepend the base URL if the URL already has a scheme
|
||||
|
||||
if (url.length >= 2 && url.indexOf('//') === 0) { // If it starts with // it's a protcol-relative URL
|
||||
return urlUtils.urlProtocol(baseUrl) + url;
|
||||
|
Loading…
Reference in New Issue
Block a user