tweaking tsconfig.json
This commit is contained in:
Vendored
+2
-38
@@ -1,41 +1,5 @@
|
|||||||
"use strict";
|
import * as tags from "./tags";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
export const defaultTags = new tags.TagCollection([
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
||||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
||||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
||||||
}
|
|
||||||
Object.defineProperty(o, k2, desc);
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || (function () {
|
|
||||||
var ownKeys = function(o) {
|
|
||||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
||||||
var ar = [];
|
|
||||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
||||||
return ar;
|
|
||||||
};
|
|
||||||
return ownKeys(o);
|
|
||||||
};
|
|
||||||
return function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.defaultTags = void 0;
|
|
||||||
const tags = __importStar(require("./tags"));
|
|
||||||
exports.defaultTags = new tags.TagCollection([
|
|
||||||
new tags.Bold(),
|
new tags.Bold(),
|
||||||
new tags.Italic(),
|
new tags.Italic(),
|
||||||
new tags.BoldItalic(),
|
new tags.BoldItalic(),
|
||||||
|
|||||||
Vendored
+6
-11
@@ -1,14 +1,10 @@
|
|||||||
"use strict";
|
|
||||||
/*
|
/*
|
||||||
* hopdown.ts
|
* hopdown.ts
|
||||||
* - Configurable markdown <=> HTML converter.
|
* - Configurable markdown <=> HTML converter.
|
||||||
*/
|
*/
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
import { defaultTags } from "./defaults";
|
||||||
exports.HopDown = void 0;
|
import { Tokenizer } from "./tokenizer";
|
||||||
exports.escapeHtml = escapeHtml;
|
export function escapeHtml(source) {
|
||||||
const defaults_1 = require("./defaults");
|
|
||||||
const tokenizer_1 = require("./tokenizer");
|
|
||||||
function escapeHtml(source) {
|
|
||||||
return source
|
return source
|
||||||
.replace(/&/g, '&')
|
.replace(/&/g, '&')
|
||||||
.replace(/</g, '<')
|
.replace(/</g, '<')
|
||||||
@@ -37,13 +33,13 @@ function escapeHtml(source) {
|
|||||||
* "</div>"
|
* "</div>"
|
||||||
* );
|
* );
|
||||||
*/
|
*/
|
||||||
class HopDown {
|
export class HopDown {
|
||||||
tags;
|
tags;
|
||||||
referenceLinks = new Map();
|
referenceLinks = new Map();
|
||||||
tokenizer;
|
tokenizer;
|
||||||
constructor(tags) {
|
constructor(tags) {
|
||||||
this.tags = tags || defaults_1.defaultTags;
|
this.tags = tags || defaultTags;
|
||||||
this.tokenizer = new tokenizer_1.Tokenizer(this.tags);
|
this.tokenizer = new Tokenizer(this.tags);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Convert a markdown string to tokens.
|
* Convert a markdown string to tokens.
|
||||||
@@ -380,4 +376,3 @@ class HopDown {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.HopDown = HopDown;
|
|
||||||
|
|||||||
Vendored
+2
-18
@@ -1,18 +1,2 @@
|
|||||||
"use strict";
|
export * from "./hopdown";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
export * from "./defaults";
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
||||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
||||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
||||||
}
|
|
||||||
Object.defineProperty(o, k2, desc);
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
||||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
__exportStar(require("./hopdown"), exports);
|
|
||||||
__exportStar(require("./defaults"), exports);
|
|
||||||
|
|||||||
Vendored
+23
-44
@@ -1,8 +1,4 @@
|
|||||||
"use strict";
|
import { escapeHtml } from "./hopdown";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.Paragraph = exports.Table = exports.OrderedList = exports.UnorderedList = exports.Blockquote = exports.Heading = exports.HorizontalRule = exports.FencedCode = exports.HardBreak = exports.Anchor = exports.Code = exports.Strikethrough = exports.BoldItalic = exports.Italic = exports.Bold = exports.TagCollection = exports.Tag = void 0;
|
|
||||||
exports.childNodesToMarkdown = childNodesToMarkdown;
|
|
||||||
const hopdown_1 = require("./hopdown");
|
|
||||||
/**
|
/**
|
||||||
* Patterns shared across multiple tag classes. Defined once here
|
* Patterns shared across multiple tag classes. Defined once here
|
||||||
* so the regexes aren't duplicated and can be referenced by name.
|
* so the regexes aren't duplicated and can be referenced by name.
|
||||||
@@ -21,12 +17,12 @@ const tableSeparator = new RegExp('^'
|
|||||||
+ '\\|?' // optional trailing pipe
|
+ '\\|?' // optional trailing pipe
|
||||||
+ '\\s*$' // end of line
|
+ '\\s*$' // end of line
|
||||||
);
|
);
|
||||||
function childNodesToMarkdown(element, callback) {
|
export function childNodesToMarkdown(element, callback) {
|
||||||
return Array.from(element.childNodes)
|
return Array.from(element.childNodes)
|
||||||
.map(child => callback(child))
|
.map(child => callback(child))
|
||||||
.join('');
|
.join('');
|
||||||
}
|
}
|
||||||
class Tag {
|
export class Tag {
|
||||||
element = [''];
|
element = [''];
|
||||||
opener = '';
|
opener = '';
|
||||||
closer = '';
|
closer = '';
|
||||||
@@ -70,8 +66,7 @@ class Tag {
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
exports.Tag = Tag;
|
export class TagCollection {
|
||||||
class TagCollection {
|
|
||||||
tags = {};
|
tags = {};
|
||||||
ordered;
|
ordered;
|
||||||
openers;
|
openers;
|
||||||
@@ -130,47 +125,41 @@ class TagCollection {
|
|||||||
})[0] || undefined;
|
})[0] || undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.TagCollection = TagCollection;
|
export class Bold extends Tag {
|
||||||
class Bold extends Tag {
|
|
||||||
element = ['STRONG'];
|
element = ['STRONG'];
|
||||||
aliases = ['B'];
|
aliases = ['B'];
|
||||||
delimiter = '**';
|
delimiter = '**';
|
||||||
shortcut = 'Ctrl+B';
|
shortcut = 'Ctrl+B';
|
||||||
precedence = 40;
|
precedence = 40;
|
||||||
}
|
}
|
||||||
exports.Bold = Bold;
|
export class Italic extends Tag {
|
||||||
class Italic extends Tag {
|
|
||||||
element = ['EM'];
|
element = ['EM'];
|
||||||
aliases = ['I'];
|
aliases = ['I'];
|
||||||
delimiter = '*';
|
delimiter = '*';
|
||||||
shortcut = 'Ctrl+I';
|
shortcut = 'Ctrl+I';
|
||||||
precedence = 30;
|
precedence = 30;
|
||||||
}
|
}
|
||||||
exports.Italic = Italic;
|
export class BoldItalic extends Tag {
|
||||||
class BoldItalic extends Tag {
|
|
||||||
element = ['STRONG', 'EM'];
|
element = ['STRONG', 'EM'];
|
||||||
delimiter = '***';
|
delimiter = '***';
|
||||||
precedence = 50;
|
precedence = 50;
|
||||||
}
|
}
|
||||||
exports.BoldItalic = BoldItalic;
|
export class Strikethrough extends Tag {
|
||||||
class Strikethrough extends Tag {
|
|
||||||
element = ['DEL'];
|
element = ['DEL'];
|
||||||
aliases = ['S', 'STRIKE'];
|
aliases = ['S', 'STRIKE'];
|
||||||
delimiter = '~~';
|
delimiter = '~~';
|
||||||
}
|
}
|
||||||
exports.Strikethrough = Strikethrough;
|
export class Code extends Tag {
|
||||||
class Code extends Tag {
|
|
||||||
element = ['CODE'];
|
element = ['CODE'];
|
||||||
delimiter = '`';
|
delimiter = '`';
|
||||||
}
|
}
|
||||||
exports.Code = Code;
|
export class Anchor extends Tag {
|
||||||
class Anchor extends Tag {
|
|
||||||
element = ['A'];
|
element = ['A'];
|
||||||
toHTML(token, callback) {
|
toHTML(token, callback) {
|
||||||
const titleAttr = token.title
|
const titleAttr = token.title
|
||||||
? ` TITLE="${(0, hopdown_1.escapeHtml)(token.title)}"`
|
? ` TITLE="${escapeHtml(token.title)}"`
|
||||||
: '';
|
: '';
|
||||||
return `<A HREF="${(0, hopdown_1.escapeHtml)(token.href || '')}"${titleAttr}>${(0, hopdown_1.escapeHtml)(token.value)}</A>`;
|
return `<A HREF="${escapeHtml(token.href || '')}"${titleAttr}>${escapeHtml(token.value)}</A>`;
|
||||||
}
|
}
|
||||||
toMarkdown(element, callback) {
|
toMarkdown(element, callback) {
|
||||||
const href = element.getAttribute('href') || '';
|
const href = element.getAttribute('href') || '';
|
||||||
@@ -182,7 +171,6 @@ class Anchor extends Tag {
|
|||||||
return document.createElement('A');
|
return document.createElement('A');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.Anchor = Anchor;
|
|
||||||
class BlockTag extends Tag {
|
class BlockTag extends Tag {
|
||||||
isBlock = true;
|
isBlock = true;
|
||||||
delimiter = null;
|
delimiter = null;
|
||||||
@@ -196,21 +184,20 @@ class BlockTag extends Tag {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class HardBreak extends BlockTag {
|
export class HardBreak extends BlockTag {
|
||||||
match(context) {
|
match(context) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
toHTML() { return '<BR>'; }
|
toHTML() { return '<BR>'; }
|
||||||
toMarkdown() { return ' \n'; }
|
toMarkdown() { return ' \n'; }
|
||||||
}
|
}
|
||||||
exports.HardBreak = HardBreak;
|
|
||||||
/**
|
/**
|
||||||
* Fenced code blocks: lines between ``` delimiters become <pre><code>.
|
* Fenced code blocks: lines between ``` delimiters become <pre><code>.
|
||||||
*
|
*
|
||||||
* converter.toHTML('```js\nlet x = 1;\n```')
|
* converter.toHTML('```js\nlet x = 1;\n```')
|
||||||
* // <pre><code class="language-js">let x = 1;</code></pre>
|
* // <pre><code class="language-js">let x = 1;</code></pre>
|
||||||
*/
|
*/
|
||||||
class FencedCode extends BlockTag {
|
export class FencedCode extends BlockTag {
|
||||||
opener = '```';
|
opener = '```';
|
||||||
closer = '```';
|
closer = '```';
|
||||||
element = ['PRE'];
|
element = ['PRE'];
|
||||||
@@ -246,9 +233,9 @@ class FencedCode extends BlockTag {
|
|||||||
}
|
}
|
||||||
toHTML(token, callback) {
|
toHTML(token, callback) {
|
||||||
const langAttr = token.meta?.lang
|
const langAttr = token.meta?.lang
|
||||||
? ` class="language-${(0, hopdown_1.escapeHtml)(token.meta.lang)}"`
|
? ` class="language-${escapeHtml(token.meta.lang)}"`
|
||||||
: '';
|
: '';
|
||||||
return `<pre${langAttr}>${(0, hopdown_1.escapeHtml)(token.content)}</pre>`;
|
return `<pre${langAttr}>${escapeHtml(token.content)}</pre>`;
|
||||||
}
|
}
|
||||||
toMarkdown(element, callback) {
|
toMarkdown(element, callback) {
|
||||||
const lang = element.className.match(/language-(\S+)/)?.[1] || '';
|
const lang = element.className.match(/language-(\S+)/)?.[1] || '';
|
||||||
@@ -256,13 +243,12 @@ class FencedCode extends BlockTag {
|
|||||||
return '\n\n' + this.opener + `${lang}\n${content}\n` + this.closer + '\n\n';
|
return '\n\n' + this.opener + `${lang}\n${content}\n` + this.closer + '\n\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.FencedCode = FencedCode;
|
|
||||||
/**
|
/**
|
||||||
* Three or more *, -, or _ on a line become <hr>.
|
* Three or more *, -, or _ on a line become <hr>.
|
||||||
*
|
*
|
||||||
* converter.toHTML('---') // '<hr>'
|
* converter.toHTML('---') // '<hr>'
|
||||||
*/
|
*/
|
||||||
class HorizontalRule extends BlockTag {
|
export class HorizontalRule extends BlockTag {
|
||||||
element = ['HR'];
|
element = ['HR'];
|
||||||
button = {
|
button = {
|
||||||
show: true,
|
show: true,
|
||||||
@@ -292,8 +278,7 @@ class HorizontalRule extends BlockTag {
|
|||||||
return '\n***\n';
|
return '\n***\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.HorizontalRule = HorizontalRule;
|
export class Heading extends BlockTag {
|
||||||
class Heading extends BlockTag {
|
|
||||||
element = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
|
element = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
|
||||||
match(context) {
|
match(context) {
|
||||||
// ATX heading: # through ######, optional closing #s
|
// ATX heading: # through ######, optional closing #s
|
||||||
@@ -348,7 +333,6 @@ class Heading extends BlockTag {
|
|||||||
return text.replace(escapeRegex, ' ').trim().split(/\s+/).map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join('_');
|
return text.replace(escapeRegex, ' ').trim().split(/\s+/).map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join('_');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.Heading = Heading;
|
|
||||||
/**
|
/**
|
||||||
* Lines prefixed with > become blockquotes. Consecutive > lines
|
* Lines prefixed with > become blockquotes. Consecutive > lines
|
||||||
* are merged into a single blockquote.
|
* are merged into a single blockquote.
|
||||||
@@ -356,7 +340,7 @@ exports.Heading = Heading;
|
|||||||
* converter.toHTML('> hello\n> world')
|
* converter.toHTML('> hello\n> world')
|
||||||
* // <blockquote><p>hello\nworld</p></blockquote>
|
* // <blockquote><p>hello\nworld</p></blockquote>
|
||||||
*/
|
*/
|
||||||
class Blockquote extends BlockTag {
|
export class Blockquote extends BlockTag {
|
||||||
element = ['BLOCKQUOTE'];
|
element = ['BLOCKQUOTE'];
|
||||||
hidden = false;
|
hidden = false;
|
||||||
template = '> Quote\n> continues here';
|
template = '> Quote\n> continues here';
|
||||||
@@ -426,14 +410,13 @@ class Blockquote extends BlockTag {
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.Blockquote = Blockquote;
|
|
||||||
/**
|
/**
|
||||||
* Ordered and unordered lists with arbitrary nesting. Indentation
|
* Ordered and unordered lists with arbitrary nesting. Indentation
|
||||||
* determines depth; mixed list types (ul inside ol) are supported.
|
* determines depth; mixed list types (ul inside ol) are supported.
|
||||||
*
|
*
|
||||||
* converter.toHTML('- one\n- two\n 1. nested')
|
* converter.toHTML('- one\n- two\n 1. nested')
|
||||||
*/
|
*/
|
||||||
class UnorderedList extends BlockTag {
|
export class UnorderedList extends BlockTag {
|
||||||
element = ['UL'];
|
element = ['UL'];
|
||||||
hidden = false;
|
hidden = false;
|
||||||
match(context) {
|
match(context) {
|
||||||
@@ -568,17 +551,15 @@ class UnorderedList extends BlockTag {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.UnorderedList = UnorderedList;
|
export class OrderedList extends UnorderedList {
|
||||||
class OrderedList extends UnorderedList {
|
|
||||||
element = ['OL'];
|
element = ['OL'];
|
||||||
}
|
}
|
||||||
exports.OrderedList = OrderedList;
|
|
||||||
/**
|
/**
|
||||||
* Pipe-delimited tables with optional column alignment.
|
* Pipe-delimited tables with optional column alignment.
|
||||||
*
|
*
|
||||||
* converter.toHTML('| A | B |\n|---|---|\n| 1 | 2 |')
|
* converter.toHTML('| A | B |\n|---|---|\n| 1 | 2 |')
|
||||||
*/
|
*/
|
||||||
class Table extends BlockTag {
|
export class Table extends BlockTag {
|
||||||
element = ['TABLE'];
|
element = ['TABLE'];
|
||||||
hidden = false;
|
hidden = false;
|
||||||
template = '| Header 1 | Header 2 |\n|----------|----------|\n| Cell 1 | Cell 2 |';
|
template = '| Header 1 | Header 2 |\n|----------|----------|\n| Cell 1 | Cell 2 |';
|
||||||
@@ -673,8 +654,7 @@ class Table extends BlockTag {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.Table = Table;
|
export class Paragraph extends BlockTag {
|
||||||
class Paragraph extends BlockTag {
|
|
||||||
element = ['P'];
|
element = ['P'];
|
||||||
opener = '';
|
opener = '';
|
||||||
closer = '';
|
closer = '';
|
||||||
@@ -714,4 +694,3 @@ class Paragraph extends BlockTag {
|
|||||||
return '<p>' + callback(token.content) + '</p>';
|
return '<p>' + callback(token.content) + '</p>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.Paragraph = Paragraph;
|
|
||||||
|
|||||||
Vendored
+1
-5
@@ -1,4 +1,3 @@
|
|||||||
"use strict";
|
|
||||||
/*
|
/*
|
||||||
* tokenizer.ts — markdown tokenizer.
|
* tokenizer.ts — markdown tokenizer.
|
||||||
*
|
*
|
||||||
@@ -11,8 +10,6 @@
|
|||||||
* const tokens = tokenizer.tokenize('hello **bold** end');
|
* const tokens = tokenizer.tokenize('hello **bold** end');
|
||||||
* // [text "hello "] [open "**"] [text "bold"] [close "**"] [text " end"]
|
* // [text "hello "] [open "**"] [text "bold"] [close "**"] [text " end"]
|
||||||
*/
|
*/
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.Tokenizer = void 0;
|
|
||||||
/**
|
/**
|
||||||
* Characters that count as punctuation for flanking delimiter rules.
|
* Characters that count as punctuation for flanking delimiter rules.
|
||||||
* A delimiter is left-flanking if preceded by whitespace/punctuation
|
* A delimiter is left-flanking if preceded by whitespace/punctuation
|
||||||
@@ -45,7 +42,7 @@ const NAMED_ENTITIES = {
|
|||||||
* ]);
|
* ]);
|
||||||
* const tokens = tokenizer.tokenize('**bold**');
|
* const tokens = tokenizer.tokenize('**bold**');
|
||||||
*/
|
*/
|
||||||
class Tokenizer {
|
export class Tokenizer {
|
||||||
tags;
|
tags;
|
||||||
constructor(tags) {
|
constructor(tags) {
|
||||||
this.tags = tags.ordered;
|
this.tags = tags.ordered;
|
||||||
@@ -321,4 +318,3 @@ class Tokenizer {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.Tokenizer = Tokenizer;
|
|
||||||
|
|||||||
Vendored
+1
-2
@@ -1,2 +1 @@
|
|||||||
"use strict";
|
export {};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"target": "ES2025",
|
"target": "ES2025",
|
||||||
"module": "commonjs",
|
"module": "ES2022",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user