mirror of https://github.com/zulip/zulip.git
marked: Fix type stub to declare marked as a CommonJS module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
858bcca713
commit
13c44efad9
|
@ -5,7 +5,12 @@ pnpm-lock.yaml
|
||||||
/locale
|
/locale
|
||||||
/templates/**/*.md
|
/templates/**/*.md
|
||||||
/tools/setup/emoji/emoji_map.json
|
/tools/setup/emoji/emoji_map.json
|
||||||
/web/third
|
/web/third/*
|
||||||
|
!/web/third/marked
|
||||||
|
/web/third/marked/*
|
||||||
|
!/web/third/marked/lib
|
||||||
|
/web/third/marked/lib/*
|
||||||
|
!/web/third/marked/lib/marked.d.ts
|
||||||
/zerver/tests/fixtures
|
/zerver/tests/fixtures
|
||||||
/zerver/webhooks/*/doc.md
|
/zerver/webhooks/*/doc.md
|
||||||
/zerver/webhooks/github/githubsponsors.md
|
/zerver/webhooks/github/githubsponsors.md
|
||||||
|
|
|
@ -4,21 +4,24 @@ we only use parts of the marked API and are using a fork
|
||||||
of the upstream library.
|
of the upstream library.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { PrimitiveValue } from "url-template";
|
import {PrimitiveValue} from "url-template";
|
||||||
|
|
||||||
export class Renderer {
|
declare class Renderer {
|
||||||
code: (code: string) => string;
|
code: (code: string) => string;
|
||||||
link: (href: string, title: string, text: string) => string;
|
link: (href: string, title: string, text: string) => string;
|
||||||
br: () => string;
|
br: () => string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RegExpOrStub = RegExp | {
|
declare namespace marked {
|
||||||
|
type RegExpOrStub =
|
||||||
|
| RegExp
|
||||||
|
| {
|
||||||
exec(string: string): RegExpExecArray | null;
|
exec(string: string): RegExpExecArray | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type LinkifierMatch = PrimitiveValue | PrimitiveValue[] | Record<string, PrimitiveValue>;
|
type LinkifierMatch = PrimitiveValue | PrimitiveValue[] | Record<string, PrimitiveValue>;
|
||||||
|
|
||||||
export type ParseOptions = {
|
type ParseOptions = {
|
||||||
get_linkifier_regexes: () => RegExp[];
|
get_linkifier_regexes: () => RegExp[];
|
||||||
linkifierHandler: (pattern: RegExp, matches: LinkifierMatch[]) => string;
|
linkifierHandler: (pattern: RegExp, matches: LinkifierMatch[]) => string;
|
||||||
emojiHandler: (emoji_name: string) => string;
|
emojiHandler: (emoji_name: string) => string;
|
||||||
|
@ -37,65 +40,66 @@ export type ParseOptions = {
|
||||||
zulip: boolean;
|
zulip: boolean;
|
||||||
renderer: Renderer;
|
renderer: Renderer;
|
||||||
preprocessors: ((src: string) => string)[];
|
preprocessors: ((src: string) => string)[];
|
||||||
};
|
};
|
||||||
|
|
||||||
type MarkedOptions = ParseOptions & {
|
type MarkedOptions = ParseOptions & {
|
||||||
userMentionHandler: (mention: string, silently: boolean) => string | undefined;
|
userMentionHandler: (mention: string, silently: boolean) => string | undefined;
|
||||||
groupMentionHandler: (name: string, silently: boolean) => string | undefined;
|
groupMentionHandler: (name: string, silently: boolean) => string | undefined;
|
||||||
silencedMentionHandler: (quote: string) => string;
|
silencedMentionHandler: (quote: string) => string;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
declare const marked: {
|
declare const marked: {
|
||||||
// Note: We don't use the `callback` option in any of our code.
|
// Note: We don't use the `callback` option in any of our code.
|
||||||
(src: string, opt: MarkedOptions, callback?: any): string;
|
(src: string, opt: marked.MarkedOptions, callback?: any): string;
|
||||||
Lexer: {
|
Lexer: {
|
||||||
rules: {
|
rules: {
|
||||||
tables: {
|
tables: {
|
||||||
newline: RegExpOrStub;
|
newline: marked.RegExpOrStub;
|
||||||
code: RegExpOrStub;
|
code: marked.RegExpOrStub;
|
||||||
fences: RegExpOrStub;
|
fences: marked.RegExpOrStub;
|
||||||
hr: RegExpOrStub;
|
hr: marked.RegExpOrStub;
|
||||||
heading: RegExpOrStub;
|
heading: marked.RegExpOrStub;
|
||||||
nptable: RegExpOrStub;
|
nptable: marked.RegExpOrStub;
|
||||||
blockquote: RegExpOrStub;
|
blockquote: marked.RegExpOrStub;
|
||||||
list: RegExpOrStub;
|
list: marked.RegExpOrStub;
|
||||||
html: RegExpOrStub;
|
html: marked.RegExpOrStub;
|
||||||
def: RegExpOrStub;
|
def: marked.RegExpOrStub;
|
||||||
table: RegExpOrStub;
|
table: marked.RegExpOrStub;
|
||||||
paragraph: RegExpOrStub;
|
paragraph: marked.RegExpOrStub;
|
||||||
text: RegExpOrStub;
|
text: marked.RegExpOrStub;
|
||||||
bullet: RegExpOrStub;
|
bullet: marked.RegExpOrStub;
|
||||||
item: RegExpOrStub;
|
item: marked.RegExpOrStub;
|
||||||
_ta: RegExpOrStub;
|
_ta: marked.RegExpOrStub;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
InlineLexer: {
|
InlineLexer: {
|
||||||
rules: {
|
rules: {
|
||||||
zulip: {
|
zulip: {
|
||||||
escape: RegExpOrStub;
|
escape: marked.RegExpOrStub;
|
||||||
autolink: RegExpOrStub;
|
autolink: marked.RegExpOrStub;
|
||||||
url: RegExpOrStub;
|
url: marked.RegExpOrStub;
|
||||||
tag: RegExpOrStub;
|
tag: marked.RegExpOrStub;
|
||||||
link: RegExpOrStub;
|
link: marked.RegExpOrStub;
|
||||||
reflink: RegExpOrStub;
|
reflink: marked.RegExpOrStub;
|
||||||
nolink: RegExpOrStub;
|
nolink: marked.RegExpOrStub;
|
||||||
strong: RegExpOrStub;
|
strong: marked.RegExpOrStub;
|
||||||
em: RegExpOrStub;
|
em: marked.RegExpOrStub;
|
||||||
code: RegExpOrStub;
|
code: marked.RegExpOrStub;
|
||||||
br: RegExpOrStub;
|
br: marked.RegExpOrStub;
|
||||||
del: RegExpOrStub;
|
del: marked.RegExpOrStub;
|
||||||
emoji: RegExpOrStub;
|
emoji: marked.RegExpOrStub;
|
||||||
unicodeemoji: RegExpOrStub;
|
unicodeemoji: marked.RegExpOrStub;
|
||||||
usermention: RegExpOrStub;
|
usermention: marked.RegExpOrStub;
|
||||||
groupmention: RegExpOrStub;
|
groupmention: marked.RegExpOrStub;
|
||||||
stream: RegExpOrStub;
|
stream: marked.RegExpOrStub;
|
||||||
tex: RegExpOrStub;
|
tex: marked.RegExpOrStub;
|
||||||
timestamp: RegExpOrStub;
|
timestamp: marked.RegExpOrStub;
|
||||||
text: RegExpOrStub;
|
text: marked.RegExpOrStub;
|
||||||
_inside: RegExpOrStub;
|
_inside: marked.RegExpOrStub;
|
||||||
_href: RegExpOrStub;
|
_href: marked.RegExpOrStub;
|
||||||
stream_topic: RegExpOrStub;
|
stream_topic: marked.RegExpOrStub;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -103,4 +107,4 @@ declare const marked: {
|
||||||
stashHtml: (html: string, safe: boolean) => string;
|
stashHtml: (html: string, safe: boolean) => string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default marked;
|
export = marked;
|
||||||
|
|
Loading…
Reference in New Issue