New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

markmap-lib

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markmap-lib - npm Package Compare versions

Comparing version 0.16.1 to 0.16.3-alpha.2

dist/markdown-it.d.ts

35

dist/index.js

@@ -5,7 +5,19 @@ "use strict";

const markmapHtmlParser = require("markmap-html-parser");
const remarkable = require("remarkable");
const MarkdownIt = require("markdown-it");
const md_ins = require("markdown-it-ins");
const md_mark = require("markdown-it-mark");
const md_sub = require("markdown-it-sub");
const md_sup = require("markdown-it-sup");
const plugins = require("./plugins.js");
require("js-yaml");
require("highlight.js");
require("remarkable-katex");
require("@iktakahiro/markdown-it-katex");
function initializeMarkdownIt() {
const md = MarkdownIt({
html: true,
breaks: true
});
md.use(md_ins).use(md_mark).use(md_sub).use(md_sup);
return md;
}
function patchJSItem(urlBuilder, item) {

@@ -64,15 +76,3 @@ if (item.type === "script" && item.data.src) {

this.assetsMap = assetsMap;
const md = new remarkable.Remarkable("full", {
html: true,
breaks: true,
maxNesting: Infinity
});
md.renderer.rules.htmltag = markmapCommon.wrapFunction(
md.renderer.rules.htmltag,
(render, ...args) => {
const result = render(...args);
this.hooks.htmltag.call({ args, result });
return result;
}
);
const md = initializeMarkdownIt();
this.md = md;

@@ -82,3 +82,3 @@ this.hooks.parser.call(md);

transform(content, opts) {
var _a, _b;
var _a, _b, _c;
const context = {

@@ -98,2 +98,3 @@ content,

);
root.content || (root.content = `${((_c = context.frontmatter) == null ? void 0 : _c.title) || ""}`);
return { ...context, root };

@@ -130,3 +131,3 @@ }

const transformerVersions = {
"markmap-lib": "0.16.1"
"markmap-lib": "0.16.3-alpha.2+0f4c3f8"
};

@@ -133,0 +134,0 @@ exports.Transformer = Transformer;

@@ -5,3 +5,15 @@ "use strict";

const markmapHtmlParser = require("markmap-html-parser");
const remarkable = require("remarkable");
const MarkdownIt = require("markdown-it");
const md_ins = require("markdown-it-ins");
const md_mark = require("markdown-it-mark");
const md_sub = require("markdown-it-sub");
const md_sup = require("markdown-it-sup");
function initializeMarkdownIt() {
const md = MarkdownIt({
html: true,
breaks: true
});
md.use(md_ins).use(md_mark).use(md_sub).use(md_sup);
return md;
}
function createTransformHooks(transformer) {

@@ -13,3 +25,2 @@ return {

afterParse: new markmapCommon.Hook(),
htmltag: new markmapCommon.Hook(),
retransform: new markmapCommon.Hook()

@@ -71,15 +82,3 @@ };

this.assetsMap = assetsMap;
const md = new remarkable.Remarkable("full", {
html: true,
breaks: true,
maxNesting: Infinity
});
md.renderer.rules.htmltag = markmapCommon.wrapFunction(
md.renderer.rules.htmltag,
(render, ...args) => {
const result = render(...args);
this.hooks.htmltag.call({ args, result });
return result;
}
);
const md = initializeMarkdownIt();
this.md = md;

@@ -89,3 +88,3 @@ this.hooks.parser.call(md);

transform(content, opts) {
var _a, _b;
var _a, _b, _c;
const context = {

@@ -105,2 +104,3 @@ content,

);
root.content || (root.content = `${((_c = context.frontmatter) == null ? void 0 : _c.title) || ""}`);
return { ...context, root };

@@ -137,3 +137,3 @@ }

const transformerVersions = {
"markmap-lib": "0.16.1"
"markmap-lib": "0.16.3-alpha.2+0f4c3f8"
};

@@ -140,0 +140,0 @@ exports.Transformer = Transformer;

@@ -6,3 +6,3 @@ "use strict";

const hljs = require("highlight.js");
const remarkableKatex = require("remarkable-katex");
const katexPlugin = require("@iktakahiro/markdown-it-katex");
function createTransformHooks(transformer) {

@@ -14,3 +14,2 @@ return {

afterParse: new markmapCommon.Hook(),
htmltag: new markmapCommon.Hook(),
retransform: new markmapCommon.Hook()

@@ -33,23 +32,18 @@ };

transformHooks.parser.tap((md) => {
md.core.ruler.before(
"inline",
"checkbox",
(state) => {
for (let i = 2; i < state.tokens.length; i += 1) {
const token = state.tokens[i];
if (token.type === "inline" && token.content) {
const prevType = state.tokens[i - 1].type;
const prevPrevType = state.tokens[i - 2].type;
if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
token.content = token.content.replace(
/^\[(.)\] /,
(m, g) => images[g] ? `${images[g]} ` : m
);
}
md.core.ruler.before("inline", "checkbox", (state) => {
for (let i = 2; i < state.tokens.length; i += 1) {
const token = state.tokens[i];
if (token.type === "inline" && token.content) {
const prevType = state.tokens[i - 1].type;
const prevPrevType = state.tokens[i - 2].type;
if (prevType === "heading_open" || prevType === "paragraph_open" && prevPrevType === "list_item_open") {
token.content = token.content.replace(
/^\[(.)\] /,
(m, g) => images[g] ? `${images[g]} ` : m
);
}
}
return false;
},
{}
);
}
return false;
});
});

@@ -215,10 +209,12 @@ return {};

transformHooks.parser.tap((md) => {
md.use(remarkableKatex);
md.renderer.rules.katex = markmapCommon.wrapFunction(
md.renderer.rules.katex,
(render, ...args) => {
enableFeature();
return render(...args);
md.use(katexPlugin);
["math_block", "math_inline"].forEach((key) => {
const fn = md.renderer.rules[key];
if (fn) {
md.renderer.rules[key] = markmapCommon.wrapFunction(fn, (render, ...args) => {
enableFeature();
return render(...args);
});
}
);
});
});

@@ -268,11 +264,12 @@ transformHooks.beforeParse.tap((_, context) => {

transformHooks.parser.tap((md) => {
Object.entries(md.renderer.rules).forEach(([key, value]) => {
if (typeof value === "function") {
md.renderer.rules[key] = patchRule(value);
} else {
Object.entries(value).forEach(([k, v]) => {
value[k] = patchRule(v);
});
md.renderer.renderAttrs = markmapCommon.wrapFunction(
md.renderer.renderAttrs,
(renderAttrs, token) => {
let attrs = renderAttrs(token);
if (token.block && token.map) {
attrs += ` data-lines=${token.map.join(",")}`;
}
return attrs;
}
});
);
});

@@ -282,15 +279,2 @@ return {};

});
function patchRule(rule, _key) {
return markmapCommon.wrapFunction(rule, (render, tokens, idx, ...rest) => {
let html = render(tokens, idx, ...rest);
const { lines } = tokens[idx];
if (lines) {
html = html.replace(
/^<[\w-]+/,
(m) => `${m} data-lines="${lines.join(",")}"`
);
}
return html;
});
}
const pluginSourceLines = plugin;

@@ -297,0 +281,0 @@ const plugins = [

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

import type MarkdownIt from 'markdown-it';
import { UrlBuilder } from 'markmap-common';
import { IHtmlParserOptions } from 'markmap-html-parser';
import { Remarkable } from 'remarkable';
import { IAssets, IFeatures, ITransformHooks, ITransformPlugin, ITransformResult, ITransformer } from './types';

@@ -8,3 +8,3 @@ export declare const builtInPlugins: ITransformPlugin[];

hooks: ITransformHooks;
md: Remarkable;
md: MarkdownIt;
assetsMap: Record<string, IAssets>;

@@ -11,0 +11,0 @@ urlBuilder: UrlBuilder;

@@ -1,6 +0,5 @@

import { CSSItem, Hook, IPureNode, IWrapContext, JSItem, UrlBuilder } from 'markmap-common';
import type MarkdownIt from 'markdown-it';
import { CSSItem, Hook, IPureNode, JSItem, UrlBuilder } from 'markmap-common';
import { IHtmlParserOptions } from 'markmap-html-parser';
import { IMarkmapJSONOptions as IMarkmapJSONOptionsForView } from 'markmap-view';
import type { Remarkable } from 'remarkable';
type Htmltag = Remarkable.Rule<Remarkable.HtmlTagToken, string>;
export interface ITransformHooks {

@@ -11,16 +10,12 @@ transformer: ITransformer;

*/
parser: Hook<[md: Remarkable]>;
parser: Hook<[md: MarkdownIt]>;
/**
* Tapped every time before Markdown content is parsed.
*/
beforeParse: Hook<[md: Remarkable, context: ITransformContext]>;
beforeParse: Hook<[md: MarkdownIt, context: ITransformContext]>;
/**
* Tapped every time after Markdown content is parsed.
*/
afterParse: Hook<[md: Remarkable, context: ITransformContext]>;
afterParse: Hook<[md: MarkdownIt, context: ITransformContext]>;
/**
* Tapped when Remarkable renders an HTML tag in Markdown.
*/
htmltag: Hook<[ctx: IWrapContext<Parameters<Htmltag>, ReturnType<Htmltag>>]>;
/**
* Used in autoloader to force rerender when resource is loaded.

@@ -58,2 +53,3 @@ */

frontmatter?: {
title?: string;
markmap?: IMarkmapJSONOptions;

@@ -78,2 +74,1 @@ };

}
export {};
{
"name": "markmap-lib",
"version": "0.16.1",
"version": "0.16.3-alpha.2+0f4c3f8",
"description": "Visualize your Markdown as mindmaps with Markmap",

@@ -61,3 +61,4 @@ "author": "Gerald <gera2ld@live.com>",

"@highlightjs/cdn-assets": "^11.8.0",
"@types/remarkable": "^2.0.3",
"@types/katex": "^0.16.7",
"@types/markdown-it": "^14.0.0",
"markmap-common": "0.16.0",

@@ -68,10 +69,14 @@ "webfontloader": "^1.6.28"

"@babel/runtime": "^7.22.6",
"@iktakahiro/markdown-it-katex": "^4.0.1",
"highlight.js": "^11.8.0",
"js-yaml": "^4.1.0",
"katex": "^0.16.8",
"markdown-it": "^14.1.0",
"markdown-it-ins": "^4.0.0",
"markdown-it-mark": "^4.0.0",
"markdown-it-sub": "^2.0.0",
"markdown-it-sup": "^2.0.0",
"markmap-html-parser": "0.16.1",
"markmap-view": "0.16.0",
"prismjs": "^1.29.0",
"remarkable": "^2.0.1",
"remarkable-katex": "^1.2.1"
"markmap-view": "0.16.3-alpha.2+0f4c3f8",
"prismjs": "^1.29.0"
},

@@ -95,3 +100,3 @@ "peerDependencies": {

},
"gitHead": "f10ad62ef03e02a1843484cca51521f48989fab7"
"gitHead": "0f4c3f84ff21f0957ec3dbf338ed7a453f050638"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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