diff --git a/README.md b/README.md index 93f21e16..7844dd77 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,8 @@ bower install remarkable --save ## Usage ```js -var Remarkable = require('remarkable'); -var md = new Remarkable(); +const Remarkable = require('remarkable'); +const md = new Remarkable(); console.log(md.render('# Remarkable rulezz!')); // =>

Remarkable rulezz!

@@ -69,12 +69,13 @@ Define options in the constructor: ```js // Actual default values -var md = new Remarkable({ +const md = new Remarkable({ html: false, // Enable HTML tags in source xhtmlOut: false, // Use '/' to close single tags (
) breaks: false, // Convert '\n' in paragraphs into
langPrefix: 'language-', // CSS language prefix for fenced blocks linkify: false, // Autoconvert URL-like text to links + linkTarget: '', // Set target to open link in // Enable some language-neutral replacement + quotes beautification typographer: false, @@ -97,8 +98,8 @@ console.log(md.render('# Remarkable rulezz!')); Or define options via the `.set()` method: ```js -var Remarkable = require('remarkable'); -var md = new Remarkable(); +const Remarkable = require('remarkable'); +const md = new Remarkable(); md.set({ html: true, @@ -122,8 +123,8 @@ active syntax rules and options for common use cases. Enable strict [CommonMark](http://commonmark.org/) mode with the `commonmark` preset: ```js -var Remarkable = require('remarkable'); -var md = new Remarkable('commonmark'); +const Remarkable = require('remarkable'); +const md = new Remarkable('commonmark'); ``` #### full @@ -131,11 +132,11 @@ var md = new Remarkable('commonmark'); Enable all available rules (but still with default options, if not set): ```js -var Remarkable = require('remarkable'); -var md = new Remarkable('full'); +const Remarkable = require('remarkable'); +const md = new Remarkable('full'); // Or with options: -var md = new Remarkable('full', { +const md = new Remarkable('full', { html: true, linkify: true, typographer: true @@ -148,12 +149,12 @@ var md = new Remarkable('full', { Apply syntax highlighting to fenced code blocks with the `highlight` option: ```js -var Remarkable = require('remarkable'); -var hljs = require('highlight.js') // https://highlightjs.org/ +const Remarkable = require('remarkable'); +const hljs = require('highlight.js') // https://highlightjs.org/ // Actual default values -var md = new Remarkable({ - highlight: function (str, lang) { +const md = new Remarkable({ + highlight(str, lang) { if (lang && hljs.getLanguage(lang)) { try { return hljs.highlight(lang, str).value; @@ -195,7 +196,7 @@ old-style rules via external plugins if you prefer. ### Manage rules ```js -var md = new Remarkable(); +const md = new Remarkable(); md.inline.ruler.enable([ 'ins', 'mark' ]); md.block.ruler.disable([ 'table' ]); @@ -209,7 +210,7 @@ md = new Remarkable('full', { // // Manually enable rules, disabled by default: // -var md = new Remarkable(); +const md = new Remarkable(); md.core.ruler.enable([ 'abbr' ]); @@ -233,8 +234,8 @@ Although full-weight typographical replacements are language specific, `remarkab provides coverage for the most common and universal use cases: ```js -var Remarkable = require('remarkable'); -var md = new Remarkable({ +const Remarkable = require('remarkable'); +const md = new Remarkable({ typographer: true, quotes: '“”‘’' }); @@ -266,7 +267,7 @@ more advanced or specific to your language. Easily load plugins with the `.use()` method: ```js -var md = new Remarkable(); +const md = new Remarkable(); md.use(plugin1) .use(plugin2, opts) @@ -324,7 +325,7 @@ Sample: spec.txt (110610 bytes) > marked-0.3.2 x 22.92 ops/sec ±0.79% (41 runs sampled) ``` -As you can see, `remarkable` doesn't pay with speed for it's flexibility. Because +As you can see, `remarkable` doesn't pay with speed for its flexibility. Because it's written in monomorphic style and uses JIT inline caches effectively. diff --git a/bin/remarkable.js b/bin/remarkable.js index b7c03c3f..8fc7ef46 100755 --- a/bin/remarkable.js +++ b/bin/remarkable.js @@ -17,7 +17,7 @@ var cli = new argparse.ArgumentParser({ addHelp: true }); -cli.addArgument([ 'file' ], { +cli.addArgument([ '--file' ], { help: 'File to read', nargs: '?', defaultValue: '-' @@ -74,5 +74,4 @@ readFile(options.file, 'utf8', function (err, input) { } process.stdout.write(output); - process.exit(0); }); diff --git a/lib/rules.js b/lib/rules.js index 94568f2f..47aa730c 100644 --- a/lib/rules.js +++ b/lib/rules.js @@ -131,7 +131,7 @@ rules.list_item_close = function (/* tokens, idx, options, env */) { rules.ordered_list_open = function (tokens, idx /*, options, env */) { var token = tokens[idx]; - var order = token.order > 1 ? ' start="' + token.order + '"' : ''; + var order = (token.order === 0 || token.order > 1) ? ' start="' + token.order + '"' : ''; return '\n'; }; rules.ordered_list_close = function (tokens, idx /*, options, env */) { diff --git a/lib/rules_block/paragraph.js b/lib/rules_block/paragraph.js index d25e5da7..c1eb731e 100644 --- a/lib/rules_block/paragraph.js +++ b/lib/rules_block/paragraph.js @@ -12,7 +12,7 @@ module.exports = function paragraph(state, startLine/*, endLine*/) { // jump line-by-line until empty one or EOF if (nextLine < endLine && !state.isEmpty(nextLine)) { - terminatorRules = state.parser.ruler.getRules('paragraph'); + terminatorRules = state.parser.ruler.getRules('paragraph') || []; for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) { // this would be a code block normally, but after paragraph diff --git a/lib/rules_inline/mark.js b/lib/rules_inline/mark.js index d154ba45..c6c6790b 100644 --- a/lib/rules_inline/mark.js +++ b/lib/rules_inline/mark.js @@ -2,7 +2,7 @@ 'use strict'; -module.exports = function del(state, silent) { +module.exports = function mark(state, silent) { var found, pos, stack,