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

marked-footnote

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marked-footnote - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

7

changelog.md

@@ -0,1 +1,8 @@

## marked-footnote [1.2.2](https://github.com/bent10/marked-extensions/compare/marked-footnote@1.2.1...marked-footnote@1.2.2) (2023-12-16)
### Bug Fixes
* ensure the footnotes token is consistently reset during each parsing process ([6f4d6d9](https://github.com/bent10/marked-extensions/commit/6f4d6d9a4b86740d75c0a992abffebd64281085c)), closes [#34](https://github.com/bent10/marked-extensions/issues/34)
## marked-footnote [1.2.1](https://github.com/bent10/marked-extensions/compare/marked-footnote@1.2.0...marked-footnote@1.2.1) (2023-12-13)

@@ -2,0 +9,0 @@

52

dist/index.js
function p(t, l) {
const n = {
const o = {
type: "footnotes",

@@ -13,3 +13,3 @@ raw: l,

tokenizer(r) {
t.hasFootnotes || (this.lexer.tokens.push(n), t.tokens = this.lexer.tokens, t.hasFootnotes = !0, n.rawItems = [], n.items = []);
t.hasFootnotes || (this.lexer.tokens.push(o), t.tokens = this.lexer.tokens, t.hasFootnotes = !0, o.rawItems = [], o.items = []);
const e = /^\[\^([^\]\n]+)\]:(?:[ \t]+|[\n]*?|$)([^\n]*?(?:\n|$)(?:\n*?[ ]{4,}[^\n]*)*)/.exec(

@@ -19,4 +19,4 @@ r

if (e) {
const [o, i, d = ""] = e;
let f = d.split(`
const [n, i, h = ""] = e;
let f = h.split(`
`).reduce((c, s) => c + `

@@ -34,3 +34,3 @@ ` + s.replace(/^(?:[ ]{4}|[\t])/, ""), "");

type: "footnote",
raw: o,
raw: n,
label: i,

@@ -40,3 +40,3 @@ refs: [],

};
return n.rawItems.push(a), a;
return o.rawItems.push(a), a;
}

@@ -50,3 +50,3 @@ },

function $(t, l = !1) {
let n = 0;
let o = 0;
return {

@@ -58,3 +58,3 @@ name: "footnoteRef",

if (e) {
const [o, i] = e, d = this.lexer.tokens[0], f = d.rawItems.filter(
const [n, i] = e, h = this.lexer.tokens[0], f = h.rawItems.filter(
(s) => s.label === i

@@ -64,15 +64,15 @@ );

return;
const u = f[0], a = d.items.filter((s) => s.label === i)[0], c = {
const u = f[0], a = h.items.filter((s) => s.label === i)[0], c = {
type: "footnoteRef",
raw: o,
raw: n,
id: "",
label: i
};
return a ? (c.id = `${n}:${a.refs.length + 1}`, a.refs.push(c)) : (n++, c.id = String(n), u.refs.push(c), d.items.push(u)), c;
return a ? (c.id = `${o}:${a.refs.length + 1}`, a.refs.push(c)) : (o++, c.id = String(o), u.refs.push(c), h.items.push(u)), c;
}
},
renderer({ id: r, label: e }) {
n = 0;
const o = encodeURIComponent(e);
return `<sup><a id="${t}ref-${o}" href="#${t + o}" data-${t}ref aria-describedby="${t}label">${l ? `[${r}]` : r}</a></sup>`;
o = 0;
const n = encodeURIComponent(e);
return `<sup><a id="${t}ref-${n}" href="#${t + n}" data-${t}ref aria-describedby="${t}label">${l ? `[${r}]` : r}</a></sup>`;
}

@@ -84,16 +84,16 @@ };

name: "footnotes",
renderer({ raw: l, items: n = [] }) {
if (n.length === 0)
renderer({ raw: l, items: o = [] }) {
if (o.length === 0)
return "";
const r = n.reduce(
(o, { label: i, content: d, refs: f }) => {
const u = encodeURIComponent(i), a = this.parser.parse(d).trimEnd(), c = a.endsWith("</p>");
const r = o.reduce(
(n, { label: i, content: h, refs: f }) => {
const u = encodeURIComponent(i), a = this.parser.parse(h).trimEnd(), c = a.endsWith("</p>");
let s = `<li id="${t + u}">
`;
return s += c ? a.replace(/<\/p>$/, "") : a, f.forEach((k, h) => {
s += ` <a href="#${t}ref-${u}" data-${t}backref aria-label="Back to reference ${i}">${h > 0 ? `↩<sup>${h + 1}</sup>` : "↩"}</a>`;
return s += c ? a.replace(/<\/p>$/, "") : a, f.forEach((k, d) => {
s += ` <a href="#${t}ref-${u}" data-${t}backref aria-label="Back to reference ${i}">${d > 0 ? `↩<sup>${d + 1}</sup>` : "↩"}</a>`;
}), s += c ? `</p>
` : `
`, s += `</li>
`, o + s;
`, n + s;
},

@@ -115,3 +115,3 @@ ""

prefixId: l = "footnote-",
description: n = "Footnotes",
description: o = "Footnotes",
refMarkers: r

@@ -121,8 +121,8 @@ } = t, e = { hasFootnotes: !1, tokens: [] };

extensions: [
p(e, n),
p(e, o),
$(l, r),
m(l)
],
walkTokens(o) {
o.type === "footnotes" && e.tokens.indexOf(o) === 0 && o.items.length && (e.tokens[0] = { type: "space", raw: "" }, e.tokens.push(o), e.hasFootnotes = !1);
walkTokens(n) {
n.type === "footnotes" && e.tokens.indexOf(n) === 0 && n.items.length && (e.tokens[0] = { type: "space", raw: "" }, e.tokens.push(n)), e.hasFootnotes && (e.hasFootnotes = !1);
}

@@ -129,0 +129,0 @@ };

@@ -15,2 +15,2 @@ (function(h,p){typeof exports=="object"&&typeof module<"u"?module.exports=p():typeof define=="function"&&define.amd?define(p):(h=typeof globalThis<"u"?globalThis:h||self,h.markedFootnote=p())})(this,function(){"use strict";function h(t,c){const n={type:"footnotes",raw:c,rawItems:[],items:[]};return{name:"footnote",level:"block",childTokens:["content"],tokenizer(r){t.hasFootnotes||(this.lexer.tokens.push(n),t.tokens=this.lexer.tokens,t.hasFootnotes=!0,n.rawItems=[],n.items=[]);const e=/^\[\^([^\]\n]+)\]:(?:[ \t]+|[\n]*?|$)([^\n]*?(?:\n|$)(?:\n*?[ ]{4,}[^\n]*)*)/.exec(r);if(e){const[o,f,u=""]=e;let l=u.split(`

`,e+=`</section>
`,e}}}function k(t={}){const{prefixId:c="footnote-",description:n="Footnotes",refMarkers:r}=t,e={hasFootnotes:!1,tokens:[]};return{extensions:[h(e,n),p(c,r),$(c)],walkTokens(o){o.type==="footnotes"&&e.tokens.indexOf(o)===0&&o.items.length&&(e.tokens[0]={type:"space",raw:""},e.tokens.push(o),e.hasFootnotes=!1)}}}return k});
`,e}}}function k(t={}){const{prefixId:c="footnote-",description:n="Footnotes",refMarkers:r}=t,e={hasFootnotes:!1,tokens:[]};return{extensions:[h(e,n),p(c,r),$(c)],walkTokens(o){o.type==="footnotes"&&e.tokens.indexOf(o)===0&&o.items.length&&(e.tokens[0]={type:"space",raw:""},e.tokens.push(o)),e.hasFootnotes&&(e.hasFootnotes=!1)}}}return k});
{
"name": "marked-footnote",
"description": "A marked extension to support GFM footnotes",
"version": "1.2.1",
"version": "1.2.2",
"publishConfig": {

@@ -6,0 +6,0 @@ "access": "public"

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