mirror of
https://github.com/laurent22/joplin.git
synced 2025-03-29 21:21:15 +02:00
All: Improved Evernote import for blockquotes and sup tags
This commit is contained in:
parent
4af496632f
commit
6c3918ebd2
CliClient
ReactNativeClient/lib
@ -8,53 +8,5 @@ rsync -a "$ROOT_DIR/../ReactNativeClient/lib/" "$BUILD_DIR/lib/"
|
|||||||
cp "$ROOT_DIR/package.json" "$BUILD_DIR"
|
cp "$ROOT_DIR/package.json" "$BUILD_DIR"
|
||||||
chmod 755 "$BUILD_DIR/main.js"
|
chmod 755 "$BUILD_DIR/main.js"
|
||||||
|
|
||||||
cd "$BUILD_DIR"
|
# cd "$BUILD_DIR"
|
||||||
node build-translation.js --silent
|
# node build-translation.js --silent
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
|
|
||||||
# # require('cache-require-paths');
|
|
||||||
|
|
||||||
# mkdir -p "$ROOT_DIR/build"
|
|
||||||
# rm -f "$ROOT_DIR/app/lib"
|
|
||||||
# ln -s "$ROOT_DIR/../ReactNativeClient/lib" "$ROOT_DIR/app"
|
|
||||||
|
|
||||||
# npm run build || exit 1
|
|
||||||
|
|
||||||
# # Files under app/gui are in ES6 already but I cannot get Babel
|
|
||||||
# # to ignore them, so copy them back to the build directory.
|
|
||||||
# rsync -a "$ROOT_DIR/app/gui/" "$ROOT_DIR/build/gui/"
|
|
||||||
|
|
||||||
# cp "$ROOT_DIR/package.json" "$ROOT_DIR/build"
|
|
||||||
|
|
||||||
# chmod 755 "$ROOT_DIR/build/main.js"
|
|
||||||
|
|
||||||
# # if [[ ! -f "$ROOT_DIR/package.json.md5" ]]; then
|
|
||||||
# # "$ROOT_DIR/update-package-md5.sh"
|
|
||||||
# # fi
|
|
||||||
|
|
||||||
# # Add modules on top of main.js:
|
|
||||||
# # - cache-require-paths to cache require() calls
|
|
||||||
# # - app-module-path so that lib/something paths can be resolved.
|
|
||||||
|
|
||||||
# #PACKAGE_MD5=$(cat "$ROOT_DIR/package.json.md5")
|
|
||||||
# MAIN_PATH="$ROOT_DIR/build/main.js"
|
|
||||||
# #LINE_TO_ADD="var osTmpdir = require('os-tmpdir'); process.env.CACHE_REQUIRE_PATHS_FILE = osTmpdir() + '/joplin-module-path-cache-$PACKAGE_MD5'; require('cache-require-paths'); require('app-module-path').addPath(__dirname);"
|
|
||||||
# LINE_TO_ADD="require('app-module-path').addPath(__dirname);"
|
|
||||||
# RESULT="$(grep "$LINE_TO_ADD" "$MAIN_PATH")"
|
|
||||||
# if [[ -z "$RESULT" ]]; then
|
|
||||||
# echo "Adding extra modules..."
|
|
||||||
# sed -i "2i $LINE_TO_ADD" "$MAIN_PATH"
|
|
||||||
# else
|
|
||||||
# echo "Extra modules already added."
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# NODE_PATH="$ROOT_DIR/build" node "$ROOT_DIR/build/build-translation.js" --silent
|
|
2
CliClient/package-lock.json
generated
2
CliClient/package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "joplin",
|
"name": "joplin",
|
||||||
"version": "0.10.75",
|
"version": "0.10.76",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
],
|
],
|
||||||
"owner": "Laurent Cozic"
|
"owner": "Laurent Cozic"
|
||||||
},
|
},
|
||||||
"version": "0.10.75",
|
"version": "0.10.76",
|
||||||
"bin": {
|
"bin": {
|
||||||
"joplin": "./main.js"
|
"joplin": "./main.js"
|
||||||
},
|
},
|
||||||
|
@ -149,6 +149,17 @@ function collapseWhiteSpaceAndAppend(lines, state, text) {
|
|||||||
|
|
||||||
if (!spaceLeft && !spaceRight && text == "") return lines;
|
if (!spaceLeft && !spaceRight && text == "") return lines;
|
||||||
|
|
||||||
|
if (state.inQuote) {
|
||||||
|
// Add a ">" at the beginning of the block then at the beginning of each lines. So it turns this:
|
||||||
|
// "my quote\nsecond line" into this => "> my quote\n> second line"
|
||||||
|
lines.push('> ');
|
||||||
|
if (lines.indexOf('\r') >= 0) {
|
||||||
|
text = text.replace(/\n\r/g, '\n\r> ');
|
||||||
|
} else {
|
||||||
|
text = text.replace(/\n/g, '\n> ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (spaceLeft) lines.push(SPACE);
|
if (spaceLeft) lines.push(SPACE);
|
||||||
lines.push(text);
|
lines.push(text);
|
||||||
if (spaceRight) lines.push(SPACE);
|
if (spaceRight) lines.push(SPACE);
|
||||||
@ -199,7 +210,7 @@ function isAnchor(n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isIgnoredEndTag(n) {
|
function isIgnoredEndTag(n) {
|
||||||
return n=="en-note" || n=="en-todo" || n=="span" || n=="body" || n=="html" || n=="font" || n=="br" || n=='hr' || n=='s' || n == 'tbody';
|
return n=="en-note" || n=="en-todo" || n=="span" || n=="body" || n=="html" || n=="font" || n=="br" || n=='hr' || n=='s' || n == 'tbody' || n == 'sup';
|
||||||
}
|
}
|
||||||
|
|
||||||
function isListTag(n) {
|
function isListTag(n) {
|
||||||
@ -212,6 +223,24 @@ function isNewLineOnlyEndTag(n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isCodeTag(n) {
|
function isCodeTag(n) {
|
||||||
|
// NOTE: This handles "code" tags that were copied and pasted from a browser to Evernote. Evernote also has its own code block, which
|
||||||
|
// of course is way more complicated and currently not fully supported (the code will be imported and indented properly, but it won't
|
||||||
|
// have the extra Markdown indentation that identifies the block as code). For reference this is an example of Evernote-style code block:
|
||||||
|
//
|
||||||
|
// <div style="-en-codeblock: true; box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, "Courier New",
|
||||||
|
// monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius:
|
||||||
|
// 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position:
|
||||||
|
// initial initial; background-repeat: initial initial;"><div>function justTesting() {</div><div> someCodeBlock();</div>
|
||||||
|
// <div> return true;</div><div>}</div></div>
|
||||||
|
//
|
||||||
|
// Which in normal HTML would be:
|
||||||
|
//
|
||||||
|
// <code>
|
||||||
|
// function justTesting() {
|
||||||
|
// someCodeBlock();
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// <code>
|
||||||
return n == "pre" || n == "code";
|
return n == "pre" || n == "code";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,6 +259,7 @@ function enexXmlToMdArray(stream, resources) {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let state = {
|
let state = {
|
||||||
inCode: false,
|
inCode: false,
|
||||||
|
inQuote: false,
|
||||||
lists: [],
|
lists: [],
|
||||||
anchorAttributes: [],
|
anchorAttributes: [],
|
||||||
};
|
};
|
||||||
@ -314,6 +344,8 @@ function enexXmlToMdArray(stream, resources) {
|
|||||||
section.lines.push("**");
|
section.lines.push("**");
|
||||||
} else if (n == 's') {
|
} else if (n == 's') {
|
||||||
// Not supported
|
// Not supported
|
||||||
|
} else if (n == 'q') {
|
||||||
|
section.lines.push('"');
|
||||||
} else if (isAnchor(n)) {
|
} else if (isAnchor(n)) {
|
||||||
state.anchorAttributes.push(node.attributes);
|
state.anchorAttributes.push(node.attributes);
|
||||||
section.lines.push('[');
|
section.lines.push('[');
|
||||||
@ -340,7 +372,10 @@ function enexXmlToMdArray(stream, resources) {
|
|||||||
section.lines.push(BLOCK_OPEN); section.lines.push("##### ");
|
section.lines.push(BLOCK_OPEN); section.lines.push("##### ");
|
||||||
} else if (n == "h6") {
|
} else if (n == "h6") {
|
||||||
section.lines.push(BLOCK_OPEN); section.lines.push("###### ");
|
section.lines.push(BLOCK_OPEN); section.lines.push("###### ");
|
||||||
} else if (isCodeTag(n)) {
|
} else if (n == 'blockquote') {
|
||||||
|
section.lines.push(BLOCK_OPEN);
|
||||||
|
state.inQuote = true;
|
||||||
|
} else if (isCodeTag(n, node.attributes)) {
|
||||||
section.lines.push(BLOCK_OPEN);
|
section.lines.push(BLOCK_OPEN);
|
||||||
state.inCode = true;
|
state.inCode = true;
|
||||||
} else if (n == "br") {
|
} else if (n == "br") {
|
||||||
@ -416,7 +451,7 @@ function enexXmlToMdArray(stream, resources) {
|
|||||||
section.lines = addResourceTag(section.lines, resource, node.attributes.alt);
|
section.lines = addResourceTag(section.lines, resource, node.attributes.alt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (n == "span" || n == "font") {
|
} else if (n == "span" || n == "font" || n == 'sup') {
|
||||||
// Ignore
|
// Ignore
|
||||||
} else {
|
} else {
|
||||||
console.warn("Unsupported start tag: " + n);
|
console.warn("Unsupported start tag: " + n);
|
||||||
@ -443,6 +478,11 @@ function enexXmlToMdArray(stream, resources) {
|
|||||||
section.lines.push("**");
|
section.lines.push("**");
|
||||||
} else if (isEmTag(n)) {
|
} else if (isEmTag(n)) {
|
||||||
section.lines.push("*");
|
section.lines.push("*");
|
||||||
|
} else if (n == 'q') {
|
||||||
|
section.lines.push('"');
|
||||||
|
} else if (n == 'blockquote') {
|
||||||
|
section.lines.push(BLOCK_OPEN);
|
||||||
|
state.inQuote = false;
|
||||||
} else if (isCodeTag(n)) {
|
} else if (isCodeTag(n)) {
|
||||||
state.inCode = false;
|
state.inCode = false;
|
||||||
section.lines.push(BLOCK_CLOSE);
|
section.lines.push(BLOCK_CLOSE);
|
||||||
|
@ -286,6 +286,10 @@ function importEnex(parentFolderId, filePath, importOptions = null) {
|
|||||||
note.updated_time = dateToTimestamp(text);
|
note.updated_time = dateToTimestamp(text);
|
||||||
} else if (n == 'tag') {
|
} else if (n == 'tag') {
|
||||||
note.tags.push(text);
|
note.tags.push(text);
|
||||||
|
} else if (n == 'note') {
|
||||||
|
// Ignore - white space between the opening tag <note> and the first sub-tag
|
||||||
|
} else if (n == 'content') {
|
||||||
|
// Ignore - white space between the opening tag <content> and the <![CDATA[< block where the content actually is
|
||||||
} else {
|
} else {
|
||||||
console.warn('Unsupported note tag: ' + n);
|
console.warn('Unsupported note tag: ' + n);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user