Socket
Socket
Sign inDemoInstall

@deskeen/markdown

Package Overview
Dependencies
0
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.1.0 to 4.1.1

5

CHANGELOG.md
# Changelog
## 4.1.1 - 2021-03-02
**🌟 New**
- A footnote can be referenced more than once.
## 4.1.0 - 2021-02-19

@@ -4,0 +9,0 @@

2

package.json
{
"name": "@deskeen/markdown",
"version": "4.1.0",
"version": "4.1.1",
"description": "Node.js Markdown to HTML Parser",

@@ -5,0 +5,0 @@ "author": "Morgan Schmiedt",

@@ -113,3 +113,4 @@ 'use strict'

const fnNote = {}
const fnIdList = []
const fnIdList = new Set()
const fnIdNb = new Map()

@@ -614,6 +615,12 @@ const flushBody = () => {

const ref = refMatch[1]
const refNb = fnIdList.length + 1
const id = refMatch[1]
let refNb
fnIdList.push(ref)
if (fnIdList.has(id) === false) {
fnIdList.add(id)
refNb = fnIdList.size
fnIdNb.set(id, refNb)
} else {
refNb = fnIdNb.get(id)
}

@@ -627,3 +634,3 @@ const supNode = document.createElement('SUP')

linkNode.onAttach = opt.onReference != null
? node => opt.onReference(node, ref)
? node => opt.onReference(node, id)
: undefined

@@ -725,3 +732,3 @@

for (const ref of fnIdList) {
for (const ref of fnIdList.keys()) {
const refValue = fnNote[ref]

@@ -728,0 +735,0 @@

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

test('Reference with text ref', function (t) {
test('Reference with two ids below text', function (t) {
const input = `

@@ -105,2 +105,52 @@ See this[^one] and that[^two]

test('Reference with two ids above text', function (t) {
const input = `
[^one]: ref one
[^two]: ref two
See this[^one] and that[^two]`
const output = inlineHtml`
<p>See this<a href="#reference1"><sup>1</sup></a> and that<a href="#reference2"><sup>2</sup></a></p>
<section>
<ol>
<li id="reference1">ref one</li>
<li id="reference2">ref two</li>
</ol>
</section>`
const opt = {
allowFootnote: true,
}
t.equal(parseToHtml(input, opt), output, 'Output is valid')
t.end()
})
test('Reference with two ids in between text lines', function (t) {
const input = `
See this[^one]
[^one]: ref one
And that[^two]
[^two]: ref two`
const output = inlineHtml`
<p>See this<a href="#reference1"><sup>1</sup></a></p>
<p>And that<a href="#reference2"><sup>2</sup></a></p>
<section>
<ol>
<li id="reference1">ref one</li>
<li id="reference2">ref two</li>
</ol>
</section>`
const opt = {
allowFootnote: true,
}
t.equal(parseToHtml(input, opt), output, 'Output is valid')
t.end()
})
test('Reference with missing ref key', function (t) {

@@ -151,2 +201,47 @@ const input = `

test('Reference with two ids', function (t) {
const input = `
See this[^one] and that[^one]
[^one]: ref one`
const output = inlineHtml`
<p>See this<a href="#reference1"><sup>1</sup></a> and that<a href="#reference1"><sup>1</sup></a></p>
<section>
<ol>
<li id="reference1">ref one</li>
</ol>
</section>`
const opt = {
allowFootnote: true,
}
t.equal(parseToHtml(input, opt), output, 'Output is valid')
t.end()
})
test('Reference with two notes', function (t) {
const input = `
See this[^one]
[^one]: ref one
[^one]: ref two`
const output = inlineHtml`
<p>See this<a href="#reference1"><sup>1</sup></a></p>
<section>
<ol>
<li id="reference1">ref two</li>
</ol>
</section>`
const opt = {
allowFootnote: true,
}
t.equal(parseToHtml(input, opt), output, 'Output is valid')
t.end()
})
test('Reference with complex texts', function (t) {

@@ -153,0 +248,0 @@ const input = `

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc