mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
markdown: Add helper config option to pass diff config to render.
This commit adds option to pass separate helper config to use when rendering markdown. It uses the passed helper config if available or fallbacks to web_app_helper config.
This commit is contained in:
committed by
Tim Abbott
parent
635d99ba72
commit
97f3be90d6
@@ -37,7 +37,7 @@ function contains_preview_link(content: string): boolean {
|
||||
return preview_regexes.some((re) => re.test(content));
|
||||
}
|
||||
|
||||
let web_app_helpers: MarkdownHelpers | undefined;
|
||||
export let web_app_helpers: MarkdownHelpers | undefined;
|
||||
|
||||
export type AbstractMap<K, V> = {
|
||||
keys: () => IterableIterator<K>;
|
||||
@@ -862,7 +862,10 @@ export function initialize(helper_config: MarkdownHelpers): void {
|
||||
web_app_helpers = helper_config;
|
||||
}
|
||||
|
||||
export function render(raw_content: string): {
|
||||
export function render(
|
||||
raw_content: string,
|
||||
helper_config?: MarkdownHelpers,
|
||||
): {
|
||||
content: string;
|
||||
flags: string[];
|
||||
is_me_message: boolean;
|
||||
@@ -870,7 +873,7 @@ export function render(raw_content: string): {
|
||||
// This is generally only intended to be called by the web app. Most
|
||||
// other platforms should call parse().
|
||||
assert(web_app_helpers !== undefined);
|
||||
const {content, flags} = parse({raw_content, helper_config: web_app_helpers});
|
||||
const {content, flags} = parse({raw_content, helper_config: helper_config ?? web_app_helpers});
|
||||
return {
|
||||
content,
|
||||
flags,
|
||||
|
Reference in New Issue
Block a user