Skip to content

Commit 9fff223

Browse files
fix: escape > only in wrapped line beginnings (#176)
1 parent a2b4d09 commit 9fff223

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/to-markdown.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ export function lineWrapTextHandler(node, parent, context, safeOptions) {
7373
if (line.length === 0 && word === '-') {
7474
word = '\\-';
7575
}
76+
// escape the greater symbol if a wrapped line start looks like a blockquote
77+
if (lines.length && line.length === 0 && word.startsWith('>')) {
78+
word = `\\>${word.substring(1)}`;
79+
}
7680
line.push(word);
7781
len += wordLen + 1;
7882
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Escape wrapped greater symbol
2+
3+
+-------+----------------------------------------------------------+
4+
| Title | Lorem ipsum dolor sit, consectetur elit. Vivamus rhoncus |
5+
| | \>95% metus tincidunt-990 |
6+
+-------+----------------------------------------------------------+

test/gridtable-to-md.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,21 @@ describe('gridtable to md', () => {
838838
await assertMD(mdast, 'gt-with-hyphen-wrap.md');
839839
});
840840

841+
it('table with unfortunate greater symbol wrap', async () => {
842+
const mdast = root([
843+
heading(2, text('Escape wrapped greater symbol')),
844+
gridTable([
845+
gtBody([
846+
gtRow([
847+
gtCell(text('Title')),
848+
gtCell(text('Lorem ipsum dolor sit, consectetur elit. Vivamus rhoncus >95% metus tincidunt-990')),
849+
]),
850+
]),
851+
]),
852+
]);
853+
await assertMD(mdast, 'gt-with-greater-wrap.md');
854+
});
855+
841856
it('table in list item', async () => {
842857
const mdast = root([
843858
heading(1, text('Table after List')),

0 commit comments

Comments
 (0)