Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
eSSIF-Lab framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
9
Issues
9
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ESSIF-Lab
eSSIF-Lab framework
Commits
0205c57b
Commit
0205c57b
authored
Oct 29, 2020
by
Peter Langenkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
in glossery, show glossery text and process %%...^...%% syntax
parent
8ce48f40
Pipeline
#17185
passed with stage
in 1 minute and 38 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
2 deletions
+39
-2
plugins/terminology-parser/index.js
plugins/terminology-parser/index.js
+39
-2
No files found.
plugins/terminology-parser/index.js
View file @
0205c57b
...
...
@@ -123,9 +123,44 @@ async function getGlossaryTerms(files) {
let
{
metadata
}
=
parseMD
(
content
)
//keep only the required keys
if
(
metadata
.
title
)
{
let
glossaryContent
=
metadata
.
glossaryText
;
if
(
glossaryContent
)
{
// Regex for finding the pattern: %token_1,token_2%
reg
=
/
\%
%.*
?\^
.*
?\%
%/g
;
// If there is at least one match between the content of the file and
// the regex, proceed
if
((
regex_matches
=
glossaryContent
.
match
(
reg
))
!==
null
)
{
for
(
let
regex_match
of
regex_matches
)
{
var
token
=
regex_match
.
split
(
'
^
'
);
// Find the path of the term
var
reference
=
(
token
[
1
]).
replace
(
/
[
%"
]
/g
,
''
);
var
text
=
(
token
[
0
]).
replace
(
/
[
%"
]
/g
,
''
);
let
referencePath
=
TERMS_DIR
+
reference
+
'
.md
'
;
// Get the popup text for the term
let
hoverText
=
await
getHoverText
(
referencePath
);
const
current_file_path
=
path
.
resolve
(
process
.
cwd
(),
filepath
);
const
term_path
=
path
.
resolve
(
process
.
cwd
(),
TERMS_DIR
,
reference
);
const
new_final_url
=
getRelativePath
(
current_file_path
,
term_path
);
if
(
hoverText
===
undefined
)
{
var
new_text
=
(
'
<Term reference="
'
+
new_final_url
+
'
">
'
+
text
+
'
</Term>
'
);
}
else
{
var
new_text
=
(
'
<Term popup="
'
+
hoverText
+
'
" reference="
'
+
new_final_url
+
'
">
'
+
text
+
'
</Term>
'
);
}
glossaryContent
=
glossaryContent
.
replace
(
regex_match
,
new_text
);
}
}
}
arr
.
push
({
title
:
metadata
.
title
,
hoverText
:
metadata
.
hoverText
,
glossaryText
:
glossaryContent
,
filepath
:
filepath
.
slice
(
1
,
-
3
),
});
}
...
...
@@ -141,7 +176,7 @@ function generateGlossary(data) {
if
(
item
.
hoverText
===
undefined
)
{
content
=
content
+
`\n\n- **[
${
item
.
title
}
](
${
item
.
filepath
}
)**\n`
;
}
else
{
content
=
content
+
`\n\n- **[
${
item
.
title
}
](
${
item
.
filepath
}
)**:
${
item
.
hover
Text
}
\n`
;
content
=
content
+
`\n\n- **[
${
item
.
title
}
](
${
item
.
filepath
}
)**:
${
item
.
glossary
Text
}
\n`
;
}
}
})
...
...
@@ -149,7 +184,9 @@ function generateGlossary(data) {
if
(
err
)
throw
err
;
var
indexOfSecond
=
glossaryContent
.
indexOf
(
searchTerm
,
1
);
newContent
=
glossaryContent
.
slice
(
0
,
indexOfSecond
+
3
);
newContent
=
newContent
+
content
;
var
autoIncludeStatements
=
getAutoIncludeStatements
(
glossaryPath
);
newContent
=
newContent
+
autoIncludeStatements
+
content
;
// Write the list of terms to the glossary page
fs
.
writeFile
(
glossaryPath
,
newContent
,
'
utf8
'
,
function
(
err
)
{
if
(
err
)
return
console
.
log
(
err
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment