Skip to content

Commit 291df02

Browse files
committed
feat: add support for unqouted value of Quoted
Closes #94.
1 parent 7c0ab4c commit 291df02

File tree

9 files changed

+25
-2
lines changed

9 files changed

+25
-2
lines changed

docs/Quoted.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ Value: `'quoted'`
1616
### `value`
1717
Type: `String`<br>
1818

19-
The value of the string between the quote characters.
19+
The value of the string between the quote characters, *including* quotes.
20+
21+
### `contents`
22+
Type: `String`<br>
23+
24+
The value of the string between the quote characters, *without* quotes.
2025

2126
## Example Values
2227

lib/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ export interface Quoted extends NodeBase {
185185
parent: Container;
186186
quote: string;
187187
value: string;
188+
contents: string;
188189
}
189190

190191
export interface UnicodeRange extends NodeBase {

lib/nodes/Quoted.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
The above copyright notice and this permission notice shall be
99
included in all copies or substantial portions of this Source Code Form.
1010
*/
11+
const { unquote } = require('quote-unquote');
12+
1113
const { registerWalker } = require('../walker');
1214

1315
const Node = require('./Node');
@@ -16,6 +18,7 @@ class Quoted extends Node {
1618
constructor(options) {
1719
super(options);
1820
this.type = 'quoted';
21+
this.contents = unquote(options.value);
1922
[this.quote] = options.value;
2023
}
2124

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"dependencies": {
3333
"color-name": "^1.1.4",
3434
"is-url-superb": "^4.0.0",
35-
"postcss": "^7.0.5"
35+
"postcss": "^7.0.5",
36+
"quote-unquote": "^1.0.0"
3637
},
3738
"devDependencies": {
3839
"ava": "^3.5.1",

test/snapshots/func.test.js.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,6 +2677,7 @@ Generated by [AVA](https://avajs.dev).
26772677
name: 'url',
26782678
nodes: [
26792679
Quoted {
2680+
contents: '/gfx/img/bg.jpg',
26802681
parent: [Circular],
26812682
quote: '"',
26822683
raws: {
@@ -2746,6 +2747,7 @@ Generated by [AVA](https://avajs.dev).
27462747
name: 'url',
27472748
nodes: [
27482749
Quoted {
2750+
contents: 'http://domain.com/gfx/img/bg.jpg',
27492751
parent: [Circular],
27502752
quote: '"',
27512753
raws: {
@@ -2815,6 +2817,7 @@ Generated by [AVA](https://avajs.dev).
28152817
name: 'url',
28162818
nodes: [
28172819
Quoted {
2820+
contents: '/gfx/img/bg.jpg',
28182821
parent: [Circular],
28192822
quote: '\'',
28202823
raws: {
@@ -2884,6 +2887,7 @@ Generated by [AVA](https://avajs.dev).
28842887
name: 'url',
28852888
nodes: [
28862889
Quoted {
2890+
contents: 'http://domain.com/gfx/img/bg.jpg',
28872891
parent: [Circular],
28882892
quote: '\'',
28892893
raws: {
@@ -3153,6 +3157,7 @@ Generated by [AVA](https://avajs.dev).
31533157
name: 'url',
31543158
nodes: [
31553159
Quoted {
3160+
contents: '/gfx/img/bg.jpg',
31563161
parent: [Circular],
31573162
quote: '"',
31583163
raws: {
@@ -3250,6 +3255,7 @@ Generated by [AVA](https://avajs.dev).
32503255
name: 'url',
32513256
nodes: [
32523257
Quoted {
3258+
contents: 'http://domain.com/gfx/img/bg.jpg',
32533259
parent: [Circular],
32543260
quote: '"',
32553261
raws: {

test/snapshots/func.test.js.snap

41 Bytes
Binary file not shown.

test/snapshots/word.test.js.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,7 @@ Generated by [AVA](https://avajs.dev).
953953
value: '3',
954954
},
955955
Quoted {
956+
contents: 'Open Sans',
956957
quote: '\'',
957958
raws: {
958959
after: '',
@@ -1050,6 +1051,7 @@ Generated by [AVA](https://avajs.dev).
10501051
value: ',',
10511052
},
10521053
Quoted {
1054+
contents: 'Helvetica Neue',
10531055
quote: '"',
10541056
raws: {
10551057
after: '',

test/snapshots/word.test.js.snap

32 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)