Settings toggle to disable Composer Markdown (#8358)

This commit is contained in:
Janne Mareike Koschinski 2022-04-19 15:53:59 +02:00 committed by GitHub
parent f4d935d88d
commit bca9caa98e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 260 additions and 98 deletions

View file

@ -17,6 +17,7 @@ limitations under the License.
import { AllHtmlEntities } from 'html-entities';
import cheerio from 'cheerio';
import escapeHtml from "escape-html";
import Markdown from '../Markdown';
import { makeGenericPermalink } from "../utils/permalinks/Permalinks";
@ -48,7 +49,19 @@ export function mdSerialize(model: EditorModel): string {
}, "");
}
export function htmlSerializeIfNeeded(model: EditorModel, { forceHTML = false } = {}): string {
interface ISerializeOpts {
forceHTML?: boolean;
useMarkdown?: boolean;
}
export function htmlSerializeIfNeeded(
model: EditorModel,
{ forceHTML = false, useMarkdown = true }: ISerializeOpts = {},
): string {
if (!useMarkdown) {
return escapeHtml(textSerialize(model)).replace(/\n/g, '<br/>');
}
let md = mdSerialize(model);
// copy of raw input to remove unwanted math later
const orig = md;