cjss-group / CJSS

A CSS based web framework
https://cjss.js.org/
MIT License
670 stars 20 forks source link

Proper highlighting for editors. #38

Open KargJonas opened 5 years ago

KargJonas commented 5 years ago

Currently the code is highlighted wrong in vscode. What editor do you use? Which one should we build a highlighter for?

c-harding commented 5 years ago

I use VSCode. However, I'm concerned that our current idea of the language is hitting and breaking the limits of the parser: for example a block of HTML cannot contain unmatched parentheses (:( is forbidden). I'm wondering it's worth enforcing indentation and running it through a preprocessor, but that sort of destroys the idea of the framework

KargJonas commented 5 years ago

Hmm.. we could build a "preprocessor" (a very light one) directly into cjss.js and modify the source CSS it receives. That would save us from having to use some node tool but would also have a bit of a performance penalty.

c-harding commented 5 years ago

I’m not sure that’s possible, as the errors could prevent the browser from loading the CSS properly.

On 22 Jun 2019, at 14:09, Jonas Karg notifications@github.com wrote:

Hmm.. we could build a "preprocessor" (a very light one) directly into cjss.js and modify the source of the CSS rules it receives. That would save us from having to use some node tool but would also have a bit of a performance penalty.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/scottkellum/CJSS/issues/38?email_source=notifications&email_token=ACBVKLW7M3QUNZCBJMGV7HLP3YJANA5CNFSM4H2WQDZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYKIDWI#issuecomment-504660441, or mute the thread https://github.com/notifications/unsubscribe-auth/ACBVKLQ4WCPH5GLZZ3F44Z3P3YJANANCNFSM4H2WQDZA.

KargJonas commented 5 years ago

I don't thinks that's an issue.

c-harding commented 5 years ago

How do we get the source code of the css file? If we replace the mime type of css link and style tags, we’re going to run into the problem that everything in those files is going to be very slow to load, as we will have to preprocess the plain css rules too.

On 22 Jun 2019, at 16:01, Jonas Karg notifications@github.com wrote:

I don't thinks that's an issue.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

KargJonas commented 5 years ago

Just grab rule.cssText in processRule()

c-harding commented 5 years ago

That won’t work if the parse error is greater: If we have a stray close brace (e.g. inside a template string), the boundaries of the rule may be wrong. A very contrived example would be to insert the string )} into an element: the HTML mode does not support this, and the JavaScript modes will only support it if it is wrapped in single or double quotes, rather than backticks.

KargJonas commented 5 years ago

K in that case we'll have to do our stuff in cjss() at if (ruleName === 'CSSImportRule') { ... } but this would mean stylesheets directly loaded from html cannot contain CJSS properties.

c-harding commented 5 years ago

What about a different way of formatting? We could allow double quotes to be used as delimiters, in place of the brackets to be replaced with double quotes, but then we would need to find an alternative way of allowing newlines (backslashes before the newline produce valid CSS, but at rather a usability cost).