-
-
Notifications
You must be signed in to change notification settings - Fork 353
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
Allow disabling of specific block rules #248
Comments
Hi Jared! 👋 Below is a working plugin, if you wish you can publish it, or just drop it into your own code: var remark = require('remark');
var inspect = require('unist-util-inspect');
var processor = remark().use(disable, {block: ['list', 'atxHeading', 'setextHeading']});
console.log(inspect(processor.parse('# Heading.\n* List.\n> Blockquote')));
function disable(options) {
var proto = this.Parser.prototype;
console.log('block: ', proto.blockMethods);
console.log('inline: ', proto.inlineMethods);
ignore('blockMethods', options.block);
ignore('inlineMethods', options.inline);
function ignore(key, list) {
var values = proto[key];
var index = -1;
var length = list && list.length;
var pos;
while (++index < length) {
pos = values.indexOf(list[index]);
if (pos !== -1) {
values.splice(pos, 1);
}
}
}
} Yields:
Cheers! Let me know if you have further questions :) Oh and the Gitter channel is often more responsive than I am on issues :) |
It's awesome that
remark-parser
is built in a modular fashion, but there doesn't seem to be a way to take advantage of that modularity.I'd love to be able to say "parse this string w/o
lists
orheadings
", in the way that I can withremarkable
see exampleThe text was updated successfully, but these errors were encountered: