feat: stage edits to published articles as drafts (#14842)
This commit is contained in:
@@ -67,8 +67,11 @@ const createMarkdownInstance = (linkify = true) => {
|
||||
// `<!--cw-colwidths:...-->` comment before the table. It exists only for the
|
||||
// editor's markdown round-trip and must never surface as text — markdown-it runs
|
||||
// with `html: false`, which would otherwise escape it into a visible comment in
|
||||
// rendered/plain output (e.g. dashboard search snippets). Strip it on the way in.
|
||||
const COLWIDTHS_MARKER_REGEX = /<!--cw-colwidths:[\d,]+-->\r?\n?/g;
|
||||
// rendered/plain output (e.g. dashboard search snippets). Strip the whole marker
|
||||
// line, including any blockquote prefix, so a quoted table's `>` prefixes don't
|
||||
// collapse together and break table parsing.
|
||||
const COLWIDTHS_MARKER_REGEX =
|
||||
/^[ \t>]*<!--cw-colwidths:[\d,]+-->[ \t]*\r?\n?/gm;
|
||||
|
||||
const TWITTER_USERNAME_REGEX = /(^|[^@\w])@(\w{1,15})\b/g;
|
||||
const TWITTER_USERNAME_REPLACEMENT = '$1[@$2](http://twitter.com/$2)';
|
||||
|
||||
@@ -153,6 +153,15 @@ After`;
|
||||
expect(formatter.formattedMessage).not.toContain('cw-colwidths');
|
||||
expect(formatter.plainText).not.toContain('cw-colwidths');
|
||||
});
|
||||
|
||||
it('strips a blockquote-prefixed marker so the quoted table still renders', () => {
|
||||
const message =
|
||||
'> <!--cw-colwidths:120,200-->\n> | A | B |\n> | --- | --- |\n> | 1 | 2 |';
|
||||
const { formattedMessage } = new MessageFormatter(message);
|
||||
expect(formattedMessage).not.toContain('cw-colwidths');
|
||||
expect(formattedMessage).toContain('<blockquote>');
|
||||
expect(formattedMessage).toContain('<table>');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#sanitize', () => {
|
||||
|
||||
Reference in New Issue
Block a user