Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mdast-util-to-hast

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-to-hast - npm Package Compare versions

Comparing version 3.0.4 to 4.0.0

31

lib/footer.js

@@ -15,2 +15,5 @@ 'use strict'

var def
var backReference
var content
var tail

@@ -23,12 +26,22 @@ if (!length) {

def = footnotes[index]
content = def.children.concat()
tail = content[content.length - 1]
backReference = {
type: 'link',
url: '#fnref-' + def.identifier,
data: {hProperties: {className: ['footnote-backref']}},
children: [{type: 'text', value: '↩'}]
}
if (!tail || tail.type !== 'paragraph') {
tail = {type: 'paragraph', children: []}
content.push(tail)
}
tail.children.push(backReference)
listItems[index] = {
type: 'listItem',
data: {hProperties: {id: 'fn-' + def.identifier}},
children: def.children.concat({
type: 'link',
url: '#fnref-' + def.identifier,
data: {hProperties: {className: ['footnote-backref']}},
children: [{type: 'text', value: '↩'}]
}),
children: content,
position: def.position

@@ -45,7 +58,3 @@ }

thematicBreak(h),
list(h, {
type: 'list',
ordered: true,
children: listItems
})
list(h, {type: 'list', ordered: true, children: listItems})
],

@@ -52,0 +61,0 @@ true

@@ -12,23 +12,36 @@ 'use strict'

var head = children[0]
var raw = all(h, node)
var loose = parent ? listLoose(parent) : listItemLoose(node)
var props = {}
var single = false
var result
var container
var index
var length
var child
if (
(!parent || !parent.loose) &&
children.length === 1 &&
head.type === 'paragraph'
) {
single = true
/* Tight lists should not render 'paragraph' nodes as 'p' tags */
if (loose) {
result = raw
} else {
result = []
length = raw.length
index = -1
while (++index < length) {
child = raw[index]
if (child.tagName === 'p') {
result = result.concat(child.children)
} else {
result.push(child)
}
}
}
result = all(h, single ? head : node)
if (typeof node.checked === 'boolean') {
if (!single && (!head || head.type !== 'paragraph')) {
if (loose && (!head || head.type !== 'paragraph')) {
result.unshift(h(null, 'p', []))
}
container = single ? result : result[0].children
container = loose ? result[0].children : result

@@ -51,3 +64,3 @@ if (container.length !== 0) {

if (!single && result.length !== 0) {
if (loose && result.length !== 0) {
result = wrap(result, true)

@@ -58,1 +71,22 @@ }

}
function listLoose(node) {
var loose = node.spread
var children = node.children
var length = children.length
var index = -1
while (!loose && ++index < length) {
loose = listItemLoose(children[index])
}
return loose
}
function listItemLoose(node) {
var spread = node.spread
return spread === undefined || spread === null
? node.children.length > 1
: spread
}

@@ -19,3 +19,3 @@ 'use strict'

} else if (subtype === 'full') {
suffix += '[' + node.identifier + ']'
suffix += '[' + (node.label || node.identifier) + ']'
}

@@ -22,0 +22,0 @@

{
"name": "mdast-util-to-hast",
"version": "3.0.4",
"version": "4.0.0",
"description": "Transform mdast to hast",

@@ -53,2 +53,8 @@ "license": "MIT",

},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"prettier": {

@@ -55,0 +61,0 @@ "tabWidth": 2,

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