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
|
import { Mark, markInputRule } from '@tiptap/core';
import { __ } from '~/locale';
import { PARSE_HTML_PRIORITY_HIGHEST } from '../constants';
export const inputRegex = /(?:^|\s)\$`([^`]+)`\$$/gm;
export default Mark.create({
name: 'mathInline',
parseHTML() {
return [
{
tag: 'code.math[data-math-style=inline]',
priority: PARSE_HTML_PRIORITY_HIGHEST,
},
];
},
renderHTML({ HTMLAttributes }) {
return [
'code',
{
title: __('Inline math'),
'data-toggle': 'tooltip',
class: 'gl-inset-border-1-gray-400',
...HTMLAttributes,
},
0,
];
},
addInputRules() {
return [markInputRule(inputRegex, this.type)];
},
});
|