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

mark_utils.js « services « content_editor « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6ccfed7810a1bc8eb42b969b017c5edcf9d08e47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
export const markInputRegex = (tag) =>
  new RegExp(`(<(${tag})((?: \\w+=".+?")+)?>([^<]+)</${tag}>)$`, 'gm');

export const extractMarkAttributesFromMatch = ([, , , attrsString]) => {
  const attrRegex = /(\w+)="(.+?)"/g;
  const attrs = {};

  let key;
  let value;

  do {
    [, key, value] = attrRegex.exec(attrsString) || [];
    if (key) attrs[key] = value;
  } while (key);

  return attrs;
};