Use <del> for strikeout

We've swapped to commonmark, which uses <del> instead of ~~ for strikeout, so make the RTE insert <del> when we apply strikeout. Also, when ~~ is inserted, transform them into <del> for simplicity. This means giving an input of ~~test~~ is effectively the same as giving an input of <del>test</del>.
This commit is contained in:
Luke Barnard 2017-06-23 18:19:06 +01:00
parent 89afcfd897
commit 9404dd30c5
2 changed files with 4 additions and 1 deletions

View file

@ -62,6 +62,9 @@ function is_multi_line(node) {
*/
export default class Markdown {
constructor(input) {
// Support GH-style strikeout
input = input.replace(/~~(.*?)~~/g, '<del>$1</del>');
this.input = input;
const parser = new commonmark.Parser();

View file

@ -397,7 +397,7 @@ export default class MessageComposerInput extends React.Component {
'bold': (text) => `**${text}**`,
'italic': (text) => `*${text}*`,
'underline': (text) => `_${text}_`, // there's actually no valid underline in Markdown, but *shrug*
'strike': (text) => `~~${text}~~`,
'strike': (text) => `<del>${text}</del>`,
'code-block': (text) => `\`\`\`\n${text}\n\`\`\``,
'blockquote': (text) => text.split('\n').map((line) => `> ${line}\n`).join(''),
'unordered-list-item': (text) => text.split('\n').map((line) => `\n- ${line}`).join(''),