-
Notifications
You must be signed in to change notification settings - Fork 128
Open
Description
Hi. When trying to parse a css file while the current culture is not western (en, fr...) an exception is thrown:
ExCSS.ParseException: Unrecognized integer value '-1.'
at ExCSS.NumberToken.get_IntegerValue()
at ExCSS.ValueExtensions.ToInteger(IEnumerable`1 value)
at ExCSS.StructValueConverter`1.Convert(IEnumerable`1 value)
at ExCSS.OrValueConverter.Convert(IEnumerable`1 value)
at ExCSS.OrValueConverter.Convert(IEnumerable`1 value)
at ExCSS.OrValueConverter.Convert(IEnumerable`1 value)
at ExCSS.OrValueConverter.Convert(IEnumerable`1 value)
at ExCSS.OrValueConverter.Convert(IEnumerable`1 value)
at ExCSS.OrValueConverter.Convert(IEnumerable`1 value)
at ExCSS.OrValueConverter.Convert(IEnumerable`1 value)
at ExCSS.Property.TrySetValue(TokenValue newTokenValue)
at ExCSS.StylesheetComposer.CreateDeclarationWith(Func`2 createProperty, Token& token)
at ExCSS.StylesheetComposer.FillDeclarations(StyleDeclaration style)
at ExCSS.StylesheetComposer.CreateStyle(Token current)
at ExCSS.StylesheetComposer.CreateRule(Token token)
at ExCSS.StylesheetComposer.CreateRules(Stylesheet sheet)
at ExCSS.StylesheetParser.Parse(TextSource source)
at ExCSS.StylesheetParser.Parse(String content)
at Program.<Main>$(String[] args) in D:\CssRtlTest\Program.cs:line 10
at Program.<Main>(String[] args)
Code to reproduce:
// Switching Culture to Arabic ...
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("ar");
// Using Bootstrap 5 CSS...
var bootstrap5 = await new HttpClient().GetStringAsync("https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css");
// Exception: ExCSS.ParseException: Unrecognized integer value '-1.'
var stylesheet = new StylesheetParser().Parse(bootstrap5);
Console.WriteLine("Parsing successful!");
Console.ReadLine();Workaround:
Temporary switch culture to Invariant before parsing:
Stylesheet stylesheet;
// Save original culture
var currentCulture = CultureInfo.CurrentCulture;
try
{
// Temporary switching Culture to Invariant...
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
// Parse CSS...
stylesheet = new StylesheetParser().Parse(bootstrap5);
}
finally
{
// Switch back to original culture
CultureInfo.CurrentCulture = currentCulture;
}Metadata
Metadata
Assignees
Labels
No labels