@openstage/glyph-renderer 0.2.3 → 0.4.0-rc.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/LICENSE +21 -0
- package/README.md +5 -4
- package/dist/highlight.d.ts +1 -1
- package/dist/highlight.d.ts.map +1 -1
- package/dist/highlight.js +18 -45
- package/dist/highlight.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +58 -80
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gabriel Bornea
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @openstage/glyph-renderer
|
|
2
2
|
|
|
3
|
-
Read-only renderer for [Glyph](https://
|
|
3
|
+
Read-only renderer for [Glyph](https://gitlab.com/open-stage/glyph)
|
|
4
4
|
documents. Turns a saved `EditorDocument` into DOM (or an HTML string) for
|
|
5
5
|
display **without loading the editor**, with lazy language-aware code
|
|
6
6
|
highlighting.
|
|
@@ -21,8 +21,9 @@ container.replaceChildren(renderToElement(savedDocument));
|
|
|
21
21
|
Output is built with `createElement`/`textContent` only (never `innerHTML`),
|
|
22
22
|
link `href`s are scheme-allowlisted, control-obfuscated `javascript:`/`data:`
|
|
23
23
|
URLs are stripped, and highlighted code is assembled from a parsed token tree —
|
|
24
|
-
**untrusted documents render safely**.
|
|
25
|
-
(`target="_blank"` +
|
|
24
|
+
**untrusted documents render safely**. Malformed content degrades instead of
|
|
25
|
+
throwing. Rendered links open in a new tab (`target="_blank"` +
|
|
26
|
+
`rel="noopener noreferrer"`).
|
|
26
27
|
|
|
27
28
|
## Syntax highlighting
|
|
28
29
|
|
|
@@ -52,7 +53,7 @@ const html = renderToHTML(savedDocument); // now highlighted
|
|
|
52
53
|
## Documentation
|
|
53
54
|
|
|
54
55
|
Full guide and supported-content reference:
|
|
55
|
-
<https://
|
|
56
|
+
<https://gitlab.com/open-stage/glyph#readme>
|
|
56
57
|
|
|
57
58
|
## License
|
|
58
59
|
|
package/dist/highlight.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare const isLanguageSupported: (language: string) => boolean;
|
|
|
20
20
|
/**
|
|
21
21
|
* Loads and registers a grammar on demand (idempotent, de-duplicated).
|
|
22
22
|
* Resolves `true` once the language is highlightable, `false` if there is no
|
|
23
|
-
* grammar for it.
|
|
23
|
+
* grammar for it or it failed to load (a later call retries).
|
|
24
24
|
*/
|
|
25
25
|
export declare const ensureLanguage: (language: string) => Promise<boolean>;
|
|
26
26
|
/** Eagerly load grammars (e.g. before a synchronous {@link renderToHTML}). */
|
package/dist/highlight.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../src/highlight.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../src/highlight.ts"],"names":[],"mappings":"AAiCA,QAAA,MAAM,QAAQ;wDAzByB,CAAC;0CACc,CAAC;;;;;;;;;;;CAwBtB,CAAC;AASlC;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,UAAU,MAAM,KAAG,OAIpD,CAAC;AAuBJ;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,KAAG,OAAO,CAAC,OAAO,CACH,CAAC;AAE/D,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,GAAI,WAAW,SAAS,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CACV,CAAC;AAgCnE;;;;GAIG;AACH,eAAO,MAAM,cAAc,GACzB,KAAK,QAAQ,EACb,UAAU,MAAM,EAChB,MAAM,MAAM,KACX,gBAAgB,GAAG,IAMjB,CAAC;AAEN,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/highlight.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Option } from '@openstage/monadyssey-core';
|
|
2
|
+
import { resolveCodeLanguage } from '@openstage/glyph-core';
|
|
1
3
|
import { createLowlight } from 'lowlight';
|
|
2
4
|
/**
|
|
3
5
|
* Lazy-loaded syntax highlighting. Grammars are NOT bundled — each is a
|
|
@@ -25,49 +27,15 @@ const loaders = {
|
|
|
25
27
|
typescript: () => import('highlight.js/lib/languages/typescript'),
|
|
26
28
|
xml: () => import('highlight.js/lib/languages/xml'),
|
|
27
29
|
};
|
|
28
|
-
// Aliases we advertise → canonical loader id (grammars register their own
|
|
29
|
-
// highlight.js aliases too, but only after they are loaded).
|
|
30
|
-
const aliases = {
|
|
31
|
-
ts: 'typescript',
|
|
32
|
-
js: 'javascript',
|
|
33
|
-
jsx: 'javascript',
|
|
34
|
-
sh: 'bash',
|
|
35
|
-
shell: 'bash',
|
|
36
|
-
zsh: 'bash',
|
|
37
|
-
html: 'xml',
|
|
38
|
-
htm: 'xml',
|
|
39
|
-
xhtml: 'xml',
|
|
40
|
-
svg: 'xml',
|
|
41
|
-
cs: 'csharp',
|
|
42
|
-
'c#': 'csharp',
|
|
43
|
-
fs: 'fsharp',
|
|
44
|
-
'f#': 'fsharp',
|
|
45
|
-
kt: 'kotlin',
|
|
46
|
-
py: 'python',
|
|
47
|
-
rs: 'rust',
|
|
48
|
-
md: 'markdown',
|
|
49
|
-
};
|
|
50
30
|
const lowlight = createLowlight();
|
|
51
|
-
const
|
|
52
|
-
const n = name.trim().toLowerCase();
|
|
53
|
-
return aliases[n] ?? n;
|
|
54
|
-
};
|
|
31
|
+
const grammarOf = (language) => Option.ofNullable(resolveCodeLanguage(language)).flatMap((id) => Option.ofNullable(loaders[id]).map((loader) => ({ id, loader })));
|
|
55
32
|
/**
|
|
56
33
|
* Whether a language *can* be highlighted (a loader exists). It may not be
|
|
57
34
|
* loaded yet — see {@link ensureLanguage}.
|
|
58
35
|
*/
|
|
59
|
-
export const isLanguageSupported = (language) =>
|
|
36
|
+
export const isLanguageSupported = (language) => grammarOf(language).fold(() => false, () => true);
|
|
60
37
|
const pending = new Map();
|
|
61
|
-
|
|
62
|
-
* Loads and registers a grammar on demand (idempotent, de-duplicated).
|
|
63
|
-
* Resolves `true` once the language is highlightable, `false` if there is no
|
|
64
|
-
* grammar for it.
|
|
65
|
-
*/
|
|
66
|
-
export const ensureLanguage = (language) => {
|
|
67
|
-
const id = normalize(language);
|
|
68
|
-
const loader = loaders[id];
|
|
69
|
-
if (!loader)
|
|
70
|
-
return Promise.resolve(false);
|
|
38
|
+
const load = ({ id, loader }) => {
|
|
71
39
|
if (lowlight.registered(id))
|
|
72
40
|
return Promise.resolve(true);
|
|
73
41
|
const inflight = pending.get(id);
|
|
@@ -80,10 +48,19 @@ export const ensureLanguage = (language) => {
|
|
|
80
48
|
}
|
|
81
49
|
return true;
|
|
82
50
|
})
|
|
83
|
-
.catch(() => false)
|
|
51
|
+
.catch(() => false)
|
|
52
|
+
// Settled loads leave the map: a success is now `registered`, and a
|
|
53
|
+
// failure (e.g. a chunk network error) must be retryable.
|
|
54
|
+
.finally(() => pending.delete(id));
|
|
84
55
|
pending.set(id, p);
|
|
85
56
|
return p;
|
|
86
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Loads and registers a grammar on demand (idempotent, de-duplicated).
|
|
60
|
+
* Resolves `true` once the language is highlightable, `false` if there is no
|
|
61
|
+
* grammar for it or it failed to load (a later call retries).
|
|
62
|
+
*/
|
|
63
|
+
export const ensureLanguage = (language) => grammarOf(language).fold(() => Promise.resolve(false), load);
|
|
87
64
|
/** Eagerly load grammars (e.g. before a synchronous {@link renderToHTML}). */
|
|
88
65
|
export const preloadLanguages = (languages) => Promise.all(languages.map(ensureLanguage)).then(() => undefined);
|
|
89
66
|
const toClassList = (className) => className == null ? [] : Array.isArray(className) ? className : [className];
|
|
@@ -104,12 +81,8 @@ const hastToDom = (doc) => (node) => {
|
|
|
104
81
|
* is unknown or not yet loaded. Callers wanting lazy upgrade should fall back
|
|
105
82
|
* to plain text and re-render after {@link ensureLanguage} resolves.
|
|
106
83
|
*/
|
|
107
|
-
export const highlightToDom = (doc, language, code) =>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return null;
|
|
111
|
-
const tree = lowlight.highlight(id, code);
|
|
112
|
-
return hastToDom(doc)(tree);
|
|
113
|
-
};
|
|
84
|
+
export const highlightToDom = (doc, language, code) => Option.ofNullable(resolveCodeLanguage(language))
|
|
85
|
+
.filter((id) => lowlight.registered(id))
|
|
86
|
+
.fold(() => null, (id) => hastToDom(doc)(lowlight.highlight(id, code)));
|
|
114
87
|
export { lowlight };
|
|
115
88
|
//# sourceMappingURL=highlight.js.map
|
package/dist/highlight.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight.js","sourceRoot":"","sources":["../src/highlight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"highlight.js","sourceRoot":"","sources":["../src/highlight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAiB,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI1C;;;;;GAKG;AACH,MAAM,OAAO,GAA2B;IACtC,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,iCAAiC,CAAC;IACrD,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,mCAAmC,CAAC;IACzD,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,gCAAgC,CAAC;IACnD,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,mCAAmC,CAAC;IACzD,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,+BAA+B,CAAC;IACjD,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,oCAAoC,CAAC;IAC3D,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,iCAAiC,CAAC;IACrD,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,uCAAuC,CAAC;IACjE,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,iCAAiC,CAAC;IACrD,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,mCAAmC,CAAC;IACzD,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,qCAAqC,CAAC;IAC7D,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,kCAAkC,CAAC;IACvD,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,C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EN,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,13 +11,16 @@ export type RenderOptions = {
|
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Renders a document to a detached `<div class="glyph-rendered">` you can
|
|
14
|
-
* insert anywhere. The input is migrated to the current schema
|
|
15
|
-
* documents saved by older versions render correctly
|
|
16
|
-
*
|
|
14
|
+
* insert anywhere. The input is migrated to the current schema and then
|
|
15
|
+
* normalized, so documents saved by older versions render correctly and
|
|
16
|
+
* malformed content degrades instead of throwing. Style the result with your
|
|
17
|
+
* own CSS (and {@link highlightThemeCss} for code blocks).
|
|
17
18
|
*
|
|
18
19
|
* @param input - A full {@link EditorDocument} or a bare doc root.
|
|
19
20
|
* @param options - See {@link RenderOptions}.
|
|
20
21
|
* @returns A detached element containing the rendered content.
|
|
22
|
+
* @throws RangeError if `schemaVersion` is unsupported (see `migrate`).
|
|
23
|
+
* @throws Error if there is no ambient `document` and none was passed.
|
|
21
24
|
*
|
|
22
25
|
* @example
|
|
23
26
|
* ```ts
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EAKf,MAAM,uBAAuB,CAAC;AAsB/B,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,kEAAkE;AAClE,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;AAqIF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,cAAc,GAAG,aAAa,EACrC,UAAS,aAAkB,KAC1B,WAKF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,cAAc,GAAG,aAAa,EACrC,UAAS,aAAkB,KAC1B,MAAmD,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Option } from '@openstage/monadyssey-core';
|
|
2
|
+
import { migrate, normalizeContent, sanitizeHref } from '@openstage/glyph-core';
|
|
3
3
|
/**
|
|
4
4
|
* `@openstage/glyph-renderer` — turns an {@link EditorDocument} into read-only DOM (or an
|
|
5
5
|
* HTML string) for displaying saved content without loading the editor.
|
|
@@ -16,93 +16,70 @@ import { Href as HrefT, migrate } from '@openstage/glyph-core';
|
|
|
16
16
|
*
|
|
17
17
|
* @packageDocumentation
|
|
18
18
|
*/
|
|
19
|
-
import { ensureLanguage, highlightToDom
|
|
19
|
+
import { ensureLanguage, highlightToDom } from './highlight.js';
|
|
20
20
|
export { isLanguageSupported, ensureLanguage, preloadLanguages } from './highlight.js';
|
|
21
21
|
export { highlightThemeCss } from './highlight-theme.js';
|
|
22
|
-
// Control/space chars the browser strips when resolving URLs (tab, newline,
|
|
23
|
-
// leading C0). Matching them is the point here, hence the disable.
|
|
24
|
-
// eslint-disable-next-line no-control-regex
|
|
25
|
-
const CONTROL_OR_SPACE = /[\u0000-\u0020]+/g;
|
|
26
|
-
const sanitizeHref = (href) => {
|
|
27
|
-
// Browsers strip embedded tabs/newlines and ignore leading C0 control
|
|
28
|
-
// chars when resolving a URL, so "java\nscript:" or "javascript:"
|
|
29
|
-
// would otherwise slip through as a "relative" URL and then execute.
|
|
30
|
-
// Strip all control/space chars BEFORE deciding, and store the cleaned
|
|
31
|
-
// value so the browser cannot re-derive a dangerous scheme.
|
|
32
|
-
const cleaned = href.replace(CONTROL_OR_SPACE, '');
|
|
33
|
-
if (cleaned === '')
|
|
34
|
-
return None.Instance;
|
|
35
|
-
// Relative URLs (no scheme) are safe; reject javascript:/data: and friends.
|
|
36
|
-
const allowed = /^(https?:|mailto:|tel:)/i.test(cleaned) ||
|
|
37
|
-
/^[/#.]/.test(cleaned) ||
|
|
38
|
-
!/^[a-z][a-z0-9+.-]*:/i.test(cleaned);
|
|
39
|
-
return Option.ofNullable(allowed ? HrefT.of(cleaned) : null);
|
|
40
|
-
};
|
|
41
22
|
const el = (doc) => (tag) => doc.createElement(tag);
|
|
23
|
+
const wrapIn = (doc) => (tag, child) => {
|
|
24
|
+
const wrapper = el(doc)(tag);
|
|
25
|
+
wrapper.appendChild(child);
|
|
26
|
+
return wrapper;
|
|
27
|
+
};
|
|
42
28
|
const wrapMark = (doc) => (child, mark) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
switch (mark.type) {
|
|
30
|
+
case 'bold':
|
|
31
|
+
return wrapIn(doc)('strong', child);
|
|
32
|
+
case 'italic':
|
|
33
|
+
return wrapIn(doc)('em', child);
|
|
34
|
+
case 'code':
|
|
35
|
+
return wrapIn(doc)('code', child);
|
|
36
|
+
case 'link':
|
|
37
|
+
// Re-checked although normalization already did: this is the XSS boundary.
|
|
38
|
+
return Option.ofNullable(sanitizeHref(mark.attrs.href)).fold(() => child, (safe) => {
|
|
39
|
+
const a = wrapIn(doc)('a', child);
|
|
40
|
+
a.setAttribute('href', safe);
|
|
41
|
+
// Open in a new tab so readers don't navigate away from the host page.
|
|
42
|
+
a.setAttribute('target', '_blank');
|
|
43
|
+
a.setAttribute('rel', 'noopener noreferrer');
|
|
44
|
+
return a;
|
|
45
|
+
});
|
|
47
46
|
}
|
|
48
|
-
if (mark.type === 'italic') {
|
|
49
|
-
const em = el(doc)('em');
|
|
50
|
-
em.appendChild(child);
|
|
51
|
-
return em;
|
|
52
|
-
}
|
|
53
|
-
return sanitizeHref(mark.attrs.href).fold(() => child, (safe) => {
|
|
54
|
-
const a = el(doc)('a');
|
|
55
|
-
a.setAttribute('href', safe);
|
|
56
|
-
// Open in a new tab so readers don't navigate away from the host page.
|
|
57
|
-
a.setAttribute('target', '_blank');
|
|
58
|
-
a.setAttribute('rel', 'noopener noreferrer');
|
|
59
|
-
a.appendChild(child);
|
|
60
|
-
return a;
|
|
61
|
-
});
|
|
62
47
|
};
|
|
63
48
|
const renderText = (doc) => (node) => (node.marks ?? []).reduce(wrapMark(doc), doc.createTextNode(node.text));
|
|
64
49
|
const renderInline = (doc) => (parent, content) => {
|
|
65
50
|
(content ?? []).forEach((n) => parent.appendChild(renderText(doc)(n)));
|
|
66
51
|
return parent;
|
|
67
52
|
};
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
53
|
+
// Recursion depth is bounded by normalizeContent's MAX_DEPTH.
|
|
54
|
+
const renderBlocks = (doc) => (parent, nodes) => {
|
|
55
|
+
nodes.forEach((n) => parent.appendChild(renderNode(doc)(n)));
|
|
56
|
+
return parent;
|
|
57
|
+
};
|
|
58
|
+
const renderList = (doc) => (tag, items) => {
|
|
59
|
+
const list = el(doc)(tag);
|
|
60
|
+
items.forEach((item) => list.appendChild(renderBlocks(doc)(el(doc)('li'), item.content)));
|
|
61
|
+
return list;
|
|
73
62
|
};
|
|
74
|
-
// Returns null for unknown/invalid node types so an untrusted document with
|
|
75
|
-
// an injected node degrades gracefully instead of throwing (DoS-safe).
|
|
76
63
|
const renderNode = (doc) => (node) => {
|
|
77
64
|
switch (node.type) {
|
|
78
65
|
case 'paragraph':
|
|
79
|
-
return
|
|
80
|
-
case 'heading':
|
|
81
|
-
|
|
82
|
-
// input straight into a tag name.
|
|
83
|
-
const level = node.attrs?.level === 2 ? 2 : node.attrs?.level === 3 ? 3 : 1;
|
|
84
|
-
return renderInline(doc)(el(doc)(`h${level}`), node.content);
|
|
85
|
-
}
|
|
66
|
+
return renderInline(doc)(el(doc)('p'), node.content);
|
|
67
|
+
case 'heading':
|
|
68
|
+
return renderInline(doc)(el(doc)(`h${node.attrs.level}`), node.content);
|
|
86
69
|
case 'bulletList':
|
|
70
|
+
return renderList(doc)('ul', node.content);
|
|
87
71
|
case 'orderedList': {
|
|
88
|
-
const
|
|
89
|
-
node.
|
|
90
|
-
return
|
|
91
|
-
}
|
|
92
|
-
case 'blockquote': {
|
|
93
|
-
const bq = el(doc)('blockquote');
|
|
94
|
-
node.content.forEach((p) => bq.appendChild(renderParagraph(doc)(p)));
|
|
95
|
-
return bq;
|
|
72
|
+
const ol = renderList(doc)('ol', node.content);
|
|
73
|
+
Option.ofNullable(node.attrs?.start).tap((start) => ol.setAttribute('start', `${start}`));
|
|
74
|
+
return ol;
|
|
96
75
|
}
|
|
76
|
+
case 'blockquote':
|
|
77
|
+
return renderBlocks(doc)(el(doc)('blockquote'), node.content);
|
|
97
78
|
case 'codeBlock': {
|
|
98
79
|
const pre = el(doc)('pre');
|
|
99
80
|
const code = el(doc)('code');
|
|
100
81
|
const source = (node.content ?? []).map((t) => t.text).join('');
|
|
101
|
-
|
|
102
|
-
// could carry an arbitrary string, and an unsanitized value would be
|
|
103
|
-
// interpolated into a CSS class (classList.add throws on whitespace).
|
|
104
|
-
const rawLanguage = node.attrs?.language;
|
|
105
|
-
const language = rawLanguage && isLanguageSupported(rawLanguage) ? rawLanguage : undefined;
|
|
82
|
+
const language = node.attrs?.language;
|
|
106
83
|
const highlighted = language ? highlightToDom(doc, language, source) : null;
|
|
107
84
|
if (language) {
|
|
108
85
|
code.setAttribute('data-language', language);
|
|
@@ -132,20 +109,26 @@ const renderNode = (doc) => (node) => {
|
|
|
132
109
|
pre.appendChild(code);
|
|
133
110
|
return pre;
|
|
134
111
|
}
|
|
135
|
-
default:
|
|
136
|
-
return null;
|
|
137
112
|
}
|
|
138
113
|
};
|
|
139
|
-
|
|
114
|
+
// Normalizing makes rendering total: malformed or untrusted content degrades
|
|
115
|
+
// instead of throwing, and everything below can trust the typed tree.
|
|
116
|
+
const resolveContent = (input) => normalizeContent('schemaVersion' in input ? migrate(input).content : input);
|
|
117
|
+
const ambientDocument = () => Option.ofNullable(globalThis.document).getOrElse(() => {
|
|
118
|
+
throw new Error('No DOM available: pass `options.document` (e.g. from a DOM shim) to render.');
|
|
119
|
+
});
|
|
140
120
|
/**
|
|
141
121
|
* Renders a document to a detached `<div class="glyph-rendered">` you can
|
|
142
|
-
* insert anywhere. The input is migrated to the current schema
|
|
143
|
-
* documents saved by older versions render correctly
|
|
144
|
-
*
|
|
122
|
+
* insert anywhere. The input is migrated to the current schema and then
|
|
123
|
+
* normalized, so documents saved by older versions render correctly and
|
|
124
|
+
* malformed content degrades instead of throwing. Style the result with your
|
|
125
|
+
* own CSS (and {@link highlightThemeCss} for code blocks).
|
|
145
126
|
*
|
|
146
127
|
* @param input - A full {@link EditorDocument} or a bare doc root.
|
|
147
128
|
* @param options - See {@link RenderOptions}.
|
|
148
129
|
* @returns A detached element containing the rendered content.
|
|
130
|
+
* @throws RangeError if `schemaVersion` is unsupported (see `migrate`).
|
|
131
|
+
* @throws Error if there is no ambient `document` and none was passed.
|
|
149
132
|
*
|
|
150
133
|
* @example
|
|
151
134
|
* ```ts
|
|
@@ -153,15 +136,10 @@ const resolveContent = (input) => 'schemaVersion' in input ? migrate(input).cont
|
|
|
153
136
|
* ```
|
|
154
137
|
*/
|
|
155
138
|
export const renderToElement = (input, options = {}) => {
|
|
156
|
-
const doc = Option.ofNullable(options.document).getOrElse(
|
|
139
|
+
const doc = Option.ofNullable(options.document).getOrElse(ambientDocument);
|
|
157
140
|
const root = el(doc)('div');
|
|
158
141
|
root.className = 'glyph-rendered';
|
|
159
|
-
resolveContent(input).content
|
|
160
|
-
const rendered = renderNode(doc)(node);
|
|
161
|
-
if (rendered)
|
|
162
|
-
root.appendChild(rendered);
|
|
163
|
-
});
|
|
164
|
-
return root;
|
|
142
|
+
return renderBlocks(doc)(root, resolveContent(input).content);
|
|
165
143
|
};
|
|
166
144
|
/**
|
|
167
145
|
* Like {@link renderToElement} but returns the inner HTML string (built from
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AASpD,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEhF;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAWzD,MAAM,EAAE,GACN,CAAC,GAAa,EAAE,EAAE,CAClB,CAAC,GAAW,EAAe,EAAE,CAC3B,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;AAE3B,MAAM,MAAM,GACV,CAAC,GAAa,EAAE,EAAE,CAClB,CAAC,GAAW,EAAE,KAAW,EAAe,EAAE;IACxC,MAAM,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC3B,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEJ,MAAM,QAAQ,GACZ,CAAC,GAAa,EAAE,EAAE,CAClB,CAAC,KAAW,EAAE,IAAc,EAAQ,EAAE;IACpC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,MAAM;YACT,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACtC,KAAK,QAAQ;YACX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AAC,CAAC;AACjG,CAAC,CAAC,CAAC;AAEL;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAqC,EACrC,UAAyB,EAAE,EACd,EAAE;IACf,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IAC3E,MAAM,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC;IAClC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;AAChE,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAAqC,EACrC,UAAyB,EAAE,EACnB,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openstage/glyph-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-rc.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Gabriel Bornea",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://
|
|
8
|
+
"url": "git+https://gitlab.com/open-stage/glyph.git",
|
|
9
9
|
"directory": "packages/renderer"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://gitlab.com/open-stage/glyph#readme",
|
|
12
12
|
"bugs": {
|
|
13
|
-
"url": "https://
|
|
13
|
+
"url": "https://gitlab.com/open-stage/glyph/-/issues"
|
|
14
14
|
},
|
|
15
15
|
"type": "module",
|
|
16
16
|
"main": "./dist/index.js",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
|
-
"dist"
|
|
29
|
+
"dist",
|
|
30
|
+
"LICENSE"
|
|
30
31
|
],
|
|
31
32
|
"publishConfig": {
|
|
32
33
|
"access": "public"
|
|
@@ -36,10 +37,10 @@
|
|
|
36
37
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@openstage/glyph-core": "0.
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
40
|
+
"@openstage/glyph-core": "0.4.0-rc.1",
|
|
41
|
+
"@openstage/monadyssey-core": "^3.0.0-rc.1",
|
|
42
|
+
"highlight.js": "^11.12.0",
|
|
43
|
+
"lowlight": "^3.3.0"
|
|
43
44
|
},
|
|
44
45
|
"description": "XSS-safe read-only renderer (DOM/HTML) with lazy syntax highlighting for Glyph documents.",
|
|
45
46
|
"keywords": [
|