remark-parse
Advanced tools
Comparing version 2.0.2 to 2.1.0
@@ -19,3 +19,4 @@ /** | ||
pedantic: false, | ||
blocks: require('./block-elements'), | ||
breaks: false | ||
}; |
@@ -56,3 +56,6 @@ /** | ||
if (typeof value !== 'boolean') { | ||
if ( | ||
(key !== 'blocks' && typeof value !== 'boolean') || | ||
(key === 'blocks' && typeof value !== 'object') | ||
) { | ||
throw new Error( | ||
@@ -59,0 +62,0 @@ 'Invalid value `' + value + '` ' + |
@@ -40,2 +40,3 @@ /** | ||
var self = this; | ||
var blocks = self.options.blocks; | ||
var index = 0; | ||
@@ -68,4 +69,4 @@ var length = value.length; | ||
declaration(value) || | ||
closing(value, true) || | ||
opening(value, true); | ||
closing(value, blocks) || | ||
opening(value, blocks); | ||
@@ -72,0 +73,0 @@ if (!queue) { |
@@ -82,2 +82,3 @@ /** | ||
var start = null; | ||
var size = 0; | ||
var queue; | ||
@@ -106,3 +107,2 @@ var ordered; | ||
var indented; | ||
var size; | ||
@@ -112,3 +112,7 @@ while (index < length) { | ||
if (character !== C_SPACE && character !== C_TAB) { | ||
if (character === C_TAB) { | ||
size += TAB_SIZE - (size % TAB_SIZE); | ||
} else if (character === C_SPACE) { | ||
size++; | ||
} else { | ||
break; | ||
@@ -120,2 +124,6 @@ } | ||
if (size >= TAB_SIZE) { | ||
return; | ||
} | ||
character = value.charAt(index); | ||
@@ -122,0 +130,0 @@ |
@@ -15,3 +15,2 @@ /** | ||
var whitespace = require('is-whitespace-character'); | ||
var blockElements = require('../block-elements.json'); | ||
@@ -30,8 +29,8 @@ /* Expose. */ | ||
* @param {string} value - Value to parse. | ||
* @param {boolean?} [isBlock] - Whether the tag-name | ||
* must be a known block-level node to match. | ||
* @param {Array.<string>?} [blocks] - Known block tag-names, | ||
* which must be matched if given. | ||
* @return {string?} - When applicable, the closing tag at | ||
* the start of `value`. | ||
*/ | ||
function match(value, isBlock) { | ||
function match(value, blocks) { | ||
var index = 0; | ||
@@ -69,3 +68,3 @@ var length = value.length; | ||
if (isBlock && blockElements.indexOf(subqueue.toLowerCase()) === -1) { | ||
if (blocks && blocks.indexOf(subqueue.toLowerCase()) === -1) { | ||
return; | ||
@@ -72,0 +71,0 @@ } |
@@ -15,3 +15,2 @@ /** | ||
var whitespace = require('is-whitespace-character'); | ||
var blockElements = require('../block-elements.json'); | ||
@@ -33,8 +32,8 @@ /* Expose. */ | ||
* @param {string} value - Value to parse. | ||
* @param {boolean?} [isBlock] - Whether the tag-name | ||
* must be a known block-level node to match. | ||
* @param {Array.<string>?} [blocks] - Known block tag-names, | ||
* which must be matched if given. | ||
* @return {string?} - When applicable, the closing tag at | ||
* the start of `value`. | ||
*/ | ||
function match(value, isBlock) { | ||
function match(value, blocks) { | ||
var index = 0; | ||
@@ -71,3 +70,3 @@ var length = value.length; | ||
if (isBlock && blockElements.indexOf(subqueue.toLowerCase()) === -1) { | ||
if (blocks && blocks.indexOf(subqueue.toLowerCase()) === -1) { | ||
return; | ||
@@ -74,0 +73,0 @@ } |
{ | ||
"name": "remark-parse", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "Markdown parser for remark", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -67,2 +67,3 @@ # remark-parse [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat] | ||
* [`breaks`][options-breaks] (`boolean`, default: `false`). | ||
* [`blocks`][options-blocks] (`Array.<string>`, default: list of block HTML elements); | ||
@@ -149,2 +150,12 @@ ##### `options.gfm` | ||
##### `options.blocks` | ||
```md | ||
<block>foo | ||
</block> | ||
``` | ||
Blocks (default: a list of HTML block elements) exposes | ||
let’s users define block-level HTML elements. | ||
##### `options.pedantic` | ||
@@ -426,2 +437,4 @@ | ||
[options-blocks]: #optionsblocks | ||
[parser]: https://github.com/wooorm/unified#processorparser | ||
@@ -428,0 +441,0 @@ |
144407
5260
448