NathanWalker / nativescript-ngx-fonticon

Use custom font icon collections seamlessly with NativeScript + Angular.
MIT License
76 stars 39 forks source link

CSS parsing brakes in the presence of new-lines #65

Open jalberto-ghub opened 4 years ago

jalberto-ghub commented 4 years ago

If the CSS file contains the definitions like this:

.icofont-spanner:before { content: "\eff1"; }

The parsing of the files breaks because the code will not split correctly. After much debugging had to do the following to solve it:

    TNSFontIconModule.forRoot({
        'icofont': require('../fonts/icofont-ngx.css').default.replace(/[\r\n]+/g, ' ' )
    }),

I.e. remove all the new lines while loading the file, so that it can be parsed by the current code. The parsing code should take care of it.

jalberto-ghub commented 4 years ago

To make the issue more clear, the current code is using:

let pair = set.replace(/ /g, "").split(":before{");

Which will not split on the presence of new-lines and as a consequence the definition is ignored.