mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
add typings for marked-terminal
This commit is contained in:
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
// Type definitions for marked-terminal 3.1
|
||||
// Project: https://github.com/mikaelbr/marked-terminal
|
||||
// Definitions by: Bryan Kendall <https://github.com/bkendall>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { Chalk } from 'chalk';
|
||||
import { Renderer } from 'marked';
|
||||
|
||||
export as namespace TerminalRenderer;
|
||||
|
||||
export = TerminalRenderer;
|
||||
|
||||
declare class TerminalRenderer extends Renderer {
|
||||
constructor(options?: TerminalRenderer.TerminalRendererOptions)
|
||||
}
|
||||
|
||||
declare namespace TerminalRenderer {
|
||||
interface TerminalRendererOptions {
|
||||
code?: Chalk | ((s: string) => string);
|
||||
blockquote?: Chalk | ((s: string) => string);
|
||||
html?: Chalk | ((s: string) => string);
|
||||
heading?: Chalk | ((s: string) => string);
|
||||
firstHeading?: Chalk | ((s: string) => string);
|
||||
hr?: Chalk | ((s: string) => string);
|
||||
listitem?: Chalk | ((s: string) => string);
|
||||
table?: Chalk | ((s: string) => string);
|
||||
paragraph?: Chalk | ((s: string) => string);
|
||||
strong?: Chalk | ((s: string) => string);
|
||||
em?: Chalk | ((s: string) => string);
|
||||
codespan?: Chalk | ((s: string) => string);
|
||||
del?: Chalk | ((s: string) => string);
|
||||
link?: Chalk | ((s: string) => string);
|
||||
href?: Chalk | ((s: string) => string);
|
||||
|
||||
// Formats the bulletpoints and numbers for lists
|
||||
list?: (body: string, ordered?: boolean) => string;
|
||||
|
||||
// Reflow and print-out width
|
||||
width?: number; // only applicable when reflow is true
|
||||
reflowText?: boolean;
|
||||
|
||||
// Should it prefix headers?
|
||||
showSectionPrefix?: boolean;
|
||||
|
||||
// Whether or not to undo marked escaping
|
||||
// of enitities (" -> " etc)
|
||||
unescape?: boolean;
|
||||
|
||||
// Whether or not to show emojis
|
||||
emoji?: boolean;
|
||||
|
||||
// Options passed to cli-table
|
||||
tableOptions?: any;
|
||||
|
||||
// The size of tabs in number of spaces or as tab characters
|
||||
tab?: number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import * as marked from 'marked';
|
||||
import * as TerminalRenderer from 'marked-terminal';
|
||||
import chalk from 'chalk';
|
||||
|
||||
marked.setOptions({
|
||||
// Define custom renderer
|
||||
renderer: new TerminalRenderer()
|
||||
});
|
||||
|
||||
marked.setOptions({
|
||||
// Define custom renderer
|
||||
renderer: new TerminalRenderer({
|
||||
// Change style for code
|
||||
codespan: chalk.underline.magenta,
|
||||
// Can also override color/styling by own functions.
|
||||
firstHeading: (text: string) => `*** ${text}`
|
||||
})
|
||||
});
|
||||
|
||||
marked.setOptions({
|
||||
// Define custom renderer
|
||||
renderer: new TerminalRenderer({
|
||||
reflowText: true,
|
||||
width: 60
|
||||
})
|
||||
});
|
||||
|
||||
// Show the parsed data
|
||||
console.log(marked('# a basic string\nwith stuff'));
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"marked-terminal-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user