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

marked-gfm-heading-id

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marked-gfm-heading-id - npm Package Compare versions

Comparing version 3.2.0 to 4.0.0

25

lib/index.umd.js

@@ -91,2 +91,19 @@ (function (global, factory) {

// unescape from marked helpers
const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
/* istanbul ignore next */
function unescape(html) {
// explicitly match decimal, hex, and named HTML entities
return html.replace(unescapeTest, (_, n) => {
n = n.toLowerCase();
if (n === 'colon') return ':';
if (n.charAt(0) === '#') {
return n.charAt(1) === 'x'
? String.fromCharCode(parseInt(n.substring(2), 16))
: String.fromCharCode(+n.substring(1));
}
return '';
});
}
function gfmHeadingId({ prefix = '', globalSlugs = false } = {}) {

@@ -103,8 +120,11 @@ return {

},
useNewRenderer: true,
renderer: {
heading(text, level, raw) {
raw = raw
heading({ tokens, depth }) {
const text = this.parser.parseInline(tokens);
const raw = unescape(this.parser.parseInline(tokens, this.parser.textRenderer))
.toLowerCase()
.trim()
.replace(/<[!\/a-z].*?>/gi, '');
const level = depth;
const id = `${prefix}${slugger.slug(raw)}`;

@@ -132,3 +152,4 @@ const heading = { level, text, id };

exports.resetHeadings = resetHeadings;
exports.unescape = unescape;
}));

12

package.json
{
"name": "marked-gfm-heading-id",
"version": "3.2.0",
"version": "4.0.0",
"description": "marked GFM heading ids",

@@ -42,3 +42,3 @@ "main": "./lib/index.cjs",

"peerDependencies": {
"marked": ">=4 <13"
"marked": ">=13 <14"
},

@@ -49,4 +49,4 @@ "dependencies": {

"devDependencies": {
"@babel/core": "^7.24.6",
"@babel/preset-env": "^7.24.6",
"@babel/core": "^7.24.7",
"@babel/preset-env": "^7.24.7",
"@rollup/plugin-node-resolve": "^15.2.3",

@@ -56,3 +56,3 @@ "@semantic-release/changelog": "^6.0.3",

"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^10.0.5",
"@semantic-release/github": "^10.0.6",
"@semantic-release/npm": "^12.0.1",

@@ -67,3 +67,3 @@ "@semantic-release/release-notes-generator": "^14.0.0",

"jest-cli": "^29.7.0",
"marked": "^12.0.2",
"marked": "^13.0.0",
"rollup": "^4.18.0",

@@ -70,0 +70,0 @@ "semantic-release": "^24.0.0",

@@ -6,2 +6,19 @@ import GithubSlugger from 'github-slugger';

// unescape from marked helpers
const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
/* istanbul ignore next */
export function unescape(html) {
// explicitly match decimal, hex, and named HTML entities
return html.replace(unescapeTest, (_, n) => {
n = n.toLowerCase();
if (n === 'colon') return ':';
if (n.charAt(0) === '#') {
return n.charAt(1) === 'x'
? String.fromCharCode(parseInt(n.substring(2), 16))
: String.fromCharCode(+n.substring(1));
}
return '';
});
}
export function gfmHeadingId({ prefix = '', globalSlugs = false } = {}) {

@@ -18,8 +35,11 @@ return {

},
useNewRenderer: true,
renderer: {
heading(text, level, raw) {
raw = raw
heading({ tokens, depth }) {
const text = this.parser.parseInline(tokens);
const raw = unescape(this.parser.parseInline(tokens, this.parser.textRenderer))
.toLowerCase()
.trim()
.replace(/<[!\/a-z].*?>/gi, '');
const level = depth;
const id = `${prefix}${slugger.slug(raw)}`;

@@ -26,0 +46,0 @@ const heading = { level, text, id };

Sorry, the diff of this file is not supported yet

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