make small caps more backwards-compatible

This commit is contained in:
Daniel Jönsson 2018-03-23 11:16:32 +01:00
parent c2e11b3f6d
commit 0e3553c44e
2 changed files with 28 additions and 9 deletions

View file

@ -18,18 +18,19 @@ export async function cleanMarkup (html) {
html = twemoji.parse(html, {ext: '.svg', folder: 'svg'})
// replace HTML entities with decimal entities
html = html.replace(/\xA0/g, ' ')
html = html.replace(/ /g, ' ')
html = html.replace(/ /g, ' ')
html = html.replace(/\xA0/ig, ' ')
html = html.replace(/ /ig, ' ')
html = html.replace(/ /ig, ' ')
// fix some tags
html = html.replace(/<u>/g, '<span style="text-decoration: underline">')
html = html.replace(/<\/u>/g, '</span>')
html = html.replace(/<s>/g, '<span style="text-decoration: line-through">')
html = html.replace(/<\/s>/g, '</span>')
html = html.replace(/<u>/ig, '<span style="text-decoration: underline">')
html = html.replace(/<\/u>/ig, '</span>')
html = html.replace(/<s>/ig, '<span style="text-decoration: line-through">')
html = html.replace(/<\/s>/ig, '</span>')
html = html.replace(/<span style="font-variant-caps:small-caps">/ig, '<span class="smcp">')
html = html.replace(/<p>\s*/g, '<p>')
html = html.replace(/\s*<\/p>/g, '</p>')
html = html.replace(/<p>\s*/ig, '<p>')
html = html.replace(/\s*<\/p>/ig, '</p>')
// html = fixParagraphIndent(html)

View file

@ -53,6 +53,24 @@ em em {
font-style: normal;
}
.smcp {
font-variant: small-caps;
}
@supports not (font-variant-caps: small-caps) {
.smcp {
font-variant: normal;
-webkit-font-feature-settings: 'smcp', 'onum';
font-feature-settings: 'smcp', 'onum';
}
}
@supports (font-variant-caps: small-caps) {
.smcp {
font-variant: normal;
font-variant-caps: small-caps;
font-variant-numeric: oldstyle-nums;
}
}
.chapter-title {
padding-top: 0.5em;
margin-bottom: 1.5em;