-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for generating semi-colonless references
Which is quite useful when creating minifiers; but creates “invalid” HTML.
- Loading branch information
Showing
6 changed files
with
272 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
"cent", | ||
"copy", | ||
"divide", | ||
"gt", | ||
"lt", | ||
"not", | ||
"para", | ||
"times" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* @author Titus Wormer | ||
* @copyright 2015 Titus Wormer | ||
* @license MIT | ||
* @module stringify-entities:script | ||
* @fileoverview Generate a list of entities which might | ||
* conflict when used without semi-colon. | ||
* For example, we can’t minify `¬in;` to `∉`, | ||
* as that would render another entity. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/* eslint-env node */ | ||
|
||
/* Dependencies. */ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var legacy = Object.keys(require('character-entities-legacy')); | ||
var entities = Object.keys(require('character-entities')); | ||
|
||
/* Escape-codes. */ | ||
var conflict = []; | ||
|
||
/* Generate the expression. */ | ||
var length = legacy.length; | ||
var count = entities.length; | ||
var index = -1; | ||
var offset; | ||
var left; | ||
var right; | ||
|
||
/* Generate. */ | ||
while (++index < length) { | ||
left = legacy[index]; | ||
offset = -1; | ||
|
||
while (++offset < count) { | ||
right = entities[offset]; | ||
|
||
if (left !== right && right.slice(0, left.length) === left) { | ||
conflict.push(left); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
/* Write. */ | ||
fs.writeFileSync( | ||
path.join('lib', 'dangerous.json'), | ||
JSON.stringify(conflict, null, 2) + '\n' | ||
); |
Oops, something went wrong.