Page MenuHomePhabricator

Add support for comments between property and value
Closed, ResolvedPublic

Description

... parse /less.php/test/Fixtures/lessjs-2.5.3/less/comments.less Fail
--- actual
+++ /less.php/test/Fixtures/lessjs-2.5.3/css/comments.css
@@ -1,7 +1,83 @@
-ParseError: Unexpected input in comments.less on line 65, column 34
-63|
-64| .selector /* .with */, .lots, /* of */ .comments {
-65|   color/* survive */ /* me too */: grey, /* blue */ orange;
-66|   -webkit-border-radius: 2px /* webkit only */;
-67|   -moz-border-radius: (2px * 4) /* moz only with operation */;
-68| }

Event Timeline

Krinkle updated the task description. (Show Details)

@pmiazga I suggest trying this one to start with.

Some tricks we usually use:

  1. git blame, on the less/ input file or css/ output file at https://github.com/less/less.js/tree/v2.5.3/test/, and look for when the given input or output was changed. That often (but not always) gets you very close to the main or only commit that resulted in the behaviour change.
  1. PhpStorm debugging, starting from Less_Parser->parsePrimary

You'll need to have php-xdebug installed and PhpStorm set up to recognise your PHP version. I tend to the bin/lessc entry point, with the following PHP options to force a debug connection, with a minimal test case in a temporary input file.

php -dxdebug.mode=debug -dxdebug.client_host=127.0.0.1 -dxdebug.client_port=9003 -dxdebug.start_with_request=yes bin/lessc input.less

Refer to CONTRIBUTING.md for an overview of the important milestones during parsing and what each method is for. This is also where we explain the associated less.js methods (checked into test/less/less-2.5.3.js for quick reference). The @see doc annotations are used to explain where specific code portions are ported from so that you don't have to walk through the entire stack.

Change #1017277 had a related patch set uploaded (by Pmiazga; author: Pmiazga):

[mediawiki/libs/less.php@master] Accept comments in @Keyframe and after rule name

https://gerrit.wikimedia.org/r/1017277

pmiazga changed the task status from Open to In Progress.EditedApr 5 2024, 12:56 PM

In Less library, this feature is provided by https://github.com/less/less.js/commit/e045362c901e6bb5d883e1c85ed568e04742a3f8 commit.

Change #1019269 had a related patch set uploaded (by Pmiazga; author: Pmiazga):

[mediawiki/libs/less.php@master] Proof of concept - ParserInput - Do not merge yet

https://gerrit.wikimedia.org/r/1019269

Change #1017277 merged by jenkins-bot:

[mediawiki/libs/less.php@master] Fix ParseError for comments after rule name or in `@keyframes`

https://gerrit.wikimedia.org/r/1017277

Change #1019269 abandoned by Pmiazga:

[mediawiki/libs/less.php@master] Move input handling logic to separate ParserInput class

Reason:

Not a priority for now. There were plenty of changes in Parser, therefore if we decide to purse this, we will have to split code from scratch again.

https://gerrit.wikimedia.org/r/1019269