-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #370 from mikevoets/master
Add support for counters and multiple values in pseudo-elements
- Loading branch information
Showing
4 changed files
with
191 additions
and
6 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,40 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Converts a decimal number to roman numeral. | ||
* https://stackoverflow.com/questions/9083037/convert-a-number-into-a-roman-numeral-in-javascript | ||
* | ||
* @param {Number} number | ||
* @api private. | ||
*/ | ||
exports.romanize = function(num) { | ||
if (isNaN(num)) | ||
return NaN; | ||
var digits = String(+num).split(""), | ||
key = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM", | ||
"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC", | ||
"","I","II","III","IV","V","VI","VII","VIII","IX"], | ||
roman = "", | ||
i = 3; | ||
while (i--) | ||
roman = (key[+digits.pop() + (i * 10)] || "") + roman; | ||
return Array(+digits.join("") + 1).join("M") + roman; | ||
} | ||
|
||
/** | ||
* Converts a decimal number to alphanumeric numeral. | ||
* https://stackoverflow.com/questions/45787459/convert-number-to-alphabet-string-javascript | ||
* | ||
* @param {Number} number | ||
* @api private. | ||
*/ | ||
exports.alphanumeric = function(num) { | ||
var s = '', t; | ||
|
||
while (num > 0) { | ||
t = (num - 1) % 26; | ||
s = String.fromCharCode(65 + t) + s; | ||
num = (num - t)/26 | 0; | ||
} | ||
return s || undefined; | ||
} |
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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
<html><body> | ||
<html><body style="--var: 'Element'; counter-reset: element 20 other;"> | ||
|
||
<a href="#" style="text-decoration: underline; color: blue;"><span>®+</span>Test<span style="font-weight: bold;">a</span></a> | ||
<b><span style="color: green;">b</span></b> | ||
<b><span style="color: red;"></span><span style="color: green;">b</span></b> | ||
<c style="color: red;"></c> | ||
<c class="not"></c> | ||
<d><img src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs="><span>test</span><img style="width: 20%;" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs="></d> | ||
<e style="counter-increment: element other -2;"><span>Element / 21. -2</span><span></span></e> | ||
<e length="100" style="counter-increment: element other -2;"><span>Element / 22. -4</span><span>Test</span><span> | Length: 100 [xxii:V]</span></e> | ||
<f style="counter-increment: other;"><span>-3</span><span></span></f> | ||
<f style="counter-increment: other;"><span>-2</span><span></span></f> | ||
</body></html> |