Skip to content

Commit

Permalink
Merge pull request #372 from nobkd/fix/space-around-block-md-followup
Browse files Browse the repository at this point in the history
fix: block ext spacing
  • Loading branch information
tipiirai authored Sep 24, 2024
2 parents 56b78b6 6f70f5a commit 9678786
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/nuemark/src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 170,9 @@ export function parseBlocks(lines) {
// code line
if (fenced) return fenced.content.push(line)

const trimmed = line.trimEnd()
// component
const trimmed = line.trim()
if (!comp && trimmed[0] == '[' && trimmed.slice(-1) == ']' && !line.includes('][')) {
if (line[0] == '[' && trimmed.slice(-1) == ']' && !line.includes('][')) {
comp = parseComponent(trimmed.slice(1, -1))
blocks.push(comp)
md = null
Expand Down
7 changes: 6 additions & 1 deletion packages/nuemark/test/nuemark.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 66,11 @@ test('nested code with comment', () => {
expect(html).toInclude('<sup>// hey</sup>')
})

test('multiple md extensions', () => {
const { html } = renderLines(['[.test] ', '\tcontent1', '[.test]', '\tcontent2'])
expect(html).toBe('<div class="test"><p>content1</p>\n</div>\n<div class="test"><p>content2</p>\n</div>')
})

test('parse fenced code', () => {
const blocks = parseBlocks(['# Hey', '``` md.foo#bar', '// hey', '[foo]', '```'])
const [hey, fenced] = blocks
Expand Down Expand Up @@ -119,7 124,7 @@ test('[tabs] key and wrapper', () => {


const NESTED_TABS = `
[tabs "Foo | Bar"]
[tabs "Foo | Bar"]
First
---
Second
Expand Down

0 comments on commit 9678786

Please sign in to comment.