world/book/node_modules/kramed/lib/lex/html_blocks.js
2025-05-12 05:38:44 +09:00

85 lines
1.1 KiB
JavaScript

// List of valid html blocks names, accorting to commonmark spec
// http://jgm.github.io/CommonMark/spec.html#html-blocks
'use strict';
// Treat these blocks as RAW HTML
var htmlBlocks = [
'address',
'article',
'aside',
'base',
'basefont',
'blockquote',
'body',
'caption',
'center',
'col',
'colgroup',
'dd',
'details',
'dialog',
'dir',
'div',
'dl',
'dt',
'fieldset',
'figcaption',
'figure',
'footer',
'form',
'frame',
'frameset',
'h1',
'head',
'header',
'hr',
'html',
'iframe',
'legend',
'li',
'link',
'main',
'menu',
'menuitem',
'meta',
'nav',
'noframes',
'ol',
'optgroup',
'option',
'p',
'param',
'pre',
'script',
'section',
'source',
'title',
'summary',
'table',
'tbody',
'td',
'tfoot',
'th',
'thead',
'title',
'tr',
'track',
'ul'
];
var blockMap = htmlBlocks.reduce(function(accu, x) {
accu[x] = true;
return accu;
}, {});
function isBlock(tag) {
if(!tag) {
return false;
}
var key = tag.toLowerCase();
return Boolean(blockMap[key]);
}
module.exports = isBlock;