Settings toggle to disable Composer Markdown (#8358)
This commit is contained in:
parent
f4d935d88d
commit
bca9caa98e
12 changed files with 260 additions and 98 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue