/**
* @name HTML
* @support inline style and event handlers
*/
import xml, { properties, xmlElement } from './xml.js';
let
/**
* An attribute, given by a regex source, whose value is written in another language
* @type {(name: string, sub: string) => import('../index.js').ShjRule}
*/
attribute = (name, sub) => ({
type: 'str',
// the name is left to the attribute rule of xml, only its value differs
match: RegExp(`(?<=\\s${name}\\s*)=\\s*('[^']*'|"[^"]*")`, 'gi'),
sub: [
{
type: 'oper',
match: /^=/g
},
{
// the quotes are left to the rule's own type
match: /(?<=['"])[^]+(?=['"]$)/g,
sub
}
]
}),
htmlElement = {
...xmlElement,
sub: [
attribute('style', 'css'),
attribute('on\\w+', 'js'),
...xmlElement.sub
]
};
export default /** @satisfies {import('../index.js').ShjGrammar} */ ([
{
type: 'class',
match: /])*>/gi,
sub: [
{
type: 'str',
match: /"[^"]*"|'[^']*'/g
},
{
type: 'oper',
match: /^$/g
},
{
type: 'var',
match: /DOCTYPE/gi
}
]
},
{
match: RegExp(``, 'g'),
sub: [
{
match: RegExp(`^