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