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

ezal-markdown

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ezal-markdown - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

scripts/extensions/blockquote.js

2

package.json
{
"name": "ezal-markdown",
"version": "0.0.0",
"version": "0.0.1",
"description": "A simple, asynchronous markdown renderer",

@@ -5,0 +5,0 @@ "main": "scripts/index.js",

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAllInlineExtensions = exports.getAllBlockExtensions = exports.registerExtensions = void 0;
exports.loadInternalExtensions = exports.getAllInlineExtensions = exports.getAllBlockExtensions = exports.registerExtensions = void 0;
let extensions = {

@@ -52,2 +52,27 @@ inline: {},

exports.getAllInlineExtensions = getAllInlineExtensions;
const internalExtensions = [
'blockquote',
'code',
'codeblock',
'dl',
'emoji',
'escape',
'footnote',
'heading',
'hr',
'html',
'image',
'link',
'list',
'table',
'styled-text',
// 'tag',
];
function loadInternalExtensions() {
for (const name of internalExtensions) {
// @ts-ignore
registerExtensions(require(`./extensions/${name}`).default);
}
}
exports.loadInternalExtensions = loadInternalExtensions;
//# sourceMappingURL=extension.js.map

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

const renderer_1 = require("./renderer");
(0, extension_1.loadInternalExtensions)();
exports.registerExtensions = extension_1.registerExtensions;

@@ -8,0 +9,0 @@ async function render(source, options) {

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

};
var _Toc_instances, _Toc_toc, _Toc_ids, _Toc_setId;
var _Toc_instances, _Toc_toc, _Toc_ids, _Toc_escapeId, _Toc_setId;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -18,2 +18,3 @@ exports.Toc = void 0;

;
;
addTocItem(name, level, id) {

@@ -32,4 +33,4 @@ if (typeof name !== 'string') {

else {
let index = __classPrivateFieldGet(this, _Toc_instances, "m", _Toc_setId).call(this, name);
id = name;
id = __classPrivateFieldGet(this, _Toc_instances, "m", _Toc_escapeId).call(this, name);
let index = __classPrivateFieldGet(this, _Toc_instances, "m", _Toc_setId).call(this, id);
if (index > 0)

@@ -43,2 +44,3 @@ id += '-' + index;

addId(id) {
id = __classPrivateFieldGet(this, _Toc_instances, "m", _Toc_escapeId).call(this, id);
let index = __classPrivateFieldGet(this, _Toc_instances, "m", _Toc_setId).call(this, id);

@@ -74,3 +76,5 @@ if (index > 0)

exports.Toc = Toc;
_Toc_toc = new WeakMap(), _Toc_ids = new WeakMap(), _Toc_instances = new WeakSet(), _Toc_setId = function _Toc_setId(id) {
_Toc_toc = new WeakMap(), _Toc_ids = new WeakMap(), _Toc_instances = new WeakSet(), _Toc_escapeId = function _Toc_escapeId(id) {
return id.trim().replace(/\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\_|\+|\~|\`|\{|\}|\[|\]|\:|\"|\;|\'|\<|\>|\?|\,|\.|\/|\||\\/g, '').replace(/[ ]+/g, '-');
}, _Toc_setId = function _Toc_setId(id) {
if (!__classPrivateFieldGet(this, _Toc_ids, "f")[id]) {

@@ -77,0 +81,0 @@ __classPrivateFieldGet(this, _Toc_ids, "f")[id] = 1;

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

else {
matched[index + offset] = {
matcheds[index + offset] = {
ext,

@@ -50,5 +50,4 @@ matched,

continue;
for (let j = 0; j < matcheds[i].matched.raw.length; j++) {
delete matcheds[i + j];
}
finalMatcheds[i] = matcheds[i];
i += matcheds[i].matched.raw.length;
}

@@ -97,13 +96,13 @@ return finalMatcheds;

}
for (let i = 0; i < matcheds.length; i++) {
if (!matcheds[i])
continue;
for (let j = 0; j < matcheds[i].matched.raw.length; j++) {
delete matcheds[i + j];
}
}
}
return matcheds;
let finalMatcheds = [];
for (let i = 0; i < matcheds.length; i++) {
if (!matcheds[i])
continue;
finalMatcheds[i] = matcheds[i];
i += matcheds[i].matched.raw.length;
}
return finalMatcheds;
}
exports.walkLine = walkLine;
//# sourceMappingURL=tokenizer.js.map

@@ -18,3 +18,9 @@ // Type definitions for Ezal Markdown 1.0.0

*/
options: any,
options: {
code_highlight?: (src: string, language?: string)=>IAsyncReturnValue<{content: string, language: string}>,
footnote_class?: string,
heading_author_prefix?: string,
todo_list_class?: string,
[x: string | number | symbol]: any,
},
/**

@@ -91,3 +97,3 @@ * 目录

*/
render(matched: IMatched, variables: IVariables): IAsyncReturnValue<String>;
render(matched: IMatched, variables: IVariables): IAsyncReturnValue<string>;
/**

@@ -100,2 +106,37 @@ * 优先级

/**
* Markdown 标签
*/
export type ITag = {
/**
* 标签名
* 存在名称相同的标签时,旧标签将被覆盖
*/
name: string,
/**
* 级别
* block:块状
* inline:行内
*/
level: 'block' | 'inline',
/**
* 标签闭合
* 即使用该标签需要结束标签
* 行内默认为 false
* 块状默认为 true
*/
end: IEmpty | boolean,
/**
* 渲染匹配的结果
* @param src 源文本
* @param variables 渲染时可能需要使用的变量
* @returns 返回 HTML 格式的字符串
*/
render(matched: IMatched, variables: IVariables): IAsyncReturnValue<string>,
/**
* 优先级
* 当匹配的起始位置相同时,由优先级高的渲染
*/
priority?: number,
};
/**
* 扁平目录项

@@ -147,2 +188,7 @@ */

/**
* 注册标签
* @param tags 标签数组
*/
export function IRegisterTags(tags: ITag[]): void;
/**
* 渲染 Markdown 文本

@@ -149,0 +195,0 @@ * 主要用于渲染一行的 Markdown 文本,仅行内拓展生效

@@ -9,3 +9,3 @@ // Type definitions for Ezal Markdown 1.0.0

import { IExtension, IFlatToc, IMatched, INormalToc, IToc, ITreeToc, IVariables } from "./dev";
import { IExtension, IFlatToc, IMatched, INormalToc, IRegisterExtensions, IRegisterTags, IRender, IRenderLine, ITag, IToc, ITreeToc, IVariables } from "./dev";

@@ -26,2 +26,6 @@ declare module 'ezal-markdown'{

/**
* Markdown 标签
*/
export type Tag = ITag;
/**
* 扁平目录项

@@ -47,4 +51,9 @@ */

*/
export function registerExtensions(extensions: Extension[]): void;
export const registerExtensions: typeof IRegisterExtensions;
/**
* 注册标签
* @param tags 标签数组
*/
export const registerTags: typeof IRegisterTags;
/**
* 渲染 Markdown 文本

@@ -64,5 +73,5 @@ * 主要用于渲染一行的 Markdown 文本,仅行内拓展生效

export const origin: {
render(src: string, variables?: IVariables): Promise<{content: string, variables: IVariables, toc: INormalToc}>,
renderLine(src: string, variables?: IVariables): Promise<{content: string, variables: IVariables}>,
render: typeof IRender,
renderLine: typeof IRenderLine,
}
}

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