color-marked

markdown parser with highlight and inline code style support, useful for writing email with markdown

npm install color-marked
1 downloads in the last day
1 downloads in the last week
47 downloads in the last month

marked

Markdown parser with code hightlight form highlight.js and optional inline color support. It could be useful when you want to colorful your code in your email.

Options

See orignal README to get understand of most options.

Addtional options include color and colorscheme

  • color parse the css file and add inline color for the code element.

  • colorscheme which colorscheme to use, see highlight.js demo to get all the colorschemes and supported languages.

  • The value of langPrefix was changed to language-

Browser support

  • import css file is required to display colors.

  • When used in browser, import highlight.js file before marked.js file and make sure function window.hljs is availabel for converting.

  • Use function marked(src, option) for markdown converting.

Component support

Install by using component command.

Syntax highlight is enable by default, default colorscheme is solarized_light.

component install chemzqm/marked

Usage Example:

var marked = require('marked');
console.log(marked('**This** is marked for [component](http://component.io/)'));

demo

Javascript API usage

// Set default options
marked.setOptions({
  gfm: true,
  tables: true,
  breaks: false,
  pedantic: false,
  sanitize: true,
  smartLists: true,
  smartypants: false,
  langPrefix: 'language-',
  highlight: function(code, lang) {
    if (lang === 'js') {
      return highlighter.javascript(code);
    }
    return code;
  }
});
console.log(marked('i am using __markdown__.'));

You also have direct access to the lexer and parser if you so desire.

var tokens = marked.lexer(text, options);
console.log(marked.parser(tokens));
var lexer = new marked.Lexer(options);
var tokens = lexer.lex(text);
console.log(tokens);
console.log(lexer.rules);
$ node
> require('marked').lexer('> i am using marked.')
[ { type: 'blockquote_start' },
  { type: 'paragraph',
    text: 'i am using marked.' },
  { type: 'blockquote_end' },
  links: {} ]

Running Tests & Contributing

If you want to submit a pull request, make sure your changes pass the test suite. If you're adding a new feature, be sure to add your own test.

The marked test suite is set up slightly strangely: test/new is for all tests that are not part of the original markdown.pl test suite (this is where your test should go if you make one). test/original is only for the original markdown.pl tests. test/tests houses both types of tests after they have been combined and moved/generated by running node test --fix or marked --test --fix.

In other words, if you have a test to add, add it to test/new/ and then regenerate the tests with node test --fix. Commit the result. If your test uses a certain feature, for example, maybe it assumes GFM is not enabled, you can add .nogfm to the filename. So, my-test.text becomes my-test.nogfm.text. You can do this with any marked option. Say you want line breaks and smartypants enabled, your filename should be: my-test.breaks.smartypants.text.

To run the tests:

cd marked/
node test

Contribution and License Agreement

If you contribute code to marked, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work. </legalese>

License

Copyright (c) 2011-2013, Qiming Zhao. (MIT License)

MIT

npm loves you