Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 12a5622

Browse files
committed
Update micromark, change buffers to Uint8Arrays
1 parent 662d0cd commit 12a5622

File tree

4 files changed

+35
-24
lines changed

4 files changed

+35
-24
lines changed

‎dev/lib/index.js‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,11 @@
146146

147147
import {ok as assert} from 'uvu/assert'
148148
import {toString} from 'mdast-util-to-string'
149-
import {parse} from 'micromark/lib/parse.js'
150-
import {preprocess} from 'micromark/lib/preprocess.js'
151-
import {postprocess} from 'micromark/lib/postprocess.js'
149+
import {parse, postprocess, preprocess} from 'micromark'
152150
import {decodeNumericCharacterReference} from 'micromark-util-decode-numeric-character-reference'
153151
import {decodeString} from 'micromark-util-decode-string'
154152
import {normalizeIdentifier} from 'micromark-util-normalize-identifier'
155-
import {codes} from 'micromark-util-symbol/codes.js'
156-
import {constants} from 'micromark-util-symbol/constants.js'
157-
import {types} from 'micromark-util-symbol/types.js'
153+
import {codes, constants, types} from 'micromark-util-symbol'
158154
import {decodeNamedCharacterReference} from 'decode-named-character-reference'
159155
import {stringifyPosition} from 'unist-util-stringify-position'
160156

‎package.json‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
"@types/unist": "^2.0.0",
4646
"decode-named-character-reference": "^1.0.0",
4747
"mdast-util-to-string": "^3.1.0",
48-
"micromark": "^3.0.0",
49-
"micromark-util-decode-numeric-character-reference": "^1.0.0",
50-
"micromark-util-decode-string": "^1.0.0",
51-
"micromark-util-normalize-identifier": "^1.0.0",
52-
"micromark-util-symbol": "^1.0.0",
53-
"micromark-util-types": "^1.0.0",
48+
"micromark": "^4.0.0",
49+
"micromark-util-decode-numeric-character-reference": "^2.0.0",
50+
"micromark-util-decode-string": "^2.0.0",
51+
"micromark-util-normalize-identifier": "^2.0.0",
52+
"micromark-util-symbol": "^2.0.0",
53+
"micromark-util-types": "^2.0.0",
5454
"unist-util-stringify-position": "^3.0.0",
5555
"uvu": "^0.5.0"
5656
},
@@ -63,7 +63,7 @@
6363
"hast-util-from-html": "^1.0.0",
6464
"hast-util-to-html": "^8.0.0",
6565
"mdast-util-to-hast": "^12.0.0",
66-
"micromark-build": "^1.0.0",
66+
"micromark-build": "^2.0.0",
6767
"prettier": "^2.0.0",
6868
"remark-cli": "^11.0.0",
6969
"remark-preset-wooorm": "^9.0.0",

‎readme.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ Turn markdown into a syntax tree.
150150
* `value` ([`Value`][api-value])
151151
— markdown to parse
152152
* `encoding` ([`Encoding`][api-encoding], default: `'utf8'`)
153-
[character encoding][character-encoding] for when `value` is
154-
[`Buffer`][buffer]
153+
[character encoding][encoding] for when `value` is
154+
[`Uint8Array`][uint8-array]
155155
* `options` ([`Options`][api-options], optional)
156156
— configuration
157157

@@ -210,7 +210,7 @@ declare module 'mdast-util-from-markdown' {
210210

211211
### `Encoding`
212212

213-
Encodings supported by the [`Buffer`][buffer] class (TypeScript type).
213+
Encodings supported by the [`Uint8Array`][uint8-array] class (TypeScript type).
214214

215215
<!-- To do: link to micromark type, when documented. -->
216216

@@ -499,9 +499,9 @@ abide by its terms.
499499
500500
[root]: https://github.com/syntax-tree/mdast#root
501501
502-
[character-encoding]: https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
502+
[uint8-array]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
503503
504-
[buffer]: https://nodejs.org/api/buffer.html
504+
[encoding]: https://nodejs.org/api/util.html#whatwg-supported-encodings
505505
506506
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
507507

‎test/index.js‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44

55
import assert from 'node:assert/strict'
6-
import {Buffer} from 'node:buffer'
76
import fs from 'node:fs/promises'
87
import test from 'node:test'
98
import {toHast} from 'mdast-util-to-hast'
@@ -65,17 +64,33 @@ test('fromMarkdown', () => {
6564
'should parse a paragraph'
6665
)
6766

67+
assert.deepEqual(
68+
fromMarkdown(new Uint8Array()),
69+
{
70+
type: 'root',
71+
children: [],
72+
position: {
73+
start: {line: 1, column: 1, offset: 0},
74+
end: {line: 1, column: 1, offset: 0}
75+
}
76+
},
77+
'should support empty typed arrays'
78+
)
79+
6880
assert.equal(
69-
toString(fromMarkdown(Buffer.from([0x62,0x72,0xc3,0xa1,0x76,0x6f]))),
70-
'brávo',
71-
'should support buffers'
81+
toString(fromMarkdown(newTextEncoder().encode('<admin@example.com>'))),
82+
'admin@example.com',
83+
'should support types arrays'
7284
)
7385

7486
assert.equal(
7587
toString(
76-
fromMarkdown(Buffer.from([0x62, 0x72, 0xc3, 0xa1, 0x76, 0x6f]), 'ascii')
88+
fromMarkdown(
89+
new Uint8Array([0xff, 0xfe, 0x61, 0x00, 0x62, 0x00, 0x63, 0x00]),
90+
'utf-16le'
91+
)
7792
),
78-
'brC!vo',
93+
'abc',
7994
'should support encoding'
8095
)
8196

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /