Skip to content

Commit 4f907eb

Browse files
Fix angle bracket preservation in table cells and paragraphs (#18)
1 parent 6cf76d9 commit 4f907eb

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

package-lock.json

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

src/parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ function cleanContentOutsideCodeBlocks(content) {
1313
.replace(/<br\s*\/?>/gi, "\n")
1414
.replace(/\u2014/g, "-")
1515
.replace(/\u2013/g, "-");
16-
while (/<[^>]+>/.test(line)) {
17-
line = line.replace(/<[^>]+>/g, "");
16+
while (/<\/?[a-zA-Z][^>]*>/.test(line)) {
17+
line = line.replace(/<\/?[a-zA-Z][^>]*>/g, "");
1818
}
1919
return line;
2020
})
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Feature: Table rendering in preview
2+
3+
Background:
4+
Given the application is loaded
5+
6+
Scenario: Table with angle brackets preserves cell content
7+
Given the editor contains:
8+
"""
9+
| Category | Small | Medium | Large |
10+
|---|---|---|---|
11+
| Items | <50 units | 50-100 units | >100 units |
12+
| Rules | <20 basic | 20-60 advanced | >60 complex |
13+
"""
14+
When the preview renders
15+
Then the preview should contain a "table" element
16+
And the "table" should have 3 "tr" children
17+
And the table should have 4 columns
18+
And the preview should contain text "<50 units"
19+
And the preview should contain text ">100 units"
20+
And the preview should contain text "<20 basic"
21+
And the preview should contain text ">60 complex"
22+
23+
Scenario: Table with mixed angle brackets and regular content
24+
Given the editor contains:
25+
"""
26+
| Metric | Threshold |
27+
|---|---|
28+
| Score | >90 points |
29+
| Errors | <5 allowed |
30+
| Range | 10-20 items |
31+
"""
32+
When the preview renders
33+
Then the preview should contain a "table" element
34+
And the "table" should have 4 "tr" children
35+
And the preview should contain text ">90 points"
36+
And the preview should contain text "<5 allowed"
37+
38+
Scenario: Paragraph with angle brackets preserves content
39+
Given the editor contains:
40+
"""
41+
The value should be <100 and >50 for valid results.
42+
"""
43+
When the preview renders
44+
Then the preview should contain text "<100"
45+
And the preview should contain text ">50"

0 commit comments

Comments
 (0)