Skip to content

Commit 25d2249

Browse files
authored
feat: add support for unqouted value of Quoted (#128)
Closes #94.
1 parent 5cd85c7 commit 25d2249

File tree

11 files changed

+25
-2
lines changed

11 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
@@ -31,7 +31,8 @@
3131
],
3232
"dependencies": {
3333
"color-name": "^1.1.4",
34-
"is-url-superb": "^4.0.0"
34+
"is-url-superb": "^4.0.0",
35+
"quote-unquote": "^1.0.0"
3536
},
3637
"devDependencies": {
3738
"ava": "^3.12.1",

test/snapshots/func.test.js.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3127,6 +3127,7 @@ Generated by [AVA](https://avajs.dev).
31273127
name: 'url',
31283128
nodes: [
31293129
Quoted {
3130+
contents: '/gfx/img/bg.jpg',
31303131
parent: [Circular],
31313132
quote: '"',
31323133
raws: {
@@ -3206,6 +3207,7 @@ Generated by [AVA](https://avajs.dev).
32063207
name: 'url',
32073208
nodes: [
32083209
Quoted {
3210+
contents: 'http://domain.com/gfx/img/bg.jpg',
32093211
parent: [Circular],
32103212
quote: '"',
32113213
raws: {
@@ -3285,6 +3287,7 @@ Generated by [AVA](https://avajs.dev).
32853287
name: 'url',
32863288
nodes: [
32873289
Quoted {
3290+
contents: '/gfx/img/bg.jpg',
32883291
parent: [Circular],
32893292
quote: '\'',
32903293
raws: {
@@ -3364,6 +3367,7 @@ Generated by [AVA](https://avajs.dev).
33643367
name: 'url',
33653368
nodes: [
33663369
Quoted {
3370+
contents: 'http://domain.com/gfx/img/bg.jpg',
33673371
parent: [Circular],
33683372
quote: '\'',
33693373
raws: {
@@ -3678,6 +3682,7 @@ Generated by [AVA](https://avajs.dev).
36783682
name: 'url',
36793683
nodes: [
36803684
Quoted {
3685+
contents: '/gfx/img/bg.jpg',
36813686
parent: [Circular],
36823687
quote: '"',
36833688
raws: {
@@ -3790,6 +3795,7 @@ Generated by [AVA](https://avajs.dev).
37903795
name: 'url',
37913796
nodes: [
37923797
Quoted {
3798+
contents: 'http://domain.com/gfx/img/bg.jpg',
37933799
parent: [Circular],
37943800
quote: '"',
37953801
raws: {

test/snapshots/func.test.js.snap

21 Bytes
Binary file not shown.

test/snapshots/numeric.test.js.snap

-3 Bytes
Binary file not shown.
-2 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
@@ -1108,6 +1108,7 @@ Generated by [AVA](https://avajs.dev).
11081108
[Symbol(isClean)]: false,
11091109
},
11101110
Quoted {
1111+
contents: 'Open Sans',
11111112
quote: '\'',
11121113
raws: {
11131114
after: '',
@@ -1225,6 +1226,7 @@ Generated by [AVA](https://avajs.dev).
12251226
[Symbol(isClean)]: false,
12261227
},
12271228
Quoted {
1229+
contents: 'Helvetica Neue',
12281230
quote: '"',
12291231
raws: {
12301232
after: '',

test/snapshots/word.test.js.snap

43 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)