@@ -65,6 +65,7 @@ std::map<string_id, string> style::m_valid_values =
6565 { _caption_side_, caption_side_strings },
6666
6767 { _text_decoration_style_, style_text_decoration_style_strings },
68+ { _text_emphasis_position_, style_text_emphasis_position_strings },
6869};
6970
7071std::map<string_id, vector<string_id>> shorthands =
@@ -106,6 +107,7 @@ std::map<string_id, vector<string_id>> shorthands =
106107 { _flex_flow_, {_flex_direction_, _flex_wrap_}},
107108
108109 { _text_decoration_, {_text_decoration_color_, _text_decoration_line_, _text_decoration_style_, _text_decoration_thickness_}},
110+ { _text_emphasis_, {_text_emphasis_style_, _text_emphasis_color_}},
109111};
110112
111113void style::add (const string& txt, const string& baseurl, document_container* container)
@@ -447,10 +449,22 @@ void style::add_property(string_id name, const css_token_vector& value, const st
447449 break ;
448450
449451 case _text_emphasis_:
452+ parse_text_emphasis (value, important, container);
453+ break ;
454+
455+ case _text_emphasis_style_:
450456 str = get_repr (value, 0 , -1 , true );
451457 add_parsed_property (name, property_value (str, important));
452458 break ;
453459
460+ case _text_emphasis_color_:
461+ parse_text_emphasis_color (val, important, container);
462+ break ;
463+
464+ case _text_emphasis_position_:
465+ parse_text_emphasis_position (value, important);
466+ break ;
467+
454468 // ============================= FLEX =============================
455469
456470 case _flex_:
@@ -1322,6 +1336,51 @@ void style::parse_text_decoration_line(const css_token_vector& tokens, bool impo
13221336 add_parsed_property (_text_decoration_line_, property_value (val, important));
13231337}
13241338
1339+ void style::parse_text_emphasis (const css_token_vector& tokens, bool important, document_container *container) {
1340+ string style;
1341+ for (const auto & token : std::vector (tokens.rbegin (), tokens.rend ()))
1342+ {
1343+ if (parse_text_emphasis_color (token, important, container)) continue ;
1344+ style.insert (0 , token.str + " " );
1345+ }
1346+ if (!style.empty ())
1347+ {
1348+ add_parsed_property (_text_emphasis_style_, property_value (style, important));
1349+ }
1350+ }
1351+
1352+ bool style::parse_text_emphasis_color (const css_token &token, bool important, document_container *container)
1353+ {
1354+ web_color _color;
1355+ if (parse_color (token, _color, container))
1356+ {
1357+ add_parsed_property (_text_emphasis_color_, property_value (_color, important));
1358+ return true ;
1359+ }
1360+ if (token.type == IDENT && value_in_list (token.ident (), " auto;currentcolor" ))
1361+ {
1362+ add_parsed_property (_text_emphasis_color_, property_value (web_color::current_color, important));
1363+ return true ;
1364+ }
1365+ return false ;
1366+ }
1367+
1368+ void style::parse_text_emphasis_position (const css_token_vector &tokens, bool important)
1369+ {
1370+ int val = 0 ;
1371+ for (const auto & token : tokens)
1372+ {
1373+ if (token.type == IDENT)
1374+ {
1375+ int idx = value_index (token.ident (), style_text_emphasis_position_strings);
1376+ if (idx >= 0 )
1377+ {
1378+ val |= 1 << (idx - 1 );
1379+ }
1380+ }
1381+ }
1382+ add_parsed_property (_text_emphasis_position_, property_value (val, important));
1383+ }
13251384
13261385// https://developer.mozilla.org/en-US/docs/Web/CSS/flex
13271386// https://drafts.csswg.org/css-flexbox/#flex-property
0 commit comments