Welcome to mirror list, hosted at ThFree Co, Russian Federation.

strike.js « marks « markdown « behaviors « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: afab266b645654c3da9d80d2c075710bb69341d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Transforms generated HTML back to GFM for Banzai::Filter::MarkdownFilter
export default () => ({
  name: 'strike',
  schema: {
    attrs: {
      strike: {
        default: false,
      },
      inapplicable: {
        default: false,
      },
    },
    parseDOM: [
      { tag: 'li.inapplicable > s', attrs: { inapplicable: true } },
      { tag: 'li.inapplicable > p:first-of-type > s', attrs: { inapplicable: true } },
      { tag: 's', attrs: { strike: true } },
      { tag: 'del' },
    ],
    toDOM: () => ['s', 0],
  },
  toMarkdown: {
    open(_, mark) {
      if (mark.attrs.strike) {
        return '<s>';
      }
      return mark.attrs.inapplicable ? '' : '~~';
    },
    close(_, mark) {
      if (mark.attrs.strike) {
        return '</s>';
      }
      return mark.attrs.inapplicable ? '' : '~~';
    },
    mixable: true,
    expelEnclosingWhitespace: true,
  },
});