JSFiddle - React, Tailwind, and code Playground
by xavierm02
HTML
<body />
JavaScript
var rules = ( function ( ) {
'use strict';
//( function ( ) {
function log( message, indentation ) {
if ( arguments.length >= 2 ) {
while ( indentation-- ) {
message = ' ' + message;
}
}
console.log( message );
}
var rulesByName = Object.create( null );
var prototypeOfRule = Rule.prototype;
function Rule( name, matches ) {
var that;
if ( name in rulesByName ) {
that = rulesByName[ name ];
} else {
if ( this instanceof Rule ) {
that = this;
} else {
that = Object.create( prototypeOfRule );
}
rulesByName[ name ] = that;
that.name = name;
}
if ( arguments.length >= 2 ) {
if ( ! matches instanceof Array ) {
matches = Array.prototype.slice( matches );
}
// check
that.matches = matches;
}
return that;
}
prototypeOfRule.apply = function ( iterator, ruleStack ) {
if ( ruleStack.length > 10 ) {
throw new Error();
}
var possibilities = [ ];
var possibilitiesMaxIndex = [ ];
this.matches.forEach( function ( match ) {
var tokens = [ ];
var cloneOfIterator = iterator.clone( true );
var every = match.every( function ( rule, ruleIndex ) {
var node;
if ( rule instanceof Rule ) {
log( rule.name + ' (' + iterator.index + ')', ruleStack.length );
if ( ruleStack[ ruleStack.length - 1 ] === rule && ruleIndex === 0 ) {
console.log(rule,ruleStack.slice())
...