Platform
Resources
Pricing
Sign in
Get started
Comparing
“Data from HTML / Markdown” (target)
to
“Data from HTML / Markdown” (base)
Compare reverse
Bryan Gin-ge Chen
here to learn
Workspace
Published unlisted
By
Bryan Gin-ge Chen
Edited
Jul 2, 2019
Insert cell
Insert cell
Insert cell
function
mdLinks
(
str
)
{
const
matches
=
str
.
matchAll
(
/\[([^\]]*)\]\(([^)]*)\)/g
)
;
const
result
=
[
]
;
for
(
const
match
of
matches
)
{
result
.
push
(
{
title
:
match
[
1
]
,
url
:
match
[
2
]
}
)
;
}
return
result
;
}
Insert cell
Changed in target
base
Diff
target
-
str =
md
`
+
str =
`
[test](http://test.com) `
Insert cell
Removed in base
base
target
mdLinks
(
str
)
Insert cell
Insert cell
input
=
html
`
<p><a href="http://test.com">test</a></p>
`
Insert cell
arr
=
[
]
.
slice
.
call
(
input
.
querySelectorAll
(
'a'
)
)
;
Insert cell
markup
=
arr
.
map
(
function
(
elem
)
{
return
elem
.
outerHTML
;
}
)
;
Insert cell
urls
=
arr
.
map
(
function
(
elem
)
{
return
elem
.
getAttribute
(
'href'
)
;
}
)
;
Insert cell
Fork
View
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
mdLinks
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
str
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
input
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
arr
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
markup
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
urls
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML