Skip to content
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

dev #261

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

dev #261

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!'));
// => <h1>Remarkable rulezz!</h1>
Expand Down Expand Up @@ -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 (<br />)
breaks: false, // Convert '\n' in paragraphs into <br>
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,
Expand All @@ -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,
Expand All @@ -122,20 +123,20 @@ 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

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
Expand All @@ -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;
Expand Down Expand Up @@ -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' ]);

Expand All @@ -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'
]);
Expand All @@ -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: '“”‘’'
});
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.


Expand Down
3 changes: 1 addition & 2 deletions bin/remarkable.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var cli = new argparse.ArgumentParser({
addHelp: true
});

cli.addArgument([ 'file' ], {
cli.addArgument([ '--file' ], {
help: 'File to read',
nargs: '?',
defaultValue: '-'
Expand Down Expand Up @@ -74,5 +74,4 @@ readFile(options.file, 'utf8', function (err, input) {
}

process.stdout.write(output);
process.exit(0);
});
2 changes: 1 addition & 1 deletion lib/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<ol' + order + '>\n';
};
rules.ordered_list_close = function (tokens, idx /*, options, env */) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules_block/paragraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/rules_inline/mark.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

'use strict';

module.exports = function del(state, silent) {
module.exports = function mark(state, silent) {
var found,
pos,
stack,
Expand Down