Skip to content

Commit 059d863

Browse files
committed
fix: refine paragraph boundaries for inline contents
1 parent 8e76c01 commit 059d863

File tree

32 files changed

+6929
-820
lines changed

32 files changed

+6929
-820
lines changed

src/typstToTextlintAst.ts

Lines changed: 456 additions & 32 deletions
Large diffs are not rendered by default.

test/integration/linting.test.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -314,16 +314,13 @@ describe("linting", () => {
314314
});
315315

316316
// see: https://github.com/textlint/textlint-plugin-typst/pull/31
317-
it.fails(
318-
"should handle elements immediately below comments",
319-
async () => {
320-
const result = await lintFile(
321-
"element_immediately_below_comment_valid.typ",
322-
);
323-
const violations = getViolations(result);
324-
expect(violations).toEqual([]);
325-
},
326-
);
317+
it("should handle elements immediately below comments", async () => {
318+
const result = await lintFile(
319+
"element_immediately_below_comment_valid.typ",
320+
);
321+
const violations = getViolations(result);
322+
expect(violations).toEqual([]);
323+
});
327324

328325
it("should handle term lists", async () => {
329326
const result = await lintFile("term_list_valid.typ");
@@ -332,7 +329,7 @@ describe("linting", () => {
332329
});
333330

334331
// see: https://github.com/textlint/textlint-plugin-typst/pull/31
335-
it.fails("should handle nested lists", async () => {
332+
it("should handle nested lists", async () => {
336333
const result = await lintFile("nested_list_valid.typ");
337334
const violations = getViolations(result);
338335
expect(violations).toEqual([]);
@@ -366,7 +363,7 @@ describe("linting", () => {
366363
});
367364

368365
// see: https://github.com/textlint/textlint-plugin-typst/pull/31
369-
it.fails("should detect violations in term lists", async () => {
366+
it("should detect violations in term lists", async () => {
370367
const result = await lintFile("term_list_invalid.typ");
371368
const violations = getViolations(result);
372369
expect(

test/unit/fixtures/Break/output.json

Lines changed: 82 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -114,40 +114,39 @@
114114
"raw": " ",
115115
"type": "Str",
116116
"value": " "
117-
}
118-
],
119-
"loc": {
120-
"end": {
121-
"column": 19,
122-
"line": 1
123117
},
124-
"start": {
125-
"column": 0,
126-
"line": 1
127-
}
128-
},
129-
"range": [0, 19],
130-
"raw": "*Date:* 26.12.2022 ",
131-
"type": "Paragraph"
132-
},
133-
{
134-
"loc": {
135-
"end": {
136-
"column": 20,
137-
"line": 1
118+
{
119+
"loc": {
120+
"end": {
121+
"column": 20,
122+
"line": 1
123+
},
124+
"start": {
125+
"column": 19,
126+
"line": 1
127+
}
128+
},
129+
"range": [19, 20],
130+
"raw": "\\",
131+
"type": "Str",
132+
"value": "\\"
133+
},
134+
{
135+
"loc": {
136+
"end": {
137+
"column": 0,
138+
"line": 2
139+
},
140+
"start": {
141+
"column": 20,
142+
"line": 1
143+
}
144+
},
145+
"range": [20, 21],
146+
"raw": "\n",
147+
"type": "Str",
148+
"value": "\n"
138149
},
139-
"start": {
140-
"column": 19,
141-
"line": 1
142-
}
143-
},
144-
"range": [19, 20],
145-
"raw": "\\",
146-
"type": "Break",
147-
"value": "\\"
148-
},
149-
{
150-
"children": [
151150
{
152151
"children": [
153152
{
@@ -260,40 +259,39 @@
260259
"raw": " ",
261260
"type": "Str",
262261
"value": " "
263-
}
264-
],
265-
"loc": {
266-
"end": {
267-
"column": 29,
268-
"line": 2
269262
},
270-
"start": {
271-
"column": 0,
272-
"line": 2
273-
}
274-
},
275-
"range": [21, 50],
276-
"raw": "*Topic:* Infrastructure Test ",
277-
"type": "Paragraph"
278-
},
279-
{
280-
"loc": {
281-
"end": {
282-
"column": 30,
283-
"line": 2
263+
{
264+
"loc": {
265+
"end": {
266+
"column": 30,
267+
"line": 2
268+
},
269+
"start": {
270+
"column": 29,
271+
"line": 2
272+
}
273+
},
274+
"range": [50, 51],
275+
"raw": "\\",
276+
"type": "Str",
277+
"value": "\\"
278+
},
279+
{
280+
"loc": {
281+
"end": {
282+
"column": 0,
283+
"line": 3
284+
},
285+
"start": {
286+
"column": 30,
287+
"line": 2
288+
}
289+
},
290+
"range": [51, 52],
291+
"raw": "\n",
292+
"type": "Str",
293+
"value": "\n"
284294
},
285-
"start": {
286-
"column": 29,
287-
"line": 2
288-
}
289-
},
290-
"range": [50, 51],
291-
"raw": "\\",
292-
"type": "Break",
293-
"value": "\\"
294-
},
295-
{
296-
"children": [
297295
{
298296
"children": [
299297
{
@@ -406,37 +404,37 @@
406404
"raw": " ",
407405
"type": "Str",
408406
"value": " "
407+
},
408+
{
409+
"loc": {
410+
"end": {
411+
"column": 18,
412+
"line": 3
413+
},
414+
"start": {
415+
"column": 17,
416+
"line": 3
417+
}
418+
},
419+
"range": [69, 70],
420+
"raw": "\\",
421+
"type": "Str",
422+
"value": "\\"
409423
}
410424
],
411425
"loc": {
412426
"end": {
413-
"column": 17,
427+
"column": 18,
414428
"line": 3
415429
},
416430
"start": {
417431
"column": 0,
418-
"line": 3
432+
"line": 1
419433
}
420434
},
421-
"range": [52, 69],
422-
"raw": "*Severity:* High ",
435+
"range": [0, 70],
436+
"raw": "*Date:* 26.12.2022 \\\n*Topic:* Infrastructure Test \\\n*Severity:* High \\",
423437
"type": "Paragraph"
424-
},
425-
{
426-
"loc": {
427-
"end": {
428-
"column": 18,
429-
"line": 3
430-
},
431-
"start": {
432-
"column": 17,
433-
"line": 3
434-
}
435-
},
436-
"range": [69, 70],
437-
"raw": "\\",
438-
"type": "Break",
439-
"value": "\\"
440438
}
441439
],
442440
"loc": {

test/unit/fixtures/Emphasis/output.json

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -180,40 +180,39 @@
180180
"raw": "\n",
181181
"type": "Str",
182182
"value": "\n"
183-
}
184-
],
185-
"loc": {
186-
"end": {
187-
"column": 0,
188-
"line": 4
189183
},
190-
"start": {
191-
"column": 0,
192-
"line": 3
193-
}
194-
},
195-
"range": [12, 22],
196-
"raw": "_ a b c _\n",
197-
"type": "Paragraph"
198-
},
199-
{
200-
"loc": {
201-
"end": {
202-
"column": 1,
203-
"line": 4
184+
{
185+
"loc": {
186+
"end": {
187+
"column": 1,
188+
"line": 4
189+
},
190+
"start": {
191+
"column": 0,
192+
"line": 4
193+
}
194+
},
195+
"range": [22, 23],
196+
"raw": "\\",
197+
"type": "Str",
198+
"value": "\\"
199+
},
200+
{
201+
"loc": {
202+
"end": {
203+
"column": 0,
204+
"line": 5
205+
},
206+
"start": {
207+
"column": 1,
208+
"line": 4
209+
}
210+
},
211+
"range": [23, 24],
212+
"raw": "\n",
213+
"type": "Str",
214+
"value": "\n"
204215
},
205-
"start": {
206-
"column": 0,
207-
"line": 4
208-
}
209-
},
210-
"range": [22, 23],
211-
"raw": "\\",
212-
"type": "Break",
213-
"value": "\\"
214-
},
215-
{
216-
"children": [
217216
{
218217
"loc": {
219218
"end": {
@@ -335,11 +334,11 @@
335334
},
336335
"start": {
337336
"column": 0,
338-
"line": 5
337+
"line": 3
339338
}
340339
},
341-
"range": [24, 45],
342-
"raw": "This is _emphasized_.",
340+
"range": [12, 45],
341+
"raw": "_ a b c _\n\\\nThis is _emphasized_.",
343342
"type": "Paragraph"
344343
}
345344
],

0 commit comments

Comments
 (0)