FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ionic-cli/packages/cli-scripts/src/docs/utils.ts at fix/https-option · reslear/ionic-cli · GitHub
reslear
ionic-cli
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ionic-cli
/
packages
/
cli-scripts
/
src
/
docs
/
utils.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (34 loc) · 1.43 KB
Breadcrumbs
ionic-cli
/
packages
/
cli-scripts
/
src
/
docs
/
utils.ts
Copy path
File metadata and controls
42 lines (34 loc) · 1.43 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import
{
Colors
}
from
'@ionic/cli-framework'
;
import
{
COLORS
}
from
'@ionic/cli/lib/color'
;
import
chalk
from
'chalk'
;
import
escapeStringRegexp
from
'escape-string-regexp'
;
interface
CodePair
{
open
:
string
;
close
:
string
;
}
interface
Color
{
_styler
:
CodePair
;
}
type
ColorRegistry
=
{
[
K
in
keyof
Colors
]
:
Color
}
;
export
function
links2md
(
str
:
string
)
:
string
{
str
=
str
.
replace
(
/
(
(
h
t
t
p
|
h
t
t
p
s
)
:
\/
\/
(
\w
+
:
{
0
,
1
}
\w
*
@
)
?
(
[
^
\s
\*
\)
`
]
+
)
(
\/
|
\/
(
[
\w
#
!
:
.
?
+
=
&
%
@
!
\-
\/
]
)
)
?
)
/
g
,
'[$1]($1)'
)
;
str
=
str
.
replace
(
/
\[
(
\d
+
)
\]
/
g
,
'\\\[$1\\\]'
)
;
return
str
;
}
export
function
ansi2md
(
str
:
string
)
:
string
{
const
yellow
=
chalk
.
yellow
as
any
as
Color
;
const
{
input
,
strong
}
=
COLORS
as
any
as
ColorRegistry
;
str
=
convertAnsiToMd
(
str
,
[
input
.
_styler
]
,
{
open
:
'`'
,
close
:
'`'
}
)
;
str
=
convertAnsiToMd
(
str
,
[
yellow
.
_styler
]
,
{
open
:
''
,
close
:
''
}
)
;
str
=
convertAnsiToMd
(
str
,
[
strong
.
_styler
]
,
{
open
:
'**'
,
close
:
'**'
}
)
;
return
str
;
}
export
function
convertHTMLEntities
(
str
:
string
)
:
string
{
return
str
.
replace
(
/
(?<
=
^
(?:
[
^
\`
]
|
\`
[
^
\`
]
*
\`
)
*
)
\<
(
\S
+
)
\>
/
g
,
'<$1>'
)
;
}
function
convertAnsiToMd
(
str
:
string
,
styles
:
readonly
CodePair
[
]
,
md
:
CodePair
)
:
string
{
const
start
=
styles
.
map
(
style
=>
style
.
open
)
.
join
(
''
)
;
const
end
=
[
...
styles
]
.
reverse
(
)
.
map
(
style
=>
style
.
close
)
.
join
(
''
)
;
const
re
=
new
RegExp
(
escapeStringRegexp
(
start
)
+
'(.*?)'
+
escapeStringRegexp
(
end
)
,
'g'
)
;
return
str
.
replace
(
re
,
md
.
open
+
'$1'
+
md
.
close
)
;
}
Back
|
FazBrowse Home
|
New Git URL