diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-06 21:07:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-06 21:07:33 +0300 |
commit | 9e5484cee690f8bb2c1796013345d8cbc1872d77 (patch) | |
tree | 7b5c95c7de5eaba5ebb053da65c83184af1cf74c /app/assets/javascripts/vue_shared/components/source_viewer | |
parent | 638e2f1c5f55988135da63c7aa57bcecb9355a2b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/vue_shared/components/source_viewer')
-rw-r--r-- | app/assets/javascripts/vue_shared/components/source_viewer/plugins/wrap_child_nodes.js | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/app/assets/javascripts/vue_shared/components/source_viewer/plugins/wrap_child_nodes.js b/app/assets/javascripts/vue_shared/components/source_viewer/plugins/wrap_child_nodes.js index 3540ac6caf1..a79e88a1132 100644 --- a/app/assets/javascripts/vue_shared/components/source_viewer/plugins/wrap_child_nodes.js +++ b/app/assets/javascripts/vue_shared/components/source_viewer/plugins/wrap_child_nodes.js @@ -11,25 +11,25 @@ import { escape } from 'lodash'; const newlineRegex = /\r?\n/; const generateClassName = (suffix) => (suffix ? `hljs-${escape(suffix)}` : ''); const generateCloseTag = (includeClose) => (includeClose ? '</span>' : ''); -const generateHLJSTag = (kind, content = '', includeClose) => - `<span class="${generateClassName(kind)}">${escape(content)}${generateCloseTag(includeClose)}`; +const generateHLJSTag = (scope, content = '', includeClose) => + `<span class="${generateClassName(scope)}">${escape(content)}${generateCloseTag(includeClose)}`; -const format = (node, kind = '') => { +const format = (node, scope = '') => { let buffer = ''; if (typeof node === 'string') { buffer += node .split(newlineRegex) - .map((newline) => generateHLJSTag(kind, newline, true)) + .map((newline) => generateHLJSTag(scope, newline, true)) .join('\n'); - } else if (node.kind || node.sublanguage) { + } else if (node.scope || node.sublanguage) { const { children } = node; if (children.length && children.length === 1) { - buffer += format(children[0], node.kind); + buffer += format(children[0], node.scope); } else { - buffer += generateHLJSTag(node.kind); + buffer += generateHLJSTag(node.scope); children.forEach((subChild) => { - buffer += format(subChild, node.kind); + buffer += format(subChild, node.scope); }); buffer += `</span>`; } |