New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nuemark

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuemark - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

2

index.js

@@ -16,4 +16,4 @@

/* utilities */
export { parseSize, renderIcon } from './src/render-tag.js'
export { renderInline } from './src/render-inline.js'
export { parseSize } from './src/render-tag.js'
export { elem } from './src/render-blocks.js'
{
"name": "nuemark",
"version": "0.6.0",
"version": "0.6.1",
"description": "Markdown flavour for rich, interactive websites",

@@ -5,0 +5,0 @@ "homepage": "https://nuejs.org",

@@ -33,3 +33,3 @@

// end of code
// end of code
} else {

@@ -79,6 +79,6 @@ return block = null

if (!block?.is_list) {
block = { is_list: true, numbered, entries: [[ line ]] }
block = { is_list: true, numbered, entries: [[line]] }
return blocks.push(block)
// new list item
// new list item
} else {

@@ -145,11 +145,11 @@ return block.entries.push([line])

// blockquotes
// blockquotes
} else if (block?.is_quote && c) {
if (c) block.content.push(line)
// content (append)
// content (append)
} else if (block?.is_content) {
block.content.push(line)
// new content block
// new content block
} else {

@@ -156,0 +156,0 @@ block = c ? { is_content: true, content: [line] } : { is_newline: true }

@@ -10,3 +10,3 @@

// OPTS: { data, sections, heading_ids, links, tags }
// OPTS: { data, sections, content_wrapper, heading_ids, links, tags }
export function parseDocument(lines) {

@@ -33,6 +33,8 @@ const meta = stripMeta(lines)

const classList = Array.isArray(opts.sections) ? opts.sections : []
const wrap = opts.content_wrapper
const html = []
sections.forEach((section, i) => {
html.push(elem('section', { class: classList[i] }, renderBlocks(section, opts)))
const content = renderBlocks(section, opts)
html.push(elem('section', { class: classList[i] }, wrap ? elem('div', { class: wrap }, content) : content))
})

@@ -52,5 +54,12 @@ return html.join('\n\n')

const navs = sections.map(renderNav).join('\n').trim()
return elem('div', { 'aria-label': 'Table of contents', ...attr }, navs)
return elem('div', { class: attr.class }, navs)
},
get headings() {
return blocks.filter(b => !!b.level).map(h => {
const id = h.attr.id || createHeadingId(h.text)
return { id, ...h }
})
},
codeblocks: blocks.filter(el => el.is_code),

@@ -97,3 +106,3 @@ meta,

const links = headings.map(h => {
const id = h.attr.id ||createHeadingId(h.text)
const id = h.attr.id || createHeadingId(h.text)
const label = h.level == 2 ? elem('strong', h.text) : h.text

@@ -100,0 +109,0 @@ return elem('a', { href: `#${ id }` }, label)

@@ -9,3 +9,5 @@

const { str, getValue } = valueGetter(input)
const [specs, ...attribs] = str.split(/\s+/)
const strings = str.split(/\s+/)
const specs = strings.filter((s, i) => !i || s.match(/^[#|.]/)).join('')
const attribs = strings.filter(s => !specs.includes(s))
const self = { ...parseSpecs(specs), data: {} }

@@ -55,3 +57,3 @@

if (key[0] == ':' && key.slice(-1) == ':') {
return strings[1 * key.slice(1, -1) -1]
return strings[1 * key.slice(1, -1) - 1]
}

@@ -58,0 +60,0 @@ }

@@ -15,3 +15,3 @@

export function renderBlocks(blocks, opts={}) {
export function renderBlocks(blocks, opts = {}) {
return blocks.map(b => renderBlock(b, opts)).join('\n')

@@ -26,10 +26,10 @@ }

block.is_heading ? renderHeading(block, opts) :
block.is_quote ? elem('blockquote', renderBlocks(block.blocks, opts)) :
block.is_tag ? renderTag(block, opts) :
block.is_table ? renderTable(block, opts) :
block.is_list ? renderList(block, opts) :
block.is_code ? renderCode(block, opts) :
block.is_newline ? '' :
block.is_break ? '<hr>' :
console.error('Unknown block', block)
block.is_quote ? elem('blockquote', renderBlocks(block.blocks, opts)) :
block.is_tag ? renderTag(block, opts) :
block.is_table ? renderTable(block, opts) :
block.is_list ? renderList(block, opts) :
block.is_code ? renderCode(block, opts) :
block.is_newline ? '' :
block.is_break ? '<hr>' :
console.error('Unknown block', block)
}

@@ -43,3 +43,3 @@

export function renderHeading(h, opts={}) {
export function renderHeading(h, opts = {}) {
const attr = { ...h.attr }

@@ -50,3 +50,3 @@ const show_id = opts.heading_ids

// anchor
const a = show_id ? elem('a', { href: `#${ attr.id }`, title: h.text }) : ''
const a = show_id ? elem('a', { href: `#${attr.id}`, title: h.text }) : ''

@@ -73,3 +73,3 @@ return elem('h' + h.level, attr, a + renderTokens(h.tokens, opts))

delete attr.class
let html = elem('pre', attr, glow(code, { language: name, numbered}))
let html = elem('pre', attr, glow(code, { language: name, numbered }))

@@ -104,3 +104,3 @@ const caption = data.caption || data._

const val = attr[key]
if (val) arr.push(val === true ? key :`${key}="${val}"`)
if (val) arr.push(val === true ? key : `${key}="${val}"`)
}

@@ -107,0 +107,0 @@ return arr[0] ? ' ' + arr.join(' ') : ''

@@ -88,9 +88,7 @@

const src = data.src || data._
const path = join('.', src)
return src ? readIcon(src) : ''
},
try {
return src?.endsWith('.svg') && readFileSync(path, 'utf-8')
} catch (e) {
console.error('svg not found', path)
}
icon(data) {
return renderIcon(data.src || data._, data.symbol, data.icon_dir)
},

@@ -123,2 +121,25 @@

export function readIcon(path, icon_dir) {
if (!path.endsWith('.svg')) {
path += '.svg'
if (icon_dir && path[0] != '/') path = join(icon_dir, path)
}
path = join('.', path)
try {
const svg = readFileSync(path, 'utf-8')
return svg.replace('<svg', '<svg class="icon"')
} catch (e) {
console.error('svg not found', path)
return ''
}
}
export function renderIcon(name, symbol, icon_dir) {
return name ? readIcon(name, icon_dir) : symbol ? elem('svg', { class: 'icon icon-' + symbol }, `<use href="#${symbol}"/>`) : ''
}
export function renderTag(tag, opts={}) {

@@ -125,0 +146,0 @@ const tags = { ...TAGS, ...opts.tags }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc