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

ecmarkdown

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ecmarkdown - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

7

dist/ecmarkdown.d.ts

@@ -0,3 +1,6 @@

export type { OpaqueTagNode, TagNode, CommentNode, AlgorithmNode, TextNode, StarNode, UnderscoreNode, TickNode, TildeNode, PipeNode, FormatNode, UnorderedListNode, OrderedListNode, ListNode, UnorderedListItemNode, OrderedListItemNode, Node, } from './node-types';
export type { Observer } from './visitor';
import { Parser } from './parser';
import { visit } from './visitor';
import { Emitter } from './emitter';
import { Parser } from './parser';
export declare type Options = {

@@ -11,2 +14,2 @@ trackPositions?: boolean;

declare let algorithm: (str: string, options?: Options | undefined) => string;
export { parseFragment, parseAlgorithm, emit, fragment, algorithm };
export { parseFragment, parseAlgorithm, visit, emit, fragment, algorithm };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const parser_1 = require("./parser");
const visitor_1 = require("./visitor");
exports.visit = visitor_1.visit;
const emitter_1 = require("./emitter");
const parser_1 = require("./parser");
let parseFragment = parser_1.Parser.parseFragment;

@@ -6,0 +8,0 @@ exports.parseFragment = parseFragment;

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

import type { Node, PipeNode, TildeNode, TickNode, TextNode, TagNode, UnderscoreNode, StarNode, ListItemNode, OrderedListNode, UnorderedListNode, AlgorithmNode, OpaqueTagNode, CommentNode } from './node-types';
import type { Node, PipeNode, TildeNode, TickNode, TextNode, TagNode, UnderscoreNode, StarNode, OrderedListItemNode, UnorderedListItemNode, OrderedListNode, UnorderedListNode, AlgorithmNode, OpaqueTagNode, CommentNode } from './node-types';
export declare class Emitter {

@@ -6,3 +6,3 @@ str: string;

emit(node: Node | Node[]): string;
static emit(doc: Node | Node[]): string;
static emit(node: Node | Node[]): string;
emitNode(node: Node | Node[]): void;

@@ -12,3 +12,3 @@ emitAlgorithm(algorithm: AlgorithmNode): void;

emitUnorderedList(ul: UnorderedListNode): void;
emitListItem(li: ListItemNode): void;
emitListItem(li: OrderedListItemNode | UnorderedListItemNode): void;
emitStar(node: StarNode): void;

@@ -15,0 +15,0 @@ emitUnderscore(node: UnderscoreNode): void;

@@ -11,5 +11,5 @@ "use strict";

}
static emit(doc) {
static emit(node) {
const emitter = new Emitter();
return emitter.emit(doc);
return emitter.emit(node);
}

@@ -31,3 +31,4 @@ emitNode(node) {

break;
case 'list-item':
case 'ordered-list-item':
case 'unordered-list-item':
this.emitListItem(node);

@@ -83,2 +84,10 @@ break;

this.emitFragment(li.contents);
if (li.sublist !== null) {
if (li.sublist.name === 'ol') {
this.emitOrderedList(li.sublist);
}
else {
this.emitUnorderedList(li.sublist);
}
}
this.str += '</li>';

@@ -85,0 +94,0 @@ }

@@ -125,3 +125,3 @@ export declare type Position = {

indent: number;
contents: ListItemNode[];
contents: UnorderedListItemNode[];
location?: LocationRange;

@@ -133,14 +133,19 @@ };

start: number;
contents: ListItemNode[];
contents: OrderedListItemNode[];
location?: LocationRange;
};
export declare type ListItemNode = {
name: 'list-item';
contents: ListItemContentNode[];
export declare type UnorderedListItemNode = {
name: 'unordered-list-item';
contents: FragmentNode[];
sublist: ListNode | null;
location?: LocationRange;
};
export declare type ListItemContentNode = FragmentNode | ListNode;
export declare type OrderedListItemNode = {
name: 'ordered-list-item';
contents: FragmentNode[];
sublist: ListNode | null;
location?: LocationRange;
};
export declare type FragmentNode = TextNode | FormatNode | CommentNode | TagNode | OpaqueTagNode;
export declare type ListNode = UnorderedListNode | OrderedListNode;
export declare type ParagraphNode = OpaqueTagNode | AlgorithmNode | ListNode;
export declare type Node = OpaqueTagNode | TagNode | CommentNode | AlgorithmNode | TextNode | StarNode | UnderscoreNode | TickNode | TildeNode | PipeNode | UnorderedListNode | OrderedListNode | ListItemNode;
export declare type Node = OpaqueTagNode | TagNode | CommentNode | AlgorithmNode | TextNode | StarNode | UnderscoreNode | TickNode | TildeNode | PipeNode | UnorderedListNode | OrderedListNode | UnorderedListItemNode | OrderedListItemNode;

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

import type { Position, Token, Format, Node, TextNode, CommentNode, TagNode, FragmentNode, ListItemContentNode, OrderedListNode } from './node-types';
import type { Position, Token, Format, Node, TextNode, CommentNode, TagNode, FragmentNode, ListNode, OrderedListNode, OrderedListItemNode, UnorderedListItemNode } from './node-types';
import type { Options } from './ecmarkdown';

@@ -20,13 +20,8 @@ import { Tokenizer } from './tokenizer';

};
parseList(): import("./node-types").ListNode;
parseListItem(indent: number): {
name: "list-item";
contents: ListItemContentNode[];
};
parseList(): ListNode;
parseListItem(kind: 'ol', indent: number): OrderedListItemNode;
parseListItem(kind: 'ul', indent: number): UnorderedListItemNode;
parseFragment(opts: ParseFragmentOpts): FragmentNode[];
parseFragment(opts: ParseFragmentOpts, closingFormatKind: Format): (TextNode | CommentNode | TagNode)[];
parseText(opts: ParseFragmentOpts, closingFormatKind: Format | undefined): {
name: "text";
contents: string;
};
parseText(opts: ParseFragmentOpts, closingFormatKind: Format | undefined): TextNode | null;
parseFormat(format: Format, opts: ParseFragmentOpts): FragmentNode[];

@@ -33,0 +28,0 @@ pushPos(): void;

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

const tok = this._t.peek();
if (!isList(tok)) {
if (tok.name !== node.name) {
break;

@@ -73,7 +73,8 @@ }

}
node.contents.push(this.parseListItem(node.indent));
// @ts-ignore typescript is not smart enough to figure out that the types line up
node.contents.push(this.parseListItem(node.name, node.indent));
}
return this.finish(node);
}
parseListItem(indent) {
parseListItem(kind, indent) {
this.pushPos();

@@ -85,9 +86,11 @@ // consume list token

// list items are some text followed by potentially a sub-list.
let sublist = null;
if (isList(listItemTok)) {
const match = listItemTok.contents.match(/^(\s*)/);
if (match[1].length > indent) {
contents.push(this.parseList());
sublist = this.parseList();
}
}
return this.finish({ name: 'list-item', contents });
let name = kind === 'ol' ? 'ordered-list-item' : 'unordered-list-item';
return this.finish({ name, contents, sublist });
}

@@ -105,3 +108,6 @@ parseFragment(opts, closingFormatKind) {

else if (tok.name === 'text' || tok.name === 'whitespace' || tok.name === 'linebreak') {
frag.push(this.parseText(opts, closingFormatKind));
let text = this.parseText(opts, closingFormatKind);
if (text !== null) {
frag.push(text);
}
}

@@ -149,2 +155,3 @@ else if (isFormatToken(tok)) {

// format tokens are considered part of text if they're not a valid format
// returns null rather than a node with no contents
parseText(opts, closingFormatKind) {

@@ -156,3 +163,2 @@ this.pushPos();

let tok = this._t.peek();
let firstTok = tok;
let wsChunk = '';

@@ -175,3 +181,3 @@ while (isWhitespace(tok)) {

}
lastRealTok = firstTok;
lastRealTok = tok;
contents += wsChunk;

@@ -208,2 +214,6 @@ if (isFormatToken(tok)) {

}
if (contents === '') {
this.popPos();
return null;
}
// @ts-ignore this should be `location!.end`, but we need to wait for TS to release a bugfix before we can do that

@@ -210,0 +220,0 @@ // see https://github.com/microsoft/TypeScript/pull/36539

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

this.pos++;
this.column++;
}

@@ -34,0 +33,0 @@ return this.str.slice(startPos, this.pos);

@@ -6,7 +6,2 @@ import type { Node } from './node-types';

};
export declare class Visitor {
observer: Observer;
static visit(ast: Node, observer: Observer): void;
constructor(observer: Observer);
genericallyVisit(node: Node): void;
}
export declare function visit(node: Node, observer: Observer): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const childKeys = {
document: ['contents'],
header: ['contents'],
blockTag: [],
opaqueTag: [],

@@ -19,32 +16,26 @@ tag: [],

ol: ['contents'],
'ordered-list-item': ['contents'],
'unordered-list-item': ['contents'],
'non-list': ['contents'],
'ordered-list-item': ['contents', 'sublist'],
'unordered-list-item': ['contents', 'sublist'],
};
class Visitor {
constructor(observer) {
this.observer = observer;
}
static visit(ast, observer) {
new Visitor(observer).genericallyVisit(ast);
}
genericallyVisit(node) {
var _a, _b, _c, _d;
(_b = (_a = this.observer).enter) === null || _b === void 0 ? void 0 : _b.call(_a, node);
function visit(node, observer) {
var _a, _b;
(_a = observer.enter) === null || _a === void 0 ? void 0 : _a.call(observer, node);
// @ts-ignore
for (let childKey of childKeys[node.name]) {
// @ts-ignore
for (let childKey of childKeys[node.name]) {
// @ts-ignore
let child = node[childKey];
if (Array.isArray(child)) {
for (let c of child) {
this.genericallyVisit(c);
}
let child = node[childKey];
if (child === null) {
continue;
}
if (Array.isArray(child)) {
for (let c of child) {
visit(c, observer);
}
else {
this.genericallyVisit(child);
}
}
(_d = (_c = this.observer).exit) === null || _d === void 0 ? void 0 : _d.call(_c, node);
else {
visit(child, observer);
}
}
(_b = observer.exit) === null || _b === void 0 ? void 0 : _b.call(observer, node);
}
exports.Visitor = Visitor;
exports.visit = visit;
{
"name": "ecmarkdown",
"version": "4.0.0",
"version": "5.0.0",
"description": "A compiler for \"Ecmarkdown\" algorithm shorthand into HTML.",

@@ -5,0 +5,0 @@ "main": "dist/ecmarkdown.js",

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