Last active
July 11, 2016 09:06
-
-
Save arthurattwell/74b2cac0171360997e9d257ed41b68ba to your computer and use it in GitHub Desktop.
Workaround in Sass for EPUB2's XHTML not supporting `start` attribute
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
// Workaround for EPUB2's XHTML not supporting `start` attribute | |
// In HTML, regex search-replace | |
// <ol (.*?)start="(\d+)" | |
// with | |
// <ol \1class="start-\2" | |
// Create 20 options for starting numbering | |
@for $i from 2 through 20 { | |
$start: $i + 1; | |
// If we the list ol to start at 1, the first li will be 2 | |
// Then to show the new numbering, we set the li to display as a block | |
// with a generated number `:before` it that follows the reset numbering | |
ol.start-#{$i} { | |
counter-reset: start ($i - 1); | |
li { | |
display: block; | |
} | |
li:before { | |
content: counter(start) ". "; | |
counter-increment: start; | |
} | |
// Nested lists shouldn't keep counting, so | |
// reset the counters and :before content for nested lists | |
ol li { | |
display: list-item; | |
counter-reset: start 1; | |
} | |
ol.start-3 ol li:before { | |
content: normal; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment