Skip to content

Commit

Permalink
feat(mdast): use the latest mdast-util-to-markdown
Browse files Browse the repository at this point in the history
remark-stringify is outdated
  • Loading branch information
craftzdog committed Aug 23, 2023
1 parent f592884 commit 27ed73e
Show file tree
Hide file tree
Showing 6 changed files with 985 additions and 800 deletions.
14 changes: 11 additions & 3 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ test('convert list', () => {
</ul>`
const md = html2Markdown(html)
expect(typeof md).toBe('string')
expect(md).toBe('* list 1\n* list 2\n')
expect(md).toBe('- list 1\n- list 2\n')
})
test('file 1', () => {
const md = fs.readFileSync(__dirname + '/test1.html', 'utf-8')
Expand Down Expand Up @@ -177,9 +177,9 @@ test('file 2', () => {
## 今日やったこと
* [x] Bash on Windowsを触る
- [x] Bash on Windowsを触る
* Windowsを最新版 1903 にアップデート
- Windowsを最新版 1903 にアップデート
## 明日どうするか\n`)
})
Expand Down Expand Up @@ -228,3 +228,11 @@ test('ignore comments', () => {
expect(typeof md).toBe('string')
expect(md).toBe('hello world\n')
})
test('file 3', () => {
const html = fs.readFileSync(__dirname + '/test3.html', 'utf-8')
const md = html2Markdown(html)
expect(typeof md).toBe('string')
expect(md).toBe(
'Adds a user to the guild, provided you have a valid oauth2 access token for the user with the `guilds.join` scope. Returns a 201 Created with the [guild member](https://discord.com/developers/docs/resources/guild#guild-member-object) as the body, or 204 No Content if the user is already a member of the guild. Fires a [Guild Member Add](https://discord.com/developers/docs/topics/gateway-events#guild-member-add) Gateway event.\n'
)
})
207 changes: 207 additions & 0 deletions __tests__/test3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
<meta charset="utf-8" /><span
style="
color: rgb(227, 229, 232);
font-family: 'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial,
sans-serif;
font-size: 16px;
font-style: normal;
font-variant-ligatures: normal;
font-variant-caps: normal;
font-weight: 500;
letter-spacing: normal;
orphans: 2;
text-align: start;
text-indent: 0px;
text-transform: none;
widows: 2;
word-spacing: 0px;
-webkit-text-stroke-width: 0px;
white-space: normal;
background-color: rgb(49, 51, 56);
text-decoration-thickness: initial;
text-decoration-style: initial;
text-decoration-color: initial;
display: inline !important;
float: none;
"
>Adds a user to the guild, provided you have a valid oauth2 access token for
the user with the<span> </span></span
><code
style="
margin: 0px;
padding: 3px 5px 4px;
border: 0px;
outline: 0px;
font-weight: 500;
font-style: normal;
font-family: monospace;
font-size: 13px;
vertical-align: baseline;
background: var(--primary-800);
display: inline-block;
border-radius: 3px;
line-height: 13px;
color: rgb(227, 229, 232);
font-variant-ligatures: normal;
font-variant-caps: normal;
letter-spacing: normal;
orphans: 2;
text-align: start;
text-indent: 0px;
text-transform: none;
widows: 2;
word-spacing: 0px;
-webkit-text-stroke-width: 0px;
white-space: normal;
text-decoration-thickness: initial;
text-decoration-style: initial;
text-decoration-color: initial;
"
>guilds.join</code
><span
style="
color: rgb(227, 229, 232);
font-family: 'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial,
sans-serif;
font-size: 16px;
font-style: normal;
font-variant-ligatures: normal;
font-variant-caps: normal;
font-weight: 500;
letter-spacing: normal;
orphans: 2;
text-align: start;
text-indent: 0px;
text-transform: none;
widows: 2;
word-spacing: 0px;
-webkit-text-stroke-width: 0px;
white-space: normal;
background-color: rgb(49, 51, 56);
text-decoration-thickness: initial;
text-decoration-style: initial;
text-decoration-color: initial;
display: inline !important;
float: none;
"
><span> </span>scope. Returns a 201 Created with the<span> </span></span
><a
class="link-3m0lUT"
href="https://discord.com/developers/docs/resources/guild#guild-member-object"
style="
margin: 0px;
padding: 0px;
border: 0px;
outline: 0px;
font-weight: 500;
font-style: normal;
font-family: 'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial,
sans-serif;
font-size: 16px;
vertical-align: baseline;
text-decoration: none;
color: var(--blue-345);
cursor: pointer;
transition: color 0.1s ease 0s;
font-variant-ligatures: normal;
font-variant-caps: normal;
letter-spacing: normal;
orphans: 2;
text-align: start;
text-indent: 0px;
text-transform: none;
widows: 2;
word-spacing: 0px;
-webkit-text-stroke-width: 0px;
white-space: normal;
background-color: rgb(49, 51, 56);
"
>guild member</a
><span
style="
color: rgb(227, 229, 232);
font-family: 'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial,
sans-serif;
font-size: 16px;
font-style: normal;
font-variant-ligatures: normal;
font-variant-caps: normal;
font-weight: 500;
letter-spacing: normal;
orphans: 2;
text-align: start;
text-indent: 0px;
text-transform: none;
widows: 2;
word-spacing: 0px;
-webkit-text-stroke-width: 0px;
white-space: normal;
background-color: rgb(49, 51, 56);
text-decoration-thickness: initial;
text-decoration-style: initial;
text-decoration-color: initial;
display: inline !important;
float: none;
"
><span> </span>as the body, or 204 No Content if the user is already a member
of the guild. Fires a<span> </span></span
><a
class="link-3m0lUT"
href="https://discord.com/developers/docs/topics/gateway-events#guild-member-add"
style="
margin: 0px;
padding: 0px;
border: 0px;
outline: 0px;
font-weight: 500;
font-style: normal;
font-family: 'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial,
sans-serif;
font-size: 16px;
vertical-align: baseline;
text-decoration: none;
color: var(--blue-345);
cursor: pointer;
transition: color 0.1s ease 0s;
font-variant-ligatures: normal;
font-variant-caps: normal;
letter-spacing: normal;
orphans: 2;
text-align: start;
text-indent: 0px;
text-transform: none;
widows: 2;
word-spacing: 0px;
-webkit-text-stroke-width: 0px;
white-space: normal;
background-color: rgb(49, 51, 56);
"
>Guild Member Add</a
><span
style="
color: rgb(227, 229, 232);
font-family: 'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial,
sans-serif;
font-size: 16px;
font-style: normal;
font-variant-ligatures: normal;
font-variant-caps: normal;
font-weight: 500;
letter-spacing: normal;
orphans: 2;
text-align: start;
text-indent: 0px;
text-transform: none;
widows: 2;
word-spacing: 0px;
-webkit-text-stroke-width: 0px;
white-space: normal;
background-color: rgb(49, 51, 56);
text-decoration-thickness: initial;
text-decoration-style: initial;
text-decoration-color: initial;
display: inline !important;
float: none;
"
><span> </span>Gateway event.</span
>
Loading

0 comments on commit 27ed73e

Please sign in to comment.