Skip to content

Commit

Permalink
quick nuemark inline span support
Browse files Browse the repository at this point in the history
  • Loading branch information
nobkd committed Jan 31, 2025
1 parent 81e5ed7 commit e14f975
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/nuemark/src/parse-inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const PARSERS = [
// parse tag
const tag = parseTag(str.slice(1, i).trim())
const { name } = tag
const is_footnote = name[0] == '^'
const is_footnote = name && name[0] == '^'
const end = i + 1

// footnote?
Expand All @@ -90,6 +90,8 @@ const PARSERS = [
// normal tag
if (name == '!' || isValidName(name)) return { is_tag: true, ...tag, end }

if (!name) return { is_tag: true, ...tag, name: 'span', end }

return { text: c }
}
},
Expand Down
6 changes: 5 additions & 1 deletion packages/nuemark/src/render-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ export function renderTag(tag, opts={}) {
const tags = { ...TAGS, ...opts.tags }
const fn = tags[tag.name || 'block']

if (!fn) return renderIsland(tag, opts.data)
if (!fn) {
// TODO: import html tags array, fix stuff for blocks
if (tag.name == 'span') return elem(tag.name, tag.attr, renderInline(tag.data?._))
return renderIsland(tag, opts.data)
}

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

0 comments on commit e14f975

Please sign in to comment.