Comments (8)
Yeah but what happens if the LESS source is manipulated on the fly before parsing. The @import()
statement is already half crippled if you're not parsing LESS directly from the filesystem, so this feature would have to follow suit there. I do like the minified option, and I've been planning to add it to my own LESS workflow at some point. Of course, the minified output would be the same regardless of whether or not the LESS was loaded and compiled directly from the FS, so it makes a little more sense.
from lessphp.
well not bad idea but personly i use either cssviewer or firebug... however as an option for debuging porposes only it's not bad
from lessphp.
I mean, with mixins being called left and right, and imports, and imports with mixins, and dynamic LESS generated by PHP, this is going to be a behemoth of a feature now that I think about it. Right?
from lessphp.
Looking at the code, this actually looks fairly straightforward. Just call $this->set("__line", $this->line); each time a new tag is encountered and use the line during compilation to build the comment.
For non-file inputs, add an optional "file" parameter to parse(). (This is needed anyway.)
For import, only a minor tweak is needed (to change it to the way it should have been anyway.)
- Save a copy of the current line and file
- Parse the import file data via $this->parse($loaded, $url); (rather than adding it to the current buffer).
- Restore the original line and file data
Also, there is already a firebug plugin that consumes file/line metadata in SASS files. If the output for this feature matched the output used by SASS, and consumed by that plugin, it would be infinitely more useful.
from lessphp.
i think it would be great to make something like sass which uses this syntax on each selector :
@media -sass-debug-info{filename{font-family:file\:\/\/C\:\\wamp\\www\\test\\\\css\\styles\.scss;}line{font-family:'2334';}}
.test a {
color:blue;
}
It would be easy to edit the firesass extension so that it can work with less...
from lessphp.
The line number in a prepended comment will help when reading the raw output file, but does little for you in Firebug. If the line number was added as a class to each rule when in a development mode, it would be easy to spot in tools like Firebug.
For example:
.foo { color: #FFF; }
becomes:
.foo, .line-351 { color: #FFF; }
from lessphp.
xomba: Bad idea. This would stop ::-moz-selection pseudo-element from working. Another thing is that it wouldn't be very helpful with mixins.
from lessphp.
Xomba's idea is good enough for most cases, and it has the distinct advantage of getting the data into debug consoles without requiring any additional plugins, so I looked into what it requires just to hack in. Turns out to be absurdly easy:
In lesc_parser::pushBlock(), add:
if ($tags && $this->lessc->debug_info) { $count = is_null($count) ? $this->count : $count; $line = $this->line + substr_count(substr($this->buffer, 0, $count), "\n"); $b->line = $line; $b->fileName = $this->lessc->fileName; }
Then in lessc::compileBlock(), just before the return, add:
if ($tags && $this->debug_info && isset($block->line) && isset($block->fileName)) { $tags[] = '.lessc_debug_info[line="'.$block->line.'"][file="'.basename($block->fileName).'"]'; }
The first edit is needed for any sort of solution here
Issues:
- Line number finding uses the same method as the error handler, which in this case is now horribly inefficient. It would be far better to maintain the current line number as the position indicator ($this->count) is updated.
- Line number is the line where the block is defined. If you need more detailed information, like info about mixins, you'd have to dig deeper on your own. The line number of the block should give a sufficient starting point for this though.
from lessphp.
Related Issues (20)
- parse error: failed at `$result: &;` (stdin) HOT 1
- Will the project uodated to teh newest less version? HOT 2
- @supports CSS Feature Queries not working HOT 3
- Both DOS and UNIX style line endings issue on Theme Check WordPress Plugin
- guarded recursion fails on exit
- setPreserveComments changes line endings
- Parse error with CSS Grid Layout and named grid lines/areas HOT 3
- lessphp fatal error: expected color value: /home/iler/public_html/wp-content/themes/CherryFramework-child2/bootstrap/less/bootstrap.less on line 63
- less parser fails with UIKIT 3 less files HOT 3
- less parser fails with less.js built-in function color() HOT 1
- recursive mixin not working in nested rule
- Background SVG animation breaks generation
- PHP Fatal error: Uncaught Exception: E_NOTICE in PHP 7.4 HOT 3
- Error parse: calc function HOT 1
- Deprecated Array and string offset access syntax with curly braces is deprecated HOT 5
- Imported files get optimized incorrectly. HOT 1
- Deprecated stuff under PHP 8.1 HOT 3
- each loop -> Uncaught Exception: parse error: failed at `); `
- Support for PHP 8.2 HOT 4
- Deprecated things under PHP 8.2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lessphp.