Skip to content

Commit fb29139

Browse files
authored
feat: support smart quote (#37)
1 parent e0c03fa commit fb29139

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Legend for syntax support:
6464
| Term list | List / ListItem | ⚠️ | 🚫 |
6565
| Math | Code / CodeBlock || 🚫 |
6666
| Line break | Break || 🚫 |
67-
| Smart quote | | 🚫 | 🚫 |
67+
| Smart quote | Str | | 🚫 |
6868
| Symbol shorthand | Code || 🚫 |
6969
| Code expression | |||
7070
| Character escape | Code || 🚫 |

src/typstToTextlintAst.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ const isInlineEscapeNode = (node: Content): boolean => {
272272
};
273273

274274
const isInlineMarkedNode = (node: Content): boolean => {
275-
return ["Marked::Ref", "Marked::SmartQuote"].includes(node.type);
275+
return ["Marked::Ref"].includes(node.type);
276276
};
277277

278278
const isParagraphInlineLikeNode = (node: Content): boolean => {
@@ -698,6 +698,10 @@ export const convertRawTypstAstObjectToTextlintAstObject = (
698698
if (/^Marked::Text/.test(node.type)) {
699699
node.type = ASTNodeTypes.Str;
700700
}
701+
if (/^Marked::SmartQuote$/.test(node.type)) {
702+
node.type = ASTNodeTypes.Str;
703+
node.value = node.raw;
704+
}
701705
if (/^Marked::Parbreak/.test(node.type)) {
702706
node.type = ASTNodeTypes.Break;
703707
}

test/unit/fixtures/inline-escape-shorthand-smartquote/output.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255
},
256256
"range": [74, 75],
257257
"raw": "\"",
258-
"type": "Marked::SmartQuote",
258+
"type": "Str",
259259
"value": "\""
260260
},
261261
{
@@ -287,7 +287,7 @@
287287
},
288288
"range": [81, 82],
289289
"raw": "\"",
290-
"type": "Marked::SmartQuote",
290+
"type": "Str",
291291
"value": "\""
292292
},
293293
{
@@ -351,7 +351,7 @@
351351
},
352352
"range": [87, 88],
353353
"raw": "'",
354-
"type": "Marked::SmartQuote",
354+
"type": "Str",
355355
"value": "'"
356356
},
357357
{
@@ -383,7 +383,7 @@
383383
},
384384
"range": [94, 95],
385385
"raw": "'",
386-
"type": "Marked::SmartQuote",
386+
"type": "Str",
387387
"value": "'"
388388
},
389389
{

0 commit comments

Comments
 (0)