Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addons and Syntax #1904

Closed
deviprsd opened this issue Mar 1, 2014 · 16 comments
Closed

Addons and Syntax #1904

deviprsd opened this issue Mar 1, 2014 · 16 comments

Comments

@deviprsd
Copy link
Contributor

deviprsd commented Mar 1, 2014

Is there a way to get chunks when the less code is passed to the parser?

@lukeapage
Copy link
Member

What do you mean?

@deviprsd
Copy link
Contributor Author

deviprsd commented Mar 1, 2014

@lukeapage Im working on a project, so i pass the less code to parse of window.less.parser(). It returns the parsed object, but i want the array which contains the chunks of the less code. Is there any way of retrieving that array without modifying the less.js like the error.

One more advice? I want to use $ instead of @ to differentiate a variable. How can i do that?

@seven-phases-max
Copy link
Member

@deviprsd21 and by "the chunks" you mean...? (tokens? rules?) Either way, no, there's no such function/interface in less.js since it's a just a compiler not a Less parsing library.

I want to use $ instead of @ to differentiate a variable. How can i do that?

Find all occurrences of @ where it designates a variable (but not an at-rule like @media) and replace.

@lukeapage
Copy link
Member

I'm not sure why the chunks are useful.. they don't break in predictable
ways.. they exist so that we don't pass regexes the whole string.. just for
performance reasons.

@deviprsd
Copy link
Contributor Author

deviprsd commented Mar 1, 2014

@seven-phases-max I mean the array that contains chunked less code. the variable named "chunks"

@lukeapage I know, i just need them. I can just add a key to parse object and retrieve the chunks but since the project will be dependent on less.js i just don't want to provide a customized less.js. So, there has to be solution for this.

@lukeapage
Copy link
Member

I want to seperate out the chunker as part of the 2.0 work (see branch and
pull request). If you want to contribute to that work you are more than
welcome.

@deviprsd
Copy link
Contributor Author

deviprsd commented Mar 1, 2014

@lukeapage i would love to .... 👍

@deviprsd
Copy link
Contributor Author

deviprsd commented Mar 1, 2014

@lukeapage have u mentioned that u want to separate out the chunker somewhere, coz i didnt find any??

And u want to separate the chunker in which sense? remove or move to a different place? I would like a detailed expaination

@deviprsd
Copy link
Contributor Author

deviprsd commented Mar 1, 2014

@seven-phases-max i tried replacing all possible occurences turns out that it shows unrecognized input

@seven-phases-max
Copy link
Member

@deviprsd21 obviously it should not be all possible occurrences since the @ symbol is used not only for variables (also don't miss that in regexs the $ char should be escaped).

@lukeapage
Copy link
Member

Yes the work in moving that out is bot started. Feel free to start it!

@deviprsd
Copy link
Contributor Author

deviprsd commented Mar 2, 2014

As i working, i thought why can't less have custom syntax. I did some research ... no language has. So, if less supports custom syntax maybe more developers start using less.

LESS uses @, Sass uses $. The dollar sign has no inherit meaning in CSS, while the @ sign does. It's for things like declaring @keyframes or blocks of @media queries. You could chalk this one up to personal preference and not a big deal, but I think the edge here is for Sass which doesn't confuse standing concepts. Article

These is one of the reasons, if less supports custom syntax where the developer can just change one instance of the differentiating word or char while keeping the less behavior intact, I think it would be really great.

@deviprsd
Copy link
Contributor Author

deviprsd commented Mar 2, 2014

One more thing i thought of, if the chunks are made global, retrievable and editable outside the parser then one more new feature can come into play that is addons. Developers can create addons for less.

For example font-weigh: bol; will result the same in less. If there is a addon which rectifies the bol to bold and font-weigh to font-weight it will just lessen less's work. This will broaden less behavior.

@seven-phases-max
Copy link
Member

if the chunks are made global, retrievable and editable outside the parser then one more new feature can come into play that is addons.

As @lukeapage has already mentioned the chunks are barely useful for addons or anything like that because they are just pretty much random pieces of not parsed code having no special meaning. See #1861 (and prev. threads linked there) for the addons/plugins stuff.

I did some research ... no language has

Because beside putting compiler performance down to its knees this also would make the language to be a no-language (imagine English where anyone can randomly and arbitrary use French or Russian words. How nous would comprendre each друга?).

You could chalk this one up to personal preference and not a big deal

Exactly. No comments needed.

@deviprsd
Copy link
Contributor Author

deviprsd commented Mar 3, 2014

Hmmm........

@lukeapage
Copy link
Member

For example font-weigh: bol; will result the same in less. If there is a addon which rectifies the bol to bold and font-weigh to font-weight it will just lessen less's work. This will broaden less behavior.

We will support (the possibility for this) with plugins, but we won't be writing something like that - personally I am excited instead by a linting plugin which errors on missing characters. See the plugins story and the 2.0.0 pull request for more info. I've moved moving the chunker to a task on the 2.0.0 pull request so I think I'll close this in favour of those 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants