Socket
Socket
Sign inDemoInstall

marked-alert

Package Overview
Dependencies
1
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

12

changelog.md

@@ -0,1 +1,13 @@

# marked-alert [1.1.0](https://github.com/bent10/marked-extensions/compare/marked-alert@1.0.0...marked-alert@1.1.0) (2023-10-23)
### Bug Fixes
* resolves `titleClassName` ([bd15589](https://github.com/bent10/marked-extensions/commit/bd15589e6b134a7181db09ce41185c4297d11528))
### Features
* supports customizing alert `title` ([59ba2f9](https://github.com/bent10/marked-extensions/commit/59ba2f978a86504c2f5828266ea64a39b4936085))
# marked-alert 1.0.0 (2023-10-23)

@@ -2,0 +14,0 @@

8

dist/index.cjs.js

@@ -1,4 +0,4 @@

"use strict";const d=[{type:"note",icon:'<svg class="octicon octicon-info mr-2" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path></svg>',titleClassName:"color-fg-accent"},{type:"important",icon:'<svg class="octicon octicon-report mr-2" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg>',titleClassName:"color-fg-done"},{type:"warning",icon:'<svg class="octicon octicon-alert mr-2" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg>',titleClassName:"color-fg-attention"}];function g(e){return e.length?Object.values([...d,...e].reduce((r,s)=>(r[s.type]=s,r),{})):d}function m(e){return`^(?:\\[\\!${e.toUpperCase()}\\]|[\\*]{2}${u(e)}[\\*]{2})[s]*?
?`}function u(e){return e.slice(0,1).toUpperCase()+e.slice(1).toLowerCase()}function x(e={}){const{className:r="markdown-alert",variants:s=[]}=e,f=g(s);return{walkTokens(t){var a,c,l;if(t.type!=="blockquote")return;const i=f.find(({type:n})=>new RegExp(m(n)).test(t.text));if(i){const{type:n,icon:v,titleClassName:h=`text-${n}`}=i,o=(a=t.tokens)==null?void 0:a[0],p=(c=o.raw)==null?void 0:c.replace(new RegExp(m(n)),"");o.tokens=[{type:"text",raw:o.raw,text:`<span class="${h} text-semibold d-inline-flex flex-items-center mb-1">${v+u(n)}</span>${p?`<br />${p}`:""}`}],Object.assign(t,{type:"alert",meta:{variant:n,icon:v,titleClassName:h}}),(l=t.tokens)==null||l.splice(0,1,o)}},extensions:[{name:"alert",level:"block",renderer({meta:t,tokens:i=[]}){let a=`<div class="${r} ${r}-${t.variant}">
`;return a+=this.parser.parse(i),a+=`</div>
`,a}}]}}module.exports=x;
"use strict";const m=[{type:"note",icon:'<svg class="octicon octicon-info mr-2" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path></svg>',titleClassName:"color-fg-accent"},{type:"important",icon:'<svg class="octicon octicon-report mr-2" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg>',titleClassName:"color-fg-done"},{type:"warning",icon:'<svg class="octicon octicon-alert mr-2" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg>',titleClassName:"color-fg-attention"}];function w(e){return e.length?Object.values([...m,...e].reduce((t,r)=>(t[r.type]=r,t),{})):m}function C(e,t){return t?["note","important","warning"].includes(e)?`${t} text-semibold d-inline-flex flex-items-center mb-1`:t:`text-${e} text-semibold d-inline-flex flex-items-center mb-1`}function u(e){return`^(?:\\[\\!${e.toUpperCase()}\\]|[\\*]{2}${f(e)}[\\*]{2})[s]*?
?`}function f(e){return e.slice(0,1).toUpperCase()+e.slice(1).toLowerCase()}function Z(e={}){const{className:t="markdown-alert",variants:r=[]}=e,x=w(r);return{walkTokens(a){var n,l,c;if(a.type!=="blockquote")return;const s=x.find(({type:i})=>new RegExp(u(i)).test(a.text));if(s){const{type:i,icon:v,title:h=f(i),titleClassName:g}=s,o=(n=a.tokens)==null?void 0:n[0],p=(l=o.raw)==null?void 0:l.replace(new RegExp(u(i)),""),d=C(i,g);o.tokens=[{type:"text",raw:o.raw,text:`<span class="${d}">${v+h}</span>${p?`<br />${p}`:""}`}],Object.assign(a,{type:"alert",meta:{variant:i,icon:v,title:h,titleClassName:d}}),(c=a.tokens)==null||c.splice(0,1,o)}},extensions:[{name:"alert",level:"block",renderer({meta:a,tokens:s=[]}){let n=`<div class="${t} ${t}-${a.variant}">
`;return n+=this.parser.parse(s),n+=`</div>
`,n}}]}}module.exports=Z;

@@ -5,4 +5,4 @@ import type { MarkedExtension } from 'marked';

/**
* A [marked](https://marked.js.org/) extension to support [GFM alert](https://github.com/orgs/community/discussions/16925).
* A [marked](https://marked.js.org/) extension to support [GFM alerts](https://github.com/orgs/community/discussions/16925).
*/
export default function markedAlert(options?: Options): MarkedExtension;

@@ -1,2 +0,2 @@

const d = [
const m = [
{

@@ -18,12 +18,15 @@ type: "note",

];
function g(e) {
function w(e) {
return e.length ? Object.values(
[...d, ...e].reduce(
(r, i) => (r[i.type] = i, r),
[...m, ...e].reduce(
(t, r) => (t[r.type] = r, t),
{}
)
) : d;
) : m;
}
function m(e) {
return `^(?:\\[\\!${e.toUpperCase()}\\]|[\\*]{2}${u(
function C(e, t) {
return t ? ["note", "important", "warning"].includes(e) ? `${t} text-semibold d-inline-flex flex-items-center mb-1` : t : `text-${e} text-semibold d-inline-flex flex-items-center mb-1`;
}
function u(e) {
return `^(?:\\[\\!${e.toUpperCase()}\\]|[\\*]{2}${f(
e

@@ -33,24 +36,25 @@ )}[\\*]{2})[s]*?

}
function u(e) {
function f(e) {
return e.slice(0, 1).toUpperCase() + e.slice(1).toLowerCase();
}
function x(e = {}) {
const { className: r = "markdown-alert", variants: i = [] } = e, f = g(i);
function Z(e = {}) {
const { className: t = "markdown-alert", variants: r = [] } = e, x = w(r);
return {
walkTokens(t) {
var a, c, l;
if (t.type !== "blockquote")
walkTokens(a) {
var n, l, c;
if (a.type !== "blockquote")
return;
const s = f.find(
({ type: n }) => new RegExp(m(n)).test(t.text)
const s = x.find(
({ type: i }) => new RegExp(u(i)).test(a.text)
);
if (s) {
const {
type: n,
type: i,
icon: v,
titleClassName: h = `text-${n}`
} = s, o = (a = t.tokens) == null ? void 0 : a[0], p = (c = o.raw) == null ? void 0 : c.replace(
new RegExp(m(n)),
title: h = f(i),
titleClassName: g
} = s, o = (n = a.tokens) == null ? void 0 : n[0], d = (l = o.raw) == null ? void 0 : l.replace(
new RegExp(u(i)),
""
);
), p = C(i, g);
o.tokens = [

@@ -60,8 +64,13 @@ {

raw: o.raw,
text: `<span class="${h} text-semibold d-inline-flex flex-items-center mb-1">${v + u(n)}</span>${p ? `<br />${p}` : ""}`
text: `<span class="${p}">${v + h}</span>${d ? `<br />${d}` : ""}`
}
], Object.assign(t, {
], Object.assign(a, {
type: "alert",
meta: { variant: n, icon: v, titleClassName: h }
}), (l = t.tokens) == null || l.splice(0, 1, o);
meta: {
variant: i,
icon: v,
title: h,
titleClassName: p
}
}), (c = a.tokens) == null || c.splice(0, 1, o);
}

@@ -73,7 +82,7 @@ },

level: "block",
renderer({ meta: t, tokens: s = [] }) {
let a = `<div class="${r} ${r}-${t.variant}">
renderer({ meta: a, tokens: s = [] }) {
let n = `<div class="${t} ${t}-${a.variant}">
`;
return a += this.parser.parse(s), a += `</div>
`, a;
return n += this.parser.parse(s), n += `</div>
`, n;
}

@@ -85,3 +94,3 @@ }

export {
x as default
Z as default
};

@@ -1,4 +0,4 @@

(function(a,r){typeof exports=="object"&&typeof module<"u"?module.exports=r():typeof define=="function"&&define.amd?define(r):(a=typeof globalThis<"u"?globalThis:a||self,a.markedAlert=r())})(this,function(){"use strict";const a=[{type:"note",icon:'<svg class="octicon octicon-info mr-2" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path></svg>',titleClassName:"color-fg-accent"},{type:"important",icon:'<svg class="octicon octicon-report mr-2" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg>',titleClassName:"color-fg-done"},{type:"warning",icon:'<svg class="octicon octicon-alert mr-2" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg>',titleClassName:"color-fg-attention"}];function r(e){return e.length?Object.values([...a,...e].reduce((s,o)=>(s[o.type]=o,s),{})):a}function d(e){return`^(?:\\[\\!${e.toUpperCase()}\\]|[\\*]{2}${p(e)}[\\*]{2})[s]*?
?`}function p(e){return e.slice(0,1).toUpperCase()+e.slice(1).toLowerCase()}function g(e={}){const{className:s="markdown-alert",variants:o=[]}=e,x=r(o);return{walkTokens(t){var n,h,v;if(t.type!=="blockquote")return;const c=x.find(({type:i})=>new RegExp(d(i)).test(t.text));if(c){const{type:i,icon:u,titleClassName:f=`text-${i}`}=c,l=(n=t.tokens)==null?void 0:n[0],m=(h=l.raw)==null?void 0:h.replace(new RegExp(d(i)),"");l.tokens=[{type:"text",raw:l.raw,text:`<span class="${f} text-semibold d-inline-flex flex-items-center mb-1">${u+p(i)}</span>${m?`<br />${m}`:""}`}],Object.assign(t,{type:"alert",meta:{variant:i,icon:u,titleClassName:f}}),(v=t.tokens)==null||v.splice(0,1,l)}},extensions:[{name:"alert",level:"block",renderer({meta:t,tokens:c=[]}){let n=`<div class="${s} ${s}-${t.variant}">
`;return n+=this.parser.parse(c),n+=`</div>
`,n}}]}}return g});
(function(a,s){typeof exports=="object"&&typeof module<"u"?module.exports=s():typeof define=="function"&&define.amd?define(s):(a=typeof globalThis<"u"?globalThis:a||self,a.markedAlert=s())})(this,function(){"use strict";const a=[{type:"note",icon:'<svg class="octicon octicon-info mr-2" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path></svg>',titleClassName:"color-fg-accent"},{type:"important",icon:'<svg class="octicon octicon-report mr-2" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg>',titleClassName:"color-fg-done"},{type:"warning",icon:'<svg class="octicon octicon-alert mr-2" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg>',titleClassName:"color-fg-attention"}];function s(e){return e.length?Object.values([...a,...e].reduce((t,o)=>(t[o.type]=o,t),{})):a}function g(e,t){return t?["note","important","warning"].includes(e)?`${t} text-semibold d-inline-flex flex-items-center mb-1`:t:`text-${e} text-semibold d-inline-flex flex-items-center mb-1`}function d(e){return`^(?:\\[\\!${e.toUpperCase()}\\]|[\\*]{2}${p(e)}[\\*]{2})[s]*?
?`}function p(e){return e.slice(0,1).toUpperCase()+e.slice(1).toLowerCase()}function w(e={}){const{className:t="markdown-alert",variants:o=[]}=e,C=s(o);return{walkTokens(n){var i,h,u;if(n.type!=="blockquote")return;const l=C.find(({type:r})=>new RegExp(d(r)).test(n.text));if(l){const{type:r,icon:v,title:f=p(r),titleClassName:Z}=l,c=(i=n.tokens)==null?void 0:i[0],m=(h=c.raw)==null?void 0:h.replace(new RegExp(d(r)),""),x=g(r,Z);c.tokens=[{type:"text",raw:c.raw,text:`<span class="${x}">${v+f}</span>${m?`<br />${m}`:""}`}],Object.assign(n,{type:"alert",meta:{variant:r,icon:v,title:f,titleClassName:x}}),(u=n.tokens)==null||u.splice(0,1,c)}},extensions:[{name:"alert",level:"block",renderer({meta:n,tokens:l=[]}){let i=`<div class="${t} ${t}-${n.variant}">
`;return i+=this.parser.parse(l),i+=`</div>
`,i}}]}}return w});

@@ -15,2 +15,3 @@ import { Token } from 'marked';

icon: string;
title?: string;
titleClassName?: string;

@@ -26,2 +27,3 @@ };

icon: string;
title: string;
titleClassName: string;

@@ -28,0 +30,0 @@ };

@@ -8,2 +8,6 @@ import type { AlertVariantItem } from './types.js';

/**
* Resolve the variant title classname.
*/
export declare function resolveTitleClassName(type: string, classname?: string): string;
/**
* Returns regex pattern to match alert syntax.

@@ -10,0 +14,0 @@ */

{
"name": "marked-alert",
"description": "A marked extension to support GFM alert",
"version": "1.0.0",
"version": "1.1.0",
"publishConfig": {

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

# marked-alert
A [marked](https://marked.js.org/) extension to support [GFM alert](https://github.com/orgs/community/discussions/16925).
A [marked](https://marked.js.org/) extension to support [GFM alerts](https://github.com/orgs/community/discussions/16925).

@@ -5,0 +5,0 @@ - [Install](#install)

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