Skip to content

Lexer error notified to report parse issue on github md parsing #635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kaiyzen opened this issue Aug 3, 2015 · 2 comments · Fixed by #682
Closed

Lexer error notified to report parse issue on github md parsing #635

kaiyzen opened this issue Aug 3, 2015 · 2 comments · Fixed by #682

Comments

@kaiyzen
Copy link

kaiyzen commented Aug 3, 2015

Learning marked, tried some of the examples in the README file, edited one to read the README.md contents from:

https://raw.githubusercontent.com/chjj/marked/master/README.md

I get this error/trace from marked on parse:

c:\dev\testNode>node test.js
c:\dev\testNode\node_modules\marked\lib\marked.js:1226
    throw e;
          ^
TypeError: undefined is not a function
Please report this to https://github.com/chjj/marked.
    at Lexer.lex (c:\dev\testNode\node_modules\marked\lib\marked.js:138:6)
    at Function.Lexer.lex (c:\dev\testNode\node_modules\marked\lib\marked.js:129
:16)
    at marked (c:\dev\testNode\node_modules\marked\lib\marked.js:1218:31)
    at Object.<anonymous> (c:\dev\testNode\test.js:17:16)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)

Here is test file i ran:

var fs = require('fs');
var marked = require('marked');

marked.setOptions({
  renderer: new marked.Renderer(),
  gfm: true,
  tables: true,
  breaks: false,
  pedantic: false,
  sanitize: true,
  smartLists: true,
  smartypants: false
});

//console.log(marked('I am using __markdown__.'));
var mdString = fs.readFileSync('test.md');
var markedUp = marked(mdString);

fs.writeFile('test.html',markedUp,function(err){
    if(err) {
        console.log('ERROR:');
        console.log(err);
        return;
    }
console.log('wrote file output');
});
@chjj
Copy link
Member

chjj commented Aug 3, 2015

var mdString = fs.readFileSync('test.md');

You're passing in a Buffer instead of string. Try:

var mdString = fs.readFileSync('test.md', 'utf8');

@chjj chjj closed this as completed Aug 3, 2015
@kaiyzen
Copy link
Author

kaiyzen commented Aug 3, 2015

dam.., my bad, used to just passing buff around forgot to pass the string. thanks for pointing it out

awesome module, looking forward to working with it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants