Skip to content

Instantly share code, notes, and snippets.

@arthurattwell
Last active July 11, 2016 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthurattwell/74b2cac0171360997e9d257ed41b68ba to your computer and use it in GitHub Desktop.
Save arthurattwell/74b2cac0171360997e9d257ed41b68ba to your computer and use it in GitHub Desktop.
Workaround in Sass for EPUB2's XHTML not supporting `start` attribute
// 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