Skip to content

Commit

Permalink
Merge pull request #472 from nobkd/fix/md-lists-block-comp
Browse files Browse the repository at this point in the history
fix: starting lists in anonynous block tag
  • Loading branch information
tipiirai authored Feb 3, 2025
2 parents f7963f0 + 0c13354 commit fa3a241
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/nuemark/src/parse-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function processNestedBlocks(block, capture) {
const body = block.body.join('\n')

try {
if (body && name != '.' && isYAML(body.trim())) {
if (body && name && isYAML(body.trim())) {
let data = parseYAML(body)
if (Array.isArray(data)) data = { items: data }
Object.assign(block.data, data)
Expand Down
1 change: 0 additions & 1 deletion packages/nuemark/src/render-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ export function renderTag(tag, opts = {}) {
if (!fn) return renderIsland(tag, opts.data)

const data = { ...opts.data, ...extractData(tag.data, opts.data) }
const { blocks } = tag

const api = {
...tag,
Expand Down
5 changes: 5 additions & 0 deletions packages/nuemark/test/tag.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ test('[list] wrapper', () => {


// anonymous tag
test('.list', () => {
const html = renderLines(['[.list]', ' - elem 1', ' - elem 2'])
expect(html).toBe('<div class="list"><ul><li><p>elem 1</p></li>\n<li><p>elem 2</p></li></ul></div>')
})

test('.note', () => {
const html = renderLines(['[.note]', ' ## Note', ' Hello'])
expect(html).toBe('<div class="note"><h2>Note</h2>\n<p>Hello</p></div>')
Expand Down

0 comments on commit fa3a241

Please sign in to comment.