Git Product home page Git Product logo

Comments (8)

xdissent avatar xdissent commented on August 13, 2024

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.

jtousek avatar jtousek commented on August 13, 2024

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.

xdissent avatar xdissent commented on August 13, 2024

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.

johncrenshaw avatar johncrenshaw commented on August 13, 2024

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.)

  1. Save a copy of the current line and file
  2. Parse the import file data via $this->parse($loaded, $url); (rather than adding it to the current buffer).
  3. 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.

ogorzalka avatar ogorzalka commented on August 13, 2024

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.

xomba avatar xomba commented on August 13, 2024

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.

jtousek avatar jtousek commented on August 13, 2024

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.

johncrenshaw avatar johncrenshaw commented on August 13, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.