@thi.ng/hiccup 5.2.25 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -290
- package/README.md +27 -8
- package/api.d.ts +2 -0
- package/api.js +2 -0
- package/package.json +8 -9
- package/serialize.js +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2025-01-
|
|
3
|
+
- **Last updated**: 2025-01-23T13:39:11Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
7
|
+
Only versions published since **2022-01-01** are listed here.
|
|
8
|
+
Please consult the Git history for older version information.
|
|
7
9
|
See [Conventional Commits](https://conventionalcommits.org/) for commit guidelines.
|
|
8
10
|
|
|
9
11
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
12
|
and/or version bumps of transitive dependencies.
|
|
11
13
|
|
|
14
|
+
## [5.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@5.3.0) (2025-01-22)
|
|
15
|
+
|
|
16
|
+
#### 🚀 Features
|
|
17
|
+
|
|
18
|
+
- add special `INLINE` tag & `__escape` behavior attrib ([42e7717](https://github.com/thi-ng/umbrella/commit/42e7717))
|
|
19
|
+
- add `INLINE` tag & handling for embedded markup
|
|
20
|
+
- add `__escape` control attrib to enable/disable entity escaping (per element)
|
|
21
|
+
- add tests
|
|
22
|
+
|
|
12
23
|
### [5.2.11](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@5.2.11) (2024-08-23)
|
|
13
24
|
|
|
14
25
|
#### 🩹 Bug fixes
|
|
@@ -87,292 +98,3 @@ and/or version bumps of transitive dependencies.
|
|
|
87
98
|
|
|
88
99
|
- add XML_PROC & DOCTYPE_HTML constants ([4ec98fd](https://github.com/thi-ng/umbrella/commit/4ec98fd))
|
|
89
100
|
- update tests
|
|
90
|
-
|
|
91
|
-
## [4.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@4.2.0) (2021-11-17)
|
|
92
|
-
|
|
93
|
-
#### 🚀 Features
|
|
94
|
-
|
|
95
|
-
- Using workspaces for local tools ([bf7a404](https://github.com/thi-ng/umbrella/commit/bf7a404))
|
|
96
|
-
Improving the overall build ergonomics
|
|
97
|
-
- introduced a tools workspaces
|
|
98
|
-
- imported it in all needed packages/examples
|
|
99
|
-
- inclusive project root
|
|
100
|
-
|
|
101
|
-
#### ♻️ Refactoring
|
|
102
|
-
|
|
103
|
-
- testrunner to binary ([4ebbbb2](https://github.com/thi-ng/umbrella/commit/4ebbbb2))
|
|
104
|
-
this commit reverts (partly) changes made in:
|
|
105
|
-
ef346d7a8753590dc9094108a3d861a8dbd5dd2c
|
|
106
|
-
overall purpose is better testament ergonomics:
|
|
107
|
-
instead of having to pass NODE_OPTIONS with every invocation
|
|
108
|
-
having a binary to handle this for us.
|
|
109
|
-
|
|
110
|
-
## [4.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@4.1.0) (2021-10-25)
|
|
111
|
-
|
|
112
|
-
#### 🚀 Features
|
|
113
|
-
|
|
114
|
-
- replace entity handling w/ [@thi.ng/strings](https://github.com/thi-ng/umbrella/tree/main/packages/strings) ([04154b8](https://github.com/thi-ng/umbrella/commit/04154b8))
|
|
115
|
-
|
|
116
|
-
### [4.0.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@4.0.1) (2021-10-13)
|
|
117
|
-
|
|
118
|
-
#### ♻️ Refactoring
|
|
119
|
-
|
|
120
|
-
- update imports in all pkgs ([5fa2b6f](https://github.com/thi-ng/umbrella/commit/5fa2b6f))
|
|
121
|
-
- add .js suffix for all relative imports
|
|
122
|
-
- update imports in all tests/pkgs ([effd591](https://github.com/thi-ng/umbrella/commit/effd591))
|
|
123
|
-
|
|
124
|
-
# [4.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@4.0.0) (2021-10-12)
|
|
125
|
-
|
|
126
|
-
#### 🛑 Breaking changes
|
|
127
|
-
|
|
128
|
-
- major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea))
|
|
129
|
-
- BREAKING CHANGE: discontinue CommonJS & UMD versions
|
|
130
|
-
- only ESM modules will be published from now on
|
|
131
|
-
- CJS obsolete due to ESM support in recent versions of node:
|
|
132
|
-
- i.e. launch NodeJS via:
|
|
133
|
-
- `node --experimental-specifier-resolution=node --experimental-repl-await`
|
|
134
|
-
- in the node REPL use `await import(...)` instead of `require()`
|
|
135
|
-
- UMD obsolete due to widespread browser support for ESM
|
|
136
|
-
Also:
|
|
137
|
-
- normalize/restructure/reorg all package.json files
|
|
138
|
-
- cleanup all build scripts, remove obsolete
|
|
139
|
-
- switch from mocha to [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament) for all tests
|
|
140
|
-
|
|
141
|
-
#### ♻️ Refactoring
|
|
142
|
-
|
|
143
|
-
- update all tests in _all_ pkgs ([8b582bc](https://github.com/thi-ng/umbrella/commit/8b582bc))
|
|
144
|
-
- update all to use [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament)
|
|
145
|
-
- update imports ([138571a](https://github.com/thi-ng/umbrella/commit/138571a))
|
|
146
|
-
- update deps & imports in various pkgs ([e1cf29e](https://github.com/thi-ng/umbrella/commit/e1cf29e))
|
|
147
|
-
- largely related to recent updates/restructuring of these packages:
|
|
148
|
-
- api
|
|
149
|
-
- defmulti
|
|
150
|
-
- errors
|
|
151
|
-
- logger
|
|
152
|
-
|
|
153
|
-
### [3.6.4](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@3.6.4) (2020-12-07)
|
|
154
|
-
|
|
155
|
-
#### ♻️ Refactoring
|
|
156
|
-
|
|
157
|
-
- update type-only imports in various tests/pkgs ([3fd9c24](https://github.com/thi-ng/umbrella/commit/3fd9c24))
|
|
158
|
-
|
|
159
|
-
### [3.6.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@3.6.1) (2020-09-22)
|
|
160
|
-
|
|
161
|
-
#### ♻️ Refactoring
|
|
162
|
-
|
|
163
|
-
- extract mergeEmmetAttribs() ([0c965c9](https://github.com/thi-ng/umbrella/commit/0c965c9))
|
|
164
|
-
- simplify normalize() and improve external re-use in hdom/rdom
|
|
165
|
-
- update/split serialization fns ([32ac755](https://github.com/thi-ng/umbrella/commit/32ac755))
|
|
166
|
-
- extract serializeTag()
|
|
167
|
-
- update/split serializeAttribs() ([cdf483b](https://github.com/thi-ng/umbrella/commit/cdf483b))
|
|
168
|
-
|
|
169
|
-
## [3.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@3.6.0) (2020-09-13)
|
|
170
|
-
|
|
171
|
-
#### 🚀 Features
|
|
172
|
-
|
|
173
|
-
- add CDATA support, update void tag handling ([5989427](https://github.com/thi-ng/umbrella/commit/5989427))
|
|
174
|
-
- add CDATA tag constant
|
|
175
|
-
- add serializeCData()
|
|
176
|
-
- update VOID_TAGS, extract NO_CLOSE_EMPTY
|
|
177
|
-
|
|
178
|
-
## [3.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@3.5.0) (2020-07-02)
|
|
179
|
-
|
|
180
|
-
#### 🚀 Features
|
|
181
|
-
|
|
182
|
-
- remove obsolete SVG/XLINK urls ([aa34be7](https://github.com/thi-ng/umbrella/commit/aa34be7))
|
|
183
|
-
- moved to [@thi.ng/prefixes](https://github.com/thi-ng/umbrella/tree/main/packages/prefixes) pkg for better re-use
|
|
184
|
-
- add RDFa `prefix` attrib handling, add tests ([24a7748](https://github.com/thi-ng/umbrella/commit/24a7748))
|
|
185
|
-
- add `formatPrefixes()` helper
|
|
186
|
-
- update `serializeAttribs()`
|
|
187
|
-
|
|
188
|
-
## [3.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@3.4.0) (2020-06-28)
|
|
189
|
-
|
|
190
|
-
#### 🚀 Features
|
|
191
|
-
|
|
192
|
-
- update deps & attrib handling ([09ba171](https://github.com/thi-ng/umbrella/commit/09ba171))
|
|
193
|
-
- add [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/main/packages/api) dep
|
|
194
|
-
- add support for IDeref attrib vals
|
|
195
|
-
- add support for `class` attrib obj vals
|
|
196
|
-
- add `mergeClasses()` helper
|
|
197
|
-
- add IDeref support inside `class` & `style` attribs
|
|
198
|
-
- add support for nested data attribs
|
|
199
|
-
|
|
200
|
-
## [3.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@3.3.0) (2020-06-24)
|
|
201
|
-
|
|
202
|
-
#### 🚀 Features
|
|
203
|
-
|
|
204
|
-
- support array attrib values, add tests ([1c4ef8a](https://github.com/thi-ng/umbrella/commit/1c4ef8a))
|
|
205
|
-
- update `accept` attrib handling ([fabf447](https://github.com/thi-ng/umbrella/commit/fabf447))
|
|
206
|
-
|
|
207
|
-
### [3.2.4](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@3.2.4) (2019-08-21)
|
|
208
|
-
|
|
209
|
-
#### 🩹 Bug fixes
|
|
210
|
-
|
|
211
|
-
- update/rename regexes & tag maps ([6dba80d](https://github.com/thi-ng/umbrella/commit/6dba80d))
|
|
212
|
-
|
|
213
|
-
#### ♻️ Refactoring
|
|
214
|
-
|
|
215
|
-
- split serialize(), move normalize() to own file ([fa56951](https://github.com/thi-ng/umbrella/commit/fa56951))
|
|
216
|
-
|
|
217
|
-
## [3.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@3.2.0) (2019-07-07)
|
|
218
|
-
|
|
219
|
-
#### 🚀 Features
|
|
220
|
-
|
|
221
|
-
- enable TS strict compiler flags (refactor) ([d0fce75](https://github.com/thi-ng/umbrella/commit/d0fce75))
|
|
222
|
-
|
|
223
|
-
#### ♻️ Refactoring
|
|
224
|
-
|
|
225
|
-
- address TS strictNullChecks flag ([c73b207](https://github.com/thi-ng/umbrella/commit/c73b207))
|
|
226
|
-
|
|
227
|
-
## [3.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@3.1.0) (2019-02-18)
|
|
228
|
-
|
|
229
|
-
#### 🚀 Features
|
|
230
|
-
|
|
231
|
-
- add support for XML/DTD proc tags, update readme, tests ([ede2842](https://github.com/thi-ng/umbrella/commit/ede2842))
|
|
232
|
-
|
|
233
|
-
# [3.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@3.0.0) (2019-01-21)
|
|
234
|
-
|
|
235
|
-
#### 🛑 Breaking changes
|
|
236
|
-
|
|
237
|
-
- update package build scripts & outputs, imports in ~50 packages ([b54b703](https://github.com/thi-ng/umbrella/commit/b54b703))
|
|
238
|
-
- BREAKING CHANGE: enabled multi-outputs (ES6 modules, CJS, UMD)
|
|
239
|
-
- build scripts now first build ES6 modules in package root, then call
|
|
240
|
-
`scripts/bundle-module` to build minified CJS & UMD bundles in `/lib`
|
|
241
|
-
- all imports MUST be updated to only refer to package level
|
|
242
|
-
(not individual files anymore). tree shaking in user land will get rid of
|
|
243
|
-
all unused imported symbols.
|
|
244
|
-
|
|
245
|
-
### [2.7.2](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@2.7.2) (2018-12-20)
|
|
246
|
-
|
|
247
|
-
#### ♻️ Refactoring
|
|
248
|
-
|
|
249
|
-
- export normalize() fn ([df38394](https://github.com/thi-ng/umbrella/commit/df38394))
|
|
250
|
-
|
|
251
|
-
## [2.7.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@2.7.0) (2018-12-13)
|
|
252
|
-
|
|
253
|
-
#### 🚀 Features
|
|
254
|
-
|
|
255
|
-
- add __skip support, add test, update readme ([d3500df](https://github.com/thi-ng/umbrella/commit/d3500df))
|
|
256
|
-
|
|
257
|
-
## [2.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@2.6.0) (2018-11-07)
|
|
258
|
-
|
|
259
|
-
#### 🚀 Features
|
|
260
|
-
|
|
261
|
-
- update derefContext() to only apply to selected keys ([749925f](https://github.com/thi-ng/umbrella/commit/749925f))
|
|
262
|
-
|
|
263
|
-
## [2.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@2.5.0) (2018-11-06)
|
|
264
|
-
|
|
265
|
-
#### 🚀 Features
|
|
266
|
-
|
|
267
|
-
- add support for dynamic user context values ([a947873](https://github.com/thi-ng/umbrella/commit/a947873))
|
|
268
|
-
- add derefContext() helper to auto-deref any IDeref vals
|
|
269
|
-
- update serialize()
|
|
270
|
-
|
|
271
|
-
## [2.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@2.4.0) (2018-09-23)
|
|
272
|
-
|
|
273
|
-
#### 🚀 Features
|
|
274
|
-
|
|
275
|
-
- emmet class & class attrib merging in normalize() ([1d8eeb4](https://github.com/thi-ng/umbrella/commit/1d8eeb4))
|
|
276
|
-
- now same behavior as hdom's normalizeElement()
|
|
277
|
-
- update tests
|
|
278
|
-
|
|
279
|
-
## [2.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@2.3.0) (2018-09-22)
|
|
280
|
-
|
|
281
|
-
#### 🚀 Features
|
|
282
|
-
|
|
283
|
-
- add control attrib handling, add comment support ([363c241](https://github.com/thi-ng/umbrella/commit/363c241))
|
|
284
|
-
- skip serialize() for elements w/ `__serialize: false` attrib
|
|
285
|
-
- omit output of any control attribs
|
|
286
|
-
- add COMMENT const and comment serialization
|
|
287
|
-
- update imports
|
|
288
|
-
- update docstring
|
|
289
|
-
|
|
290
|
-
## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@2.1.0) (2018-08-31)
|
|
291
|
-
|
|
292
|
-
#### 🚀 Features
|
|
293
|
-
|
|
294
|
-
- add optional support for spans & auto keying ([#39](https://github.com/thi-ng/umbrella/issues/39)) ([1b0deb2](https://github.com/thi-ng/umbrella/commit/1b0deb2))
|
|
295
|
-
|
|
296
|
-
#### 🩹 Bug fixes
|
|
297
|
-
|
|
298
|
-
- disable spans for certain element types ([1b97a25](https://github.com/thi-ng/umbrella/commit/1b97a25))
|
|
299
|
-
- re-add NO_SPANS (moved from hdom)
|
|
300
|
-
- update _serialize()
|
|
301
|
-
- serialize() args ([1e8b4ef](https://github.com/thi-ng/umbrella/commit/1e8b4ef))
|
|
302
|
-
|
|
303
|
-
# [2.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@2.0.0) (2018-05-13)
|
|
304
|
-
|
|
305
|
-
#### 🛑 Breaking changes
|
|
306
|
-
|
|
307
|
-
- fix [#19](https://github.com/thi-ng/umbrella/issues/19), add support for context object ([feca566](https://github.com/thi-ng/umbrella/commit/feca566))
|
|
308
|
-
- BREAKING CHANGE: component functions now take a global context object as
|
|
309
|
-
first argument (like w/ [@thi.ng/hdom](https://github.com/thi-ng/umbrella/tree/main/packages/hdom))
|
|
310
|
-
- update serialize() to accept & pass optional context
|
|
311
|
-
- add support for component objects
|
|
312
|
-
- add/update tests
|
|
313
|
-
|
|
314
|
-
#### ⏱ Performance improvements
|
|
315
|
-
|
|
316
|
-
- update css() ([b1cb7d9](https://github.com/thi-ng/umbrella/commit/b1cb7d9))
|
|
317
|
-
- use string concat (~2.5x faster)
|
|
318
|
-
- skip null values
|
|
319
|
-
|
|
320
|
-
### [1.3.14](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@1.3.14) (2018-05-10)
|
|
321
|
-
|
|
322
|
-
#### ♻️ Refactoring
|
|
323
|
-
|
|
324
|
-
- update deps & imports in all packages due to [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/main/packages/api) split ([bc45636](https://github.com/thi-ng/umbrella/commit/bc45636))
|
|
325
|
-
|
|
326
|
-
### [1.3.4](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@1.3.4) (2018-04-08)
|
|
327
|
-
|
|
328
|
-
#### ♻️ Refactoring
|
|
329
|
-
|
|
330
|
-
- remove obsolete deref check ([fcf1404](https://github.com/thi-ng/umbrella/commit/fcf1404))
|
|
331
|
-
|
|
332
|
-
## [1.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@1.3.0) (2018-03-21)
|
|
333
|
-
|
|
334
|
-
#### 🚀 Features
|
|
335
|
-
|
|
336
|
-
- update error handling, add [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/main/packages/api) dep ([a3238ab](https://github.com/thi-ng/umbrella/commit/a3238ab))
|
|
337
|
-
|
|
338
|
-
## [1.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@1.2.0) (2018-03-14)
|
|
339
|
-
|
|
340
|
-
#### 🚀 Features
|
|
341
|
-
|
|
342
|
-
- add auto deref() support ([0d2c16f](https://github.com/thi-ng/umbrella/commit/0d2c16f))
|
|
343
|
-
- support fn values in style objects ([93343d6](https://github.com/thi-ng/umbrella/commit/93343d6))
|
|
344
|
-
|
|
345
|
-
#### ♻️ Refactoring
|
|
346
|
-
|
|
347
|
-
- disable deref() for attrib objects ([de839e8](https://github.com/thi-ng/umbrella/commit/de839e8))
|
|
348
|
-
|
|
349
|
-
### [1.1.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@1.1.1) (2018-02-26)
|
|
350
|
-
|
|
351
|
-
#### ♻️ Refactoring
|
|
352
|
-
|
|
353
|
-
- sort void tags ([45d6385](https://github.com/thi-ng/umbrella/commit/45d6385))
|
|
354
|
-
|
|
355
|
-
## [1.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@1.1.0) (2018-02-24)
|
|
356
|
-
|
|
357
|
-
#### 🚀 Features
|
|
358
|
-
|
|
359
|
-
- add support for more SVG tags (66 total) ([44f33df](https://github.com/thi-ng/umbrella/commit/44f33df))
|
|
360
|
-
|
|
361
|
-
# [1.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@1.0.0) (2018-02-03)
|
|
362
|
-
|
|
363
|
-
#### 🛑 Breaking changes
|
|
364
|
-
|
|
365
|
-
- skip fn exec for event attribs, update tests, readme ([7ae706e](https://github.com/thi-ng/umbrella/commit/7ae706e))
|
|
366
|
-
- BREAKING CHANGE: event attribs w/ function values will be omitted, see readme for details/examples
|
|
367
|
-
|
|
368
|
-
### [0.1.6](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@0.1.6) (2018-02-01)
|
|
369
|
-
|
|
370
|
-
#### ♻️ Refactoring
|
|
371
|
-
|
|
372
|
-
- update/add deps, restructure/split into sub-modules ([0439d24](https://github.com/thi-ng/umbrella/commit/0439d24))
|
|
373
|
-
|
|
374
|
-
### [0.1.2](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@0.1.2) (2018-01-24)
|
|
375
|
-
|
|
376
|
-
#### 🚀 Features
|
|
377
|
-
|
|
378
|
-
- initial re-import as monorepo, update readme files, cleanup imports ([04ff6e9](https://github.com/thi-ng/umbrella/commit/04ff6e9))
|
package/README.md
CHANGED
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
- [Component objects](#component-objects)
|
|
38
38
|
- [Behavior control attributes](#behavior-control-attributes)
|
|
39
39
|
- [Comments](#comments)
|
|
40
|
+
- [Inlined/embedded markup](#inlinedembedded-markup)
|
|
40
41
|
- [XML / DTD processing instructions](#xml--dtd-processing-instructions)
|
|
41
42
|
- [API](#api)
|
|
42
43
|
- [serialize()](#serialize)
|
|
@@ -183,7 +184,7 @@ For Node.js REPL:
|
|
|
183
184
|
const h = await import("@thi.ng/hiccup");
|
|
184
185
|
```
|
|
185
186
|
|
|
186
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 2.
|
|
187
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 2.24 KB
|
|
187
188
|
|
|
188
189
|
## Dependencies
|
|
189
190
|
|
|
@@ -391,7 +392,9 @@ serialize([div, {id: "foo"}, "bar"]);
|
|
|
391
392
|
|
|
392
393
|
Also see
|
|
393
394
|
[@thi.ng/hiccup-svg](https://github.com/thi-ng/umbrella/tree/develop/packages/hiccup-svg)
|
|
394
|
-
|
|
395
|
+
and
|
|
396
|
+
[@thi.ng/geom](https://github.com/thi-ng/umbrella/tree/develop/packages/geom)
|
|
397
|
+
for related (and more advanced) functionality.
|
|
395
398
|
|
|
396
399
|
```ts tangle:export/readme-circles.js
|
|
397
400
|
import { serialize } from "@thi.ng/hiccup";
|
|
@@ -554,11 +557,10 @@ Re-formatted HTML output:
|
|
|
554
557
|
|
|
555
558
|
The sibling library
|
|
556
559
|
[@thi.ng/hdom](https://github.com/thi-ng/umbrella/tree/develop/packages/hdom)
|
|
557
|
-
supports components with basic life cycle methods (init, render,
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
are ignored.
|
|
560
|
+
supports components with basic life cycle methods (init, render, release). To
|
|
561
|
+
support serialization of hdom component trees, hiccup too supports such
|
|
562
|
+
components since version 2.0.0. For static serialization only the `render`
|
|
563
|
+
method is of interest and others are ignored.
|
|
562
564
|
|
|
563
565
|
```js
|
|
564
566
|
const component = {
|
|
@@ -573,6 +575,7 @@ serialize([component, "Hello world", "Body"]);
|
|
|
573
575
|
The following attributes can be used to control the serialization
|
|
574
576
|
behavior of individual elements / tree branches:
|
|
575
577
|
|
|
578
|
+
- **`__escape`** - boolean flag to enable/disable entity escaping
|
|
576
579
|
- **`__skip`** - if true, skips serialization (also used by
|
|
577
580
|
[@thi.ng/hdom](https://github.com/thi-ng/umbrella/tree/develop/packages/hdom))
|
|
578
581
|
- **`__serialize`** - if false, skips serialization (hiccup only)
|
|
@@ -585,7 +588,7 @@ serialize(["div.container", ["div", { __skip: true }, "ignore me"]]);
|
|
|
585
588
|
### Comments
|
|
586
589
|
|
|
587
590
|
Single or multiline comments can be included using the special `COMMENT`
|
|
588
|
-
tag (`__COMMENT__
|
|
591
|
+
tag (or `__COMMENT__`, always WITHOUT attributes!).
|
|
589
592
|
|
|
590
593
|
```ts
|
|
591
594
|
import { COMMENT } from "@thi.ng/hiccup";
|
|
@@ -601,6 +604,22 @@ import { COMMENT } from "@thi.ng/hiccup";
|
|
|
601
604
|
// -->
|
|
602
605
|
```
|
|
603
606
|
|
|
607
|
+
### Inlined/embedded markup
|
|
608
|
+
|
|
609
|
+
Pre-serialized markup can be inlined without any further processing using the
|
|
610
|
+
special `INLINE` tag (or `__INLINE__`, always WITHOUT attributes!):
|
|
611
|
+
|
|
612
|
+
```js
|
|
613
|
+
import { INLINE, serialize } from "@thi.ng/hiccup";
|
|
614
|
+
|
|
615
|
+
serialize(
|
|
616
|
+
["div", {}
|
|
617
|
+
[INLINE, "<h3>Inlined & Embedded</h3><p>Lorem ipsum...</p>"]
|
|
618
|
+
]
|
|
619
|
+
);
|
|
620
|
+
// <div><h3>Inlined & Embedded</h3><p>Lorem ipsum...</p></div>
|
|
621
|
+
```
|
|
622
|
+
|
|
604
623
|
### XML / DTD processing instructions
|
|
605
624
|
|
|
606
625
|
Currently, the only processing / DTD instructions supported are:
|
package/api.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export declare const RE_TAG: RegExp;
|
|
|
7
7
|
/** @internal */
|
|
8
8
|
export declare const COMMENT = "__COMMENT__";
|
|
9
9
|
/** @internal */
|
|
10
|
+
export declare const INLINE = "__INLINE__";
|
|
11
|
+
/** @internal */
|
|
10
12
|
export declare const CDATA = "!CDATA";
|
|
11
13
|
/** @internal */
|
|
12
14
|
export declare const DOCTYPE = "!DOCTYPE";
|
package/api.js
CHANGED
|
@@ -7,6 +7,7 @@ const PROC_TAGS = {
|
|
|
7
7
|
};
|
|
8
8
|
const RE_TAG = /^([^\s.#]+)(?:#([^\s.#]+))?(?:\.([^\s#]+))?$/;
|
|
9
9
|
const COMMENT = "__COMMENT__";
|
|
10
|
+
const INLINE = "__INLINE__";
|
|
10
11
|
const CDATA = "!CDATA";
|
|
11
12
|
const DOCTYPE = "!DOCTYPE";
|
|
12
13
|
const XML_PROC = ["?xml", { version: "1.0", encoding: "UTF-8" }];
|
|
@@ -42,6 +43,7 @@ export {
|
|
|
42
43
|
COMMENT,
|
|
43
44
|
DOCTYPE,
|
|
44
45
|
DOCTYPE_HTML,
|
|
46
|
+
INLINE,
|
|
45
47
|
NO_CLOSE_EMPTY,
|
|
46
48
|
NO_SPANS,
|
|
47
49
|
PROC_TAGS,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/hiccup",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.1",
|
|
4
4
|
"description": "HTML/SVG/XML serialization of nested data structures, iterables & closures",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -40,17 +40,16 @@
|
|
|
40
40
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@thi.ng/api": "^8.11.
|
|
44
|
-
"@thi.ng/checks": "^3.6.
|
|
45
|
-
"@thi.ng/errors": "^2.5.
|
|
46
|
-
"@thi.ng/strings": "^3.9.
|
|
43
|
+
"@thi.ng/api": "^8.11.18",
|
|
44
|
+
"@thi.ng/checks": "^3.6.21",
|
|
45
|
+
"@thi.ng/errors": "^2.5.24",
|
|
46
|
+
"@thi.ng/strings": "^3.9.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@
|
|
50
|
-
"@thi.ng/atom": "^5.3.18",
|
|
49
|
+
"@thi.ng/atom": "^5.3.19",
|
|
51
50
|
"esbuild": "^0.24.2",
|
|
52
51
|
"typedoc": "^0.27.6",
|
|
53
|
-
"typescript": "^5.7.
|
|
52
|
+
"typescript": "^5.7.3"
|
|
54
53
|
},
|
|
55
54
|
"keywords": [
|
|
56
55
|
"array",
|
|
@@ -132,5 +131,5 @@
|
|
|
132
131
|
],
|
|
133
132
|
"year": 2016
|
|
134
133
|
},
|
|
135
|
-
"gitHead": "
|
|
134
|
+
"gitHead": "b92b48abda9941d608be8a2e1c83447e679a6f79\n"
|
|
136
135
|
}
|
package/serialize.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
ATTRIB_JOIN_DELIMS,
|
|
12
12
|
CDATA,
|
|
13
13
|
COMMENT,
|
|
14
|
+
INLINE,
|
|
14
15
|
NO_CLOSE_EMPTY,
|
|
15
16
|
NO_SPANS,
|
|
16
17
|
PROC_TAGS,
|
|
@@ -38,13 +39,14 @@ const __serializeElement = (tree, opts, path) => {
|
|
|
38
39
|
tag.render.apply(null, [opts.ctx, ...tree.slice(1)]),
|
|
39
40
|
opts,
|
|
40
41
|
path
|
|
41
|
-
) : tag === COMMENT ? __serializeComment(tree) : tag == CDATA ? __serializeCData(tree) : isString(tag) ? __serializeTag(tree, opts, path) : isNotStringAndIterable(tree) ? __serializeIter(tree, opts, path) : illegalArgs(`invalid tree node: ${tree}`);
|
|
42
|
+
) : tag === COMMENT ? __serializeComment(tree) : tag === INLINE ? __serializeInline(tree) : tag == CDATA ? __serializeCData(tree) : isString(tag) ? __serializeTag(tree, opts, path) : isNotStringAndIterable(tree) ? __serializeIter(tree, opts, path) : illegalArgs(`invalid tree node: ${tree}`);
|
|
42
43
|
};
|
|
43
44
|
const __serializeTag = (tree, opts, path) => {
|
|
44
45
|
tree = normalize(tree);
|
|
45
46
|
const attribs = tree[1];
|
|
46
47
|
if (attribs.__skip || attribs.__serialize === false) return "";
|
|
47
48
|
opts.keys && attribs.key === void 0 && (attribs.key = path.join("-"));
|
|
49
|
+
if (attribs.__escape != null) opts = { ...opts, escape: attribs.__escape };
|
|
48
50
|
const tag = tree[0];
|
|
49
51
|
const body = tree[2] ? __serializeBody(tag, tree[2], opts, path) : !VOID_TAGS[tag] && !NO_CLOSE_EMPTY[tag] ? `></${tag}>` : PROC_TAGS[tag] || "/>";
|
|
50
52
|
return `<${tag}${__serializeAttribs(attribs, opts)}${body}`;
|
|
@@ -93,6 +95,7 @@ ${tree.slice(1).map((x) => " " + x).join("\n")}
|
|
|
93
95
|
` : `
|
|
94
96
|
<!-- ${tree[1]} -->
|
|
95
97
|
`;
|
|
98
|
+
const __serializeInline = (tree) => tree.slice(1).join("");
|
|
96
99
|
const __serializeCData = (tree) => `<![CDATA[
|
|
97
100
|
${tree.slice(1).join("\n")}
|
|
98
101
|
]]>`;
|