enml2md icon indicating copy to clipboard operation
enml2md copied to clipboard

Undefined Exception?

Open AddoSolutions opened this issue 10 years ago • 1 comments

Looks like you had an issue here:

/Users/Nitrx/Desktop/enml2md/node_modules/html2markdown/html2markdown.js:44
    return value.replace(/^\s+|\s+$/g,"");
                 ^
TypeError: Cannot call method 'replace' of undefined
    at trim (/Users/Nitrx/Desktop/enml2md/node_modules/html2markdown/html2markdown.js:44:15)
    at Object.parser.end (/Users/Nitrx/Desktop/enml2md/node_modules/html2markdown/html2markdown.js:377:34)
    at parseEndTag (/Users/Nitrx/Desktop/enml2md/node_modules/html2markdown/markdown_html_parser.js:198:15)
    at String.replace (native)
    at HTMLParser (/Users/Nitrx/Desktop/enml2md/node_modules/html2markdown/markdown_html_parser.js:99:16)
    at html2markdown (/Users/Nitrx/Desktop/enml2md/node_modules/html2markdown/html2markdown.js:197:2)
    at module.exports (/Users/Nitrx/Desktop/enml2md/node_modules/html2markdown/index.js:7:10)
    at Note.loadENMLContent (/Users/Nitrx/Desktop/enml2md/lib/Note.js:71:29)
    at Function.Note.composeNoteWithCheerio (/Users/Nitrx/Desktop/enml2md/lib/Note.js:103:10)
    at null.<anonymous> (/Users/Nitrx/Desktop/enml2md/lib/Parser.js:28:23)
Nitrx@Davids-MacBook-Pro:~/Desktop/enml2md (master)$ node bin/enml2md ../EverNotes/MyNotes.enex ../EverNotes/Out

I patched it by replacing:

function trim(value) {
    return value.replace(/^\s+|\s+$/g,"");
}

with

function trim(value) {
    if(!value) return "";
    return value.replace(/^\s+|\s+$/g,"");
}

AddoSolutions avatar Apr 10 '15 18:04 AddoSolutions

Probably now the best solution :)

AddoSolutions avatar Apr 10 '15 18:04 AddoSolutions