2121 * [ ` Result ` ] ( #result )
2222* [ Syntax tree] ( #syntax-tree )
2323* [ JSX] ( #jsx )
24- * [ Types] ( #types )
2524* [ Compatibility] ( #compatibility )
2625* [ Security] ( #security )
2726* [ Related] ( #related )
@@ -49,7 +48,8 @@ when creating any unist nodes and
4948## Install
5049
5150This package is [ ESM only] [ github-gist-esm ] .
52- In Node.js (version 16+), install with [ npm] [ npmjs-install ] :
51+ In Node.js (version 16+),
52+ install with [ npm] [ npmjs-install ] :
5353
5454``` sh
5555npm install hastscript
@@ -146,10 +146,16 @@ Yields:
146146
147147This package exports the identifiers [ ` h ` ] [ api-h ] and [ ` s ` ] [ api-s ] .
148148There is no default export.
149+ It exports the additional [ TypeScript] [ ] types
150+ [ ` Child ` ] [ api-child ] ,
151+ [ ` Properties ` ] [ api-properties ] ,
152+ and
153+ [ ` Result ` ] [ api-result ] .
149154
150155The export map supports the automatic JSX runtime.
151- You can pass ` hastscript ` or ` hastscript/svg ` to your build tool (TypeScript,
152- Babel, SWC) with an ` importSource ` option or similar.
156+ You can pass ` hastscript ` or ` hastscript/svg ` to your build tool
157+ (TypeScript, Babel, SWC)
158+ with an ` importSource ` option or similar.
153159
154160### ` h(selector?[, properties][, …children]) `
155161
@@ -165,18 +171,22 @@ Create virtual **[hast][github-hast]** trees for HTML.
165171
166172###### ` selector `
167173
168- Simple CSS selector (` string ` , optional).
169- Can contain a tag name (` foo ` ), IDs (` #bar ` ), and classes (` .baz ` ).
170- If the selector is a string but there is no tag name in it, ` h ` defaults to
171- build a ` div ` element, and ` s ` to a ` g ` element.
172- ` selector ` is parsed by
173- [ ` hast-util-parse-selector ` ] [ github-hast-util-parse-selector ] .
174+ Simple CSS selector
175+ (` string ` , optional).
174176When string, builds an [ ` Element ` ] [ github-hast-element ] .
175177When nullish, builds a [ ` Root ` ] [ github-hast-root ] instead.
178+ The selector can contain a tag name (` foo ` ),
179+ IDs (` #bar ` ),
180+ and classes (` .baz ` ).
181+ If the selector is a string but there is no tag name in it then ` h ` defaults to
182+ build a ` div ` element and ` s ` to a ` g ` element.
183+ ` selector ` is parsed by
184+ [ ` hast-util-parse-selector ` ] [ github-hast-util-parse-selector ] .
176185
177186###### ` properties `
178187
179- Properties of the element ([ ` Properties ` ] [ api-properties ] , optional).
188+ Properties of the element
189+ ([ ` Properties ` ] [ api-properties ] , optional).
180190
181191###### ` children `
182192
@@ -194,8 +204,8 @@ otherwise [`Root`][github-hast-root].
194204Create virtual ** [ hast] [ github-hast ] ** trees for SVG.
195205
196206Signatures, parameters, and return value are the same as ` h ` above.
197- Importantly, the ` selector ` and ` properties ` parameters are interpreted as
198- SVG.
207+ Importantly,
208+ the ` selector ` and ` properties ` parameters are interpreted as SVG.
199209
200210### ` Child `
201211
@@ -222,8 +232,8 @@ type Child =
222232### ` Properties `
223233
224234Map of properties (TypeScript type).
225- Keys should match either the HTML attribute name, or the DOM property name, but
226- are case-insensitive.
235+ Keys should match either the HTML attribute name or the DOM property name,
236+ but are case-insensitive.
227237
228238###### Type
229239
@@ -262,16 +272,21 @@ This package can be used with JSX.
262272You should use the automatic JSX runtime set to ` hastscript ` or
263273` hastscript /svg ` .
264274
265- > 👉 **Note**: while ` h ` supports dots ( ` .` ) for classes or number signs ( ` #` )
266- > for IDs in ` selector ` , those are not supported in JSX.
275+ > 👉 **Note**
276+ > while ` h ` supports dots ( ` .` ) for classes or number signs ( ` #` )
277+ > for IDs in ` selector ` ,
278+ > those are not supported in JSX.
267279
268- > 🪦 **Legacy**: you can also use the classic JSX runtime, but this is not
269- > recommended.
270- > To do so, import ` h ` (or ` s ` ) yourself and define it as the pragma (plus
271- > set the fragment to ` null ` ).
280+ > 🪦 **Legacy**:
281+ > you can also use the classic JSX runtime,
282+ > but this is not recommended.
283+ > To do so,
284+ > import ` h ` (or ` s ` ) yourself and define it as the pragma
285+ > (plus set the fragment to ` null ` ).
272286
273- The Use example above can then be written like so, using inline pragmas, so
274- that SVG can be used too:
287+ The Use example above can then be written like so,
288+ using inline pragmas,
289+ so that SVG can be used too:
275290
276291` example -html .jsx ` :
277292
@@ -300,21 +315,15 @@ console.log(
300315)
301316` ` `
302317
303- ## Types
304-
305- This package is fully typed with [TypeScript][].
306- It exports the additional types [ ` Child ` ][api-child],
307- [ ` Properties ` ][api-properties], and
308- [ ` Result ` ][api-result].
309-
310318## Compatibility
311319
312320Projects maintained by the unified collective are compatible with maintained
313321versions of Node.js.
314322
315- When we cut a new major release, we drop support for unmaintained versions of
316- Node.
317- This means we try to keep the current release line, ` hastscript @^9 ` ,
323+ When we cut a new major release,
324+ we drop support for unmaintained versions of Node.
325+ This means we try to keep the current release line,
326+ ` hastscript @9 ` ,
318327compatible with Node.js 16.
319328
320329## Security
@@ -393,8 +402,9 @@ for ways to get started.
393402See [ ` support.md ` ] [ health-support ] for ways to get help.
394403
395404This project has a [ code of conduct] [ health-coc ] .
396- By interacting with this repository, organization, or community you agree to
397- abide by its terms.
405+ By interacting with this repository,
406+ organization,
407+ or community you agree to abide by its terms.
398408
399409## License
400410
0 commit comments