mirror of
https://github.com/laurent22/joplin.git
synced 2026-06-18 20:16:34 +02:00
Desktop, CLI: Fixes #1583: Handle multiple lines in attributes when importing Enex files
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<img src="https://joplinapp.org/images/Icon512.png" alt="multiple
|
||||
lines
|
||||
are
|
||||
possible
|
||||
I guess"/><img src="https://joplinapp.org/images/Icon512.png" alt="This should ] be escaped"/>
|
||||
@@ -0,0 +1 @@
|
||||
![This should \] be escaped](https://joplinapp.org/images/Icon512.png)
|
||||
@@ -309,11 +309,21 @@ function isImageMimeType(m) {
|
||||
return imageMimeTypes.indexOf(m) >= 0;
|
||||
}
|
||||
|
||||
function tagAttributeToMdText(attr) {
|
||||
// HTML attributes may contain newlines so remove them.
|
||||
// https://github.com/laurent22/joplin/issues/1583
|
||||
if (!attr) return '';
|
||||
attr = attr.replace(/[\n\r]+/g, ' ');
|
||||
attr = attr.replace(/\]/g, '\\]');
|
||||
return attr;
|
||||
}
|
||||
|
||||
function addResourceTag(lines, resource, alt = "") {
|
||||
// Note: refactor to use Resource.markdownTag
|
||||
|
||||
let tagAlt = alt == "" ? resource.alt : alt;
|
||||
if (!tagAlt) tagAlt = '';
|
||||
tagAlt = tagAttributeToMdText(tagAlt);
|
||||
if (isImageMimeType(resource.mime)) {
|
||||
lines.push("';
|
||||
section.lines.push(s);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user