private void CreateStylesheet() { //variable names kept for parity with python var t2c = new Dictionary <TokenType, string>() { { TokenTypes.Token, "" } }; var c2s = new Dictionary <string, ClassToStyle>(); var style = new StringBuilder(); foreach (var kvp in _style) { var ttype = kvp.Key; var ndef = kvp.Value; var name = GetCssClass(ttype); style.Clear(); if (!string.IsNullOrEmpty(ndef.Color)) { style.AppendFormat("color: #{0}; ", ndef.Color); } if (ndef.Bold) { style.Append("font-weight: bold; "); } if (ndef.Italic) { style.Append("font-style: italic; "); } if (ndef.Underline) { style.Append("text-decoration: underline; "); } if (!string.IsNullOrEmpty(ndef.BackgroundColor)) { style.AppendFormat("background-color: #{0}; ", ndef.BackgroundColor); } if (!string.IsNullOrEmpty(ndef.BorderColor)) { style.AppendFormat("border-color: #{0}; ", ndef.BorderColor); } if (style.Length > 0) { style.Length = style.Length - 2; //delete trailing "; " t2c[ttype] = name; c2s[name] = new ClassToStyle { StyleRules = style.ToString(), TokenType = ttype }; } } _tokenToClassMap = new TokenTypeMap(t2c); _cssToStyleMap = c2s; }
private void CreateStylesheet() { //variable names kept for parity with python var t2c = new Dictionary<TokenType, string>() { {TokenTypes.Token, ""} }; var c2s = new Dictionary<string, ClassToStyle>(); var style = new StringBuilder(); foreach (var kvp in _style) { var ttype = kvp.Key; var ndef = kvp.Value; var name = GetCssClass(ttype); style.Clear(); if (!string.IsNullOrEmpty(ndef.Color)) style.AppendFormat("color: #{0}; ", ndef.Color); if (ndef.Bold) style.Append("font-weight: bold; "); if (ndef.Italic) style.Append("font-style: italic; "); if (ndef.Underline) style.Append("text-decoration: underline; "); if (!string.IsNullOrEmpty(ndef.BackgroundColor)) style.AppendFormat("background-color: #{0}; ", ndef.BackgroundColor); if (!string.IsNullOrEmpty(ndef.BorderColor)) style.AppendFormat("border-color: #{0}; ", ndef.BorderColor); if (style.Length > 0) { style.Length = style.Length - 2; //delete trailing "; " t2c[ttype] = name; c2s[name] = new ClassToStyle {StyleRules = style.ToString(), TokenType = ttype}; } } _tokenToClassMap = new TokenTypeMap(t2c); _cssToStyleMap = c2s; }