evilstreak / markdown-js

A Markdown parser for javascript
7.69k stars 863 forks source link

"Object has no method named 'slice'" #104

Closed JJ closed 10 years ago

JJ commented 10 years ago

I'm trying to parse this: https://github.com/JJ/hoborg/blob/master/text/text.md md2html works without a glitch; however, this code:

var novel = fs.readFileSync(path); var novel_html = md.toHTML(novel);

issues this ugly error:

/home/jmerelo/txt/ocio/hoborg/apps/js/node_modules/markdown/lib/markdown.js:1448 var jsonml = tree.slice( 0 ); ^ TypeError: Object 111 has no method 'slice' at Object.convert_tree_to_html (/home/jmerelo/txt/ocio/hoborg/apps/js/node_modules/markdown/lib/markdown.js:1448:21) at convert_tree_to_html (/home/jmerelo/txt/ocio/hoborg/apps/js/node_modules/markdown/lib/markdown.js:1577:29) at Object.toHTMLTree (/home/jmerelo/txt/ocio/hoborg/apps/js/node_modules/markdown/lib/markdown.js:110:14) at Object.toHTML (/home/jmerelo/txt/ocio/hoborg/apps/js/node_modules/markdown/lib/markdown.js:80:22) at Object. (/home/jmerelo/txt/ocio/hoborg/apps/js/hoborg.js:16:21) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12)

at Function.Module.runMain (module.js:497:10)

That happens for

node --version v0.10.13

I don't think I'm using any flavor here, any idea?

JJ commented 10 years ago

Actually, it chokes also in this code:

Ideas

Only this time it's object 100, not 111

JJ commented 10 years ago

OK, got it. readFileSync returns a buffer if no encoding is mentioned. Works. now. Sorry!