Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ESSIF-Lab
eSSIF-Lab framework
Commits
514fdb00
Commit
514fdb00
authored
Oct 08, 2020
by
Thanasis Katsadas
Browse files
calculate correctly the term url
parent
5f2d7098
Pipeline
#15572
passed with stage
in 2 minutes and 5 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
plugins/terminology-parser/index.js
View file @
514fdb00
...
...
@@ -15,6 +15,17 @@ String.prototype.insert = function(index, string) {
return
string
+
this
;
};
function
getRelativePath
(
source
,
target
)
{
// calculate relative path from each file's parent dir
const
sourceDir
=
source
.
substr
(
0
,
source
.
lastIndexOf
(
"
/
"
));
const
targetDir
=
target
.
substr
(
0
,
target
.
lastIndexOf
(
"
/
"
));
const
relative_url
=
path
.
relative
(
sourceDir
,
targetDir
);
// construct the final url by appending the target's filename
// if the relative url is empty, it means that the referenced
// term is in the same dir, so add a `.`
return
relative_url
===
''
?
'
.
'
+
target
.
substr
(
target
.
lastIndexOf
(
"
/
"
))
:
relative_url
+
target
.
substr
(
target
.
lastIndexOf
(
"
/
"
));
}
function
getImportStatement
(
filePath
)
{
var
filePath
=
path
.
dirname
(
filePath
);
var
absoluteTermPath
=
path
.
resolve
(
'
./src/components
'
);
...
...
@@ -70,8 +81,11 @@ async function parser(err, files) {
// 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
);
var
new_text
=
(
'
<Term popup="
'
+
hoverText
+
'
" reference="
'
+
reference
+
'
">
'
+
text
+
'
</Term>
'
);
new_final_url
+
'
">
'
+
text
+
'
</Term>
'
);
content
=
content
.
replace
(
regex_match
,
new_text
);
}
// Find the index of the 2nd occurrence of '---'
...
...
src/components/index.js
View file @
514fdb00
"
use strict
"
;
const
TERMS_DIR
=
'
./terms/
'
;
const
React
=
require
(
'
react
'
);
const
{
Link
}
=
require
(
'
react-router-dom
'
);
const
{
Tooltip
}
=
require
(
'
@material-ui/core
'
)
require
(
'
./style.css
'
);
function
get_pathname
(
reference
)
{
return
{
pathname
:
TERMS_DIR
+
reference
};
return
{
pathname
:
reference
};
}
const
Term
=
({
children
,
reference
,
popup
})
=>
{
...
...
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