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
bonita
bonita-continuous-delivery-doc
Commits
87f42d8c
Commit
87f42d8c
authored
Nov 16, 2017
by
jeremy
Browse files
Manage application name when launch script md2html from benjaminParisel
parent
8aa04ce0
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/convertMdToHtml.js
View file @
87f42d8c
...
...
@@ -12,14 +12,21 @@
const
winston
=
require
(
'
winston
'
);
const
argv
=
require
(
'
yargs
'
).
argv
;
const
variables
=
require
(
'
./variables.json
'
);
let
version
=
argv
.
v
||
argv
.
_
[
0
];
if
(
!
version
)
{
version
=
variables
.
varVersion
;
if
(
!
version
)
{
winston
.
warn
(
'
usage convertMd2Html [-v] version or set a "varVersion" key in scripts/variables.json
'
);
return
;
}
}
let
application
=
argv
.
a
||
argv
.
_
[
0
];
if
(
application
){
application
=
application
+
'
/
'
;
}
else
{
application
=
''
;
}
let
version
=
argv
.
v
||
argv
.
_
[
1
];
if
(
!
version
)
{
version
=
variables
.
varVersion
;
if
(
!
version
)
{
winston
.
warn
(
'
usage convertMd2Html [-v] version or set a "varVersion" key in scripts/variables.json
'
);
return
;
}
}
const
readdirPromise
=
denodeify
(
fs
.
readdir
);
const
writeFilePromise
=
denodeify
(
fs
.
writeFile
);
...
...
@@ -39,7 +46,7 @@
const
hrefIndex
=
tokens
[
idx
].
attrIndex
(
'
href
'
);
if
(
hrefIndex
>=
0
&&
!
tokens
[
idx
].
attrs
[
hrefIndex
][
1
].
match
(
/^http/
))
{
if
(
hrefIndex
>=
0
&&
tokens
[
idx
].
attrs
[
hrefIndex
][
1
].
match
(
/^images
\/
/
))
{
tokens
[
idx
].
attrs
[
hrefIndex
][
1
]
=
tokens
[
idx
].
attrs
[
hrefIndex
][
1
].
replace
(
/^images
\/
/gi
,
`images/
${
version
}
/`
);
tokens
[
idx
].
attrs
[
hrefIndex
][
1
]
=
tokens
[
idx
].
attrs
[
hrefIndex
][
1
].
replace
(
/^images
\/
/gi
,
`
${
application
}
images/
${
version
}
/`
);
tokens
[
idx
].
attrPush
([
'
target
'
,
'
_blank
'
]);
}
else
{
const
pageAndHash
=
tokens
[
idx
].
attrs
[
hrefIndex
][
1
].
split
(
'
#
'
,
2
);
...
...
@@ -55,7 +62,7 @@
.
use
(
mdInline
,
'
site_compatible_images
'
,
'
image
'
,
(
tokens
,
idx
)
=>
{
const
srcIndex
=
tokens
[
idx
].
attrIndex
(
'
src
'
);
if
(
srcIndex
>=
0
)
{
tokens
[
idx
].
attrs
[
srcIndex
][
1
]
=
tokens
[
idx
].
attrs
[
srcIndex
][
1
].
replace
(
/^images
\/
/gi
,
`images/
${
version
}
/`
);
tokens
[
idx
].
attrs
[
srcIndex
][
1
]
=
tokens
[
idx
].
attrs
[
srcIndex
][
1
].
replace
(
/^images
\/
/gi
,
`
${
application
}
images/
${
version
}
/`
);
}
const
altIndex
=
tokens
[
idx
].
attrIndex
(
'
alt
'
);
if
(
altIndex
<
0
)
{
...
...
Write
Preview
Supports
Markdown
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