Skip to content

Commit c13ecb3

Browse files
committed
add support for using detached rulesets
1 parent 8893be8 commit c13ecb3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/com/inet/lib/less/LessParser.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,11 @@ private void variable( HashMap<String, Expression> variables, FormattableContain
417417
importFile( currentRule, name.substring( 8 ).trim() );
418418
return;
419419
}
420-
currentRule.add( new CssAtRule( reader, name + ';') ); // directives like @charset "UTF-8";
420+
if( name.endsWith( "()" ) ) {
421+
currentRule.add( new VariableExpression( reader, name.substring( 0, name.length() - 2 ) ) ); // reference to detached ruleset
422+
} else {
423+
currentRule.add( new CssAtRule( reader, name + ';') ); // directives like @charset "UTF-8";
424+
}
421425
return;
422426
// throw createException( "Unrecognized input: '" + name + "'" );
423427
default:

src/com/inet/lib/less/ValueExpression.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* MIT License (MIT)
33
*
4-
* Copyright (c) 2014 - 2016 Volker Berlin
4+
* Copyright (c) 2014 - 2019 Volker Berlin
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -42,6 +42,8 @@ class ValueExpression extends Expression {
4242

4343
private Operation op;
4444

45+
private Rule rule;
46+
4547
/**
4648
* Create a new instance.
4749
* @param obj another LessObject with parse position.
@@ -83,6 +85,7 @@ class ValueExpression extends Expression {
8385
*/
8486
ValueExpression( Rule rule ) {
8587
super( rule, "" );
88+
this.rule = rule;
8689
this.type = RULESET;
8790
this.unit = "";
8891
}
@@ -133,6 +136,9 @@ public void appendTo( CssFormatter formatter ) {
133136
case STRING:
134137
SelectorUtils.appendToWithPlaceHolder( formatter, toString(), 0, true, this );
135138
break;
139+
case RULESET:
140+
rule.appendPropertiesTo( formatter );
141+
break;
136142
default:
137143
super.appendTo( formatter );
138144
}

0 commit comments

Comments
 (0)