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 5.2.2 to 5.3.1

6

CHANGELOG.md
# Changelog
## 5.3.1 - 2023-08-27
**🌟 New**
- Escaped closing brackets are supported in links.
## 5.2.2 - 2023-08-24

@@ -4,0 +10,0 @@

2

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

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

@@ -326,3 +326,3 @@ # Parseur Markdown vers HTML pour Node.js

Un lien est composé de deux parties. Le texte, entouré de crochets (`[]`) suivi du lien, entouré de parenthèses (`( )`). i.e. `[Link](url)`
Un lien est composé de deux parties. Le texte, entouré de crochets (`[]`) suivi du lien, entouré de parenthèses (`( )`), i.e. `[Link](url)`. Les crochets fermants dans le texte doivent être précédés du caractère d'échappement.

@@ -339,2 +339,13 @@ *Exemple*

*Exemple avec un crochet fermant*
```
Selon [[1\]](#ref1), ce module est le meilleur !
```
```html
<p>Selon <a href="#ref1">[1]</a>, ce module est le meilleur !</p>
```
### Image

@@ -341,0 +352,0 @@

@@ -327,3 +327,3 @@ # Node.js Markdown to HTML Parser

A link is made up of two parts. The text in square brackets (`[]`), followed by an URL in round brackets (`( )`). i.e. `[Link](url)`
A link is made up of two parts. The text in square brackets (`[]`), followed by an URL in round brackets (`( )`), i.e. `[Link](url)`. Closing brackets in the text must be escaped.

@@ -339,3 +339,13 @@ *Example*

*Example with a closing bracket*
```
According to [[1\]](#ref1), this package is the best!
```
```html
<p>According to <a href="#ref1">[1]</a>, this package is the best!</p>
```
### Image

@@ -342,0 +352,0 @@

@@ -26,2 +26,6 @@ 'use strict'

new RegExp(`\\${MD_ESCAPE_CHAR}([${MD_CHARS}])`, 'g')
const REGEX_REP_ESC_CHAR_LINK_TEXT =
new RegExp(`\\${MD_ESCAPE_CHAR}\\]`, 'g')
const REGEX_CLOSING_LINK =
new RegExp(`^((?:[^\\]]|\\${MD_ESCAPE_CHAR}])+?)]\\(([^)]+?)\\)`)

@@ -657,3 +661,3 @@ const removeEscapeChars = text =>

} else if (allowLink) {
const endMatch = /^([^\]]+?)]\(([^)]+?)\)/.exec(restLineText)
const endMatch = REGEX_CLOSING_LINK.exec(restLineText)

@@ -664,2 +668,3 @@ if (endMatch) {

const title = endMatch[1]
.replace(REGEX_REP_ESC_CHAR_LINK_TEXT, ']')
const url = endMatch[2]

@@ -666,0 +671,0 @@

@@ -34,2 +34,10 @@ 'use strict'

test('Link with a closing bracket inside', function (t) {
const input = 'see [[1\\]](#ref1) (...)'
const output = '<p>see <a href="#ref1">[1]</a> (...)</p>'
t.equal(parseToHtml(input), output, 'Output is valid')
t.end()
})
test('Link with callback', function (t) {

@@ -36,0 +44,0 @@ const input = 'This is a [link](https://example.com)'

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