Fix transform of font keywords

This commit is contained in:
Kovid Goyal 2021-03-21 13:24:28 +05:30
parent 29e2561d61
commit dd2450e092
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 2 deletions

View File

@ -263,7 +263,7 @@ class Token {
if (num > 0) {
out.resize(out.size() + num);
for (int i = 0; i < num; i++) out[i + out.size() - num] = buf[i];
} else throw std::logic_error("Failed to convert character to hexedecimal escape");
} else throw std::logic_error("Failed to convert character to hexadecimal escape");
} else out.push_back(ch);
}
@ -632,6 +632,7 @@ class TokenQueue {
auto fsm = font_size_keywords.find(key);
if (fsm != font_size_keywords.end()) {
it->set_text(fsm->second);
it->set_type(TokenType::dimension);
changed = true;
}
}

View File

@ -36,7 +36,7 @@ class TestTransform(SimpleTest):
s('@import "x.y";', '@import "X.Y";')
s('@import url( x.y);', '@import url("X.Y");')
u('background: url( te st.gif ); src: url(x)', 'background: url("TE ST.GIF"); src: url("X")')
u('background: url( te st.gif ) 12; src: url(x)', 'background: url("TE ST.GIF") 12; src: url("X")')
u('background: url(test.gif); xxx: url()', 'background: url("TEST.GIF"); xxx: url()')
u(r'background: url(t\)est.gif)', 'background: url("T)EST.GIF")')
u('a:url( "( )" )', 'a:url("( )")')
@ -53,6 +53,7 @@ class TestTransform(SimpleTest):
d(r'''font: 'some \n ame' 32px''', 'font: "some n ame" 2rem')
d('''font: 'some \\\nname' 32px''', 'font: "some name" 2rem')
d('font: sans-serif 16px/3', 'font: sans-serif 1rem/3')
d('font: sans-serif small/17', 'font: sans-serif 0.8rem/17')
d('-epub-writing-mode: a; -webkit-writing-mode: b; writing-mode: c', 'writing-mode: a; writing-mode: b; writing-mode: c')
d('xxx:yyy', 'xxx:yyy')