@@ -41,4 +41,33 @@ describe('renderMarkdown', () => {
|
||||
expect(renderMarkdown('- a\n- b')).toContain('<ul><li>a</li><li>b</li></ul>')
|
||||
expect(renderMarkdown('1. a\n2. b')).toContain('<ol><li>a</li><li>b</li></ol>')
|
||||
})
|
||||
|
||||
it('renders a GFM table with header, body and inline markup', () => {
|
||||
const html = renderMarkdown('| a | b |\n|---|---|\n| 1 | `x` |\n| 2 | **y** |')
|
||||
expect(html).toContain('<table class="md-table">')
|
||||
expect(html).toContain('<thead><tr><th>a</th><th>b</th></tr></thead>')
|
||||
expect(html).toContain('<td>1</td><td><code>x</code></td>')
|
||||
expect(html).toContain('<strong>y</strong>')
|
||||
})
|
||||
|
||||
it('applies column alignment from the delimiter row', () => {
|
||||
const html = renderMarkdown('| l | c | r |\n| :-- | :-: | --: |\n| 1 | 2 | 3 |')
|
||||
expect(html).toContain('<th style="text-align:left">l</th>')
|
||||
expect(html).toContain('<th style="text-align:center">c</th>')
|
||||
expect(html).toContain('<th style="text-align:right">r</th>')
|
||||
expect(html).toContain('<td style="text-align:center">2</td>')
|
||||
})
|
||||
|
||||
it('handles escaped pipes, ragged rows and pipe-less prose after the table', () => {
|
||||
const html = renderMarkdown('| a | b |\n|---|---|\n| x \\| y | 2 |\n| short |\n\nAfter.')
|
||||
expect(html).toContain('<td>x | y</td>')
|
||||
expect(html).toContain('<td>short</td><td></td>')
|
||||
expect(html).toContain('<p>After.</p>')
|
||||
})
|
||||
|
||||
it('leaves a pipe-bearing paragraph alone when no delimiter row follows', () => {
|
||||
const html = renderMarkdown('a | b\nnot a table')
|
||||
expect(html).not.toContain('<table')
|
||||
expect(html).toContain('<p>a | b not a table</p>')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user