@dita-viewer/core 0.2.0 → 0.2.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 -21
- package/README.md +77 -58
- package/dist/index.js +3 -3
- package/dist/profiling.d.ts +2 -2
- package/dist/profiling.js +3 -3
- package/dist/render/mapTypeMap.js +23 -23
- package/package.json +53 -53
- package/styles/TOKENS.md +38 -38
- package/styles/dita-content.css +1157 -1157
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 aREversez
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 aREversez
|
|
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,58 +1,77 @@
|
|
|
1
|
-
# @dita-viewer/core
|
|
2
|
-
|
|
3
|
-
Host-neutral DITA parsing and HTML rendering
|
|
4
|
-
[VS Code DITA Viewer](https://github.com/aREversez/VS-Code-DITA-Viewer)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
| `src/
|
|
14
|
-
| `src/
|
|
15
|
-
| `src/index.ts` | New here. The public API
|
|
16
|
-
| `src/
|
|
17
|
-
| `
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
npm
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
# @dita-viewer/core
|
|
2
|
+
|
|
3
|
+
Host-neutral DITA parsing and HTML rendering. It lives in the
|
|
4
|
+
[VS Code DITA Viewer](https://github.com/aREversez/VS-Code-DITA-Viewer)
|
|
5
|
+
repository, under `packages/core`, and is shared with
|
|
6
|
+
[obsidian-dita](https://github.com/aREversez/obsidian-dita), which installs it
|
|
7
|
+
from npm.
|
|
8
|
+
|
|
9
|
+
## What is in it
|
|
10
|
+
|
|
11
|
+
| Path | Origin |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| `src/parser/`, `src/render/`, `src/editor/*.ts` | The extension's own parser, renderer and editor files. They were first copied from its `dev` at commit `596202d` into this package, and the extension deleted its copies when it switched to depend on it. Except `editor/topicRender.ts`, which is from the upstream change "move openHrefTarget out of topicRender" (it was identical before that, and the other files were checked identical to `dev` at `de5a237`). The 15 files in `parser/`, `render/` and `editor/` are exactly the transitive import closure of `renderTopicToHtml` and import nothing from `vscode`. |
|
|
14
|
+
| `src/language/ditaLanguageUtils.ts`, `src/language/referenceableFiles.ts` | The extension's files too (same commit): completion-context detection, tag-stack scanning, and the file walk behind `href` completion. Both are `vscode`-free. |
|
|
15
|
+
| `src/keyMapForDocument.ts`, `src/mapRender.ts`, `src/bookRender.ts`, `src/siteRender.ts`, `src/index.ts` | New here. The public API; the key-map lookup without the VS Code workspace features; `renderMapXml`, which sequences the copied map parser and renderer for a `.ditamap` outline; `renderBookXml` for the whole map on one page; and `renderSiteXml`, which renders one map topic at a time plus the sidebar manifest. |
|
|
16
|
+
| `src/profiling.ts` | New here. Conditional processing: read a `.ditaval`, read the profiling values of an element or of the renderer's `data-profile-keys`, decide whether an element stays (DITA-OT rules), list the values for a filter panel, and prune filtered entries from a parsed map. `renderBookXml` and `renderSiteXml` take it as `filter`. Informed by the VS Code viewer's `src/editor/ditaval.ts`, which only answers the exclusion question and is not a drop-in. |
|
|
17
|
+
| `src/index.ts` | New here. The public API. Besides the high-level `render*` functions it exports the parser and renderer entry points (`parseDita`, `parseDitamap`, `renderDocument`, ...) and the types they use, which is everything the VS Code viewer imports from the modules it copied; `test/publicApi.test.ts` pins that list. |
|
|
18
|
+
| `src/completion.ts`, `src/completionData.ts` | New here. Host-neutral completion engine (`complete(text, offset, env)`) and its tables: usual children per element (a ranking aid only, never a filter), enumerated attribute values, which attributes name files. |
|
|
19
|
+
| `styles/dita-content.css` | The topic-content, `.ditamap` outline-tree, and map page/site rules of the VS Code `media/styles.css`, with every `--vscode-*` replaced by a `--dita-*` host token. See the header comment for the complete list of differences. |
|
|
20
|
+
| `styles/TOKENS.md` | The contract between the stylesheet and a host. |
|
|
21
|
+
| `test/` | The upstream tests whose imports stay inside the 15 files (plus tests for completion, map rendering, book and site rendering), unchanged except for import paths. |
|
|
22
|
+
|
|
23
|
+
## Changing the shared files
|
|
24
|
+
|
|
25
|
+
This package is edited here. The extension imports it through the npm
|
|
26
|
+
workspace (`"@dita-viewer/core": "*"` links `packages/core`), so a change is in
|
|
27
|
+
the extension's next build with no release in between. obsidian-dita installs
|
|
28
|
+
a published version, so a change reaches it only after a release (see below).
|
|
29
|
+
The extension depends on the core as `*` on purpose: an exact version stops
|
|
30
|
+
matching the workspace after the first bump, and npm would then install the
|
|
31
|
+
published copy next to it.
|
|
32
|
+
|
|
33
|
+
The root scripts compile this package before anything that imports it
|
|
34
|
+
(`typecheck`, `build`, `test`, `test:visual`, `test:e2e`, `watch`), because the
|
|
35
|
+
extension reads its `dist/`. `npm run verify` also runs this package's own
|
|
36
|
+
tests. `npm run watch` compiles it once, at the start; after editing it while
|
|
37
|
+
watching, run `npm run build:core`.
|
|
38
|
+
|
|
39
|
+
What is not shared yet is the stylesheet. The extension's `media/styles.css`
|
|
40
|
+
reads these `--dita-*` tokens in its content and outline rules, answered from
|
|
41
|
+
VS Code's theme in one `:root` block, with rendering unchanged, but it is not
|
|
42
|
+
yet interchangeable with `styles/dita-content.css`. The open differences
|
|
43
|
+
(selectors, three colour families this package folds into one token, two
|
|
44
|
+
tokens nothing in the extension reads yet) are listed in obsidian-dita's
|
|
45
|
+
`ROADMAP.md`.
|
|
46
|
+
|
|
47
|
+
## Publishing to npm
|
|
48
|
+
|
|
49
|
+
Releases are made by `.github/workflows/release-core.yml`, which publishes with
|
|
50
|
+
npm's OIDC trusted publishing: no npm token is stored anywhere.
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
# raise "version" in packages/core/package.json, commit, then:
|
|
54
|
+
git tag core-0.2.1 # the tag must be core-<the version in package.json>
|
|
55
|
+
git push --follow-tags
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
One-time setup, on npmjs.com: open the package `@dita-viewer/core`, then
|
|
59
|
+
Settings, Trusted Publisher, GitHub Actions, and enter owner `aREversez`,
|
|
60
|
+
repository `VS-Code-DITA-Viewer`, workflow filename `release-core.yml`. It
|
|
61
|
+
must match exactly, and the `repository` field of `package.json` must name the
|
|
62
|
+
same repository, or npm refuses the provenance.
|
|
63
|
+
|
|
64
|
+
To publish by hand instead:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
npm login # two-factor authentication is required
|
|
68
|
+
npm run verify
|
|
69
|
+
npm run check:core-pack # packs, installs the tarball into an empty project, requires it, type-checks it
|
|
70
|
+
cd packages/core
|
|
71
|
+
npm publish # publishConfig makes it public; prepublishOnly builds first
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
A published version can never be reused, so run `check:core-pack` before every
|
|
75
|
+
release. Until the host-token and selector gaps are closed, keep the version at
|
|
76
|
+
`0.x`: the exported surface is allowed to change. obsidian-dita pins the exact
|
|
77
|
+
version it was built against.
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Public surface of @dita-viewer/core.
|
|
3
3
|
//
|
|
4
4
|
// Hosts (the Obsidian plugin, and in time the VS Code extension) render DITA
|
|
5
|
-
// through these exports only.
|
|
6
|
-
//
|
|
7
|
-
//
|
|
5
|
+
// through these exports only. The VS Code DITA Viewer depends on this package
|
|
6
|
+
// and holds no copies of ./parser, ./render and ./editor (see README), so they
|
|
7
|
+
// are edited here and released as a new version.
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.renderMapDocument = exports.isDitamapRef = exports.getDisplayNameInfo = exports.extractText = exports.createBookRoleLabeler = exports.findTopLevelIndextermsInSubtree = exports.collectIndextermChips = exports.renderElement = exports.renderDocument = exports.MAP_STANDARD_TAG_TO_BASETYPE = exports.STANDARD_TAG_TO_BASETYPE = exports.preprocessEntities = exports.parseDitamap = exports.parseDita = exports.getMapTitleText = exports.collectMapEntries = exports.pruneExcluded = exports.profileValuesOfKeys = exports.profileValuesOf = exports.profileKey = exports.profileGroups = exports.parseDitaval = exports.isValueExcluded = exports.isExcluded = exports.isEmptyFilter = exports.ditavalAction = exports.PROFILE_ATTRS = exports.renderSiteXml = exports.renderBookXml = exports.renderMapXml = exports.offsetToLineCol = exports.collectRefEntries = exports.splitRefFragment = exports.collectIds = exports.IMAGE_EXT = exports.toRelativeHref = exports.collectReferenceableFiles = exports.collectDiagnostics = exports.complete = exports.buildKeySpaceForDocument = exports.buildKeyMapForDocument = exports.decodeHrefPart = exports.clearSourceOverlay = exports.setSourceOverlay = exports.readSourceText = exports.getKeyDefs = exports.buildKeySpace = exports.collectDitamapFilesUpward = exports.buildTitleMap = exports.renderTopicXml = void 0;
|
|
10
10
|
exports.findIdAttrAt = exports.findEnclosingKeydefKeys = exports.findConrefTargetOffset = exports.collectUnknownElements = exports.collectTopicSymbols = exports.collectMapSymbols = exports.topicRenderCacheSize = exports.topicRenderCacheBytesHeld = exports.stampFiles = exports.setTopicRenderCacheBudgetForTesting = exports.renderTopicToHtml = exports.renderTopicCached = exports.collectText = exports.clearTopicRenderCache = exports.TOPIC_RENDER_CACHE_MAX_BYTES = exports.trackSourceReads = exports.sourceStamp = exports.sourceOverlaySize = exports.noteSourceDependencies = exports.dependsOn = exports.clearAllSourceOverlays = exports.buildRenderContext = exports.readImageDimensions = exports.makeIsInCurrentBook = exports.makeFileTitleResolver = exports.makeFileCache = exports.makeConrefResolver = exports.makeConrefRangeResolver = exports.expandDitamapRefs = exports.detectNoteLabels = exports.detectIndexLabel = exports.clearImageDimensionsCache = exports.ZH_NOTE_LABELS = exports.URL_SCHEME_RE = exports.IMAGE_DIMENSIONS_CACHE_MAX = exports.DEFAULT_NOTE_LABELS = exports.qualifiedNamesMulti = exports.qualifiedNames = exports.keySourceMaps = exports.isKeyContextAvailable = exports.collectMapKeys = exports.resolveConkeyref = exports.profilingKeysAttr = exports.profilingChipsHtml = exports.mergeProfilingAttrs = exports.needsSpace = exports.computeKeyrefSpacing = exports.BASE_TYPE_RENDERERS = exports.lookupNamedEntity = exports.isExternalRef = void 0;
|
package/dist/profiling.d.ts
CHANGED
|
@@ -20,8 +20,8 @@ export interface ProfileFilter {
|
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* The attributes the renderer records in data-profile-keys, in its order.
|
|
23
|
-
* Kept in step with PROFILING_ATTRS in render/renderer.ts (
|
|
24
|
-
*
|
|
23
|
+
* Kept in step with PROFILING_ATTRS in render/renderer.ts (not exported from
|
|
24
|
+
* there); a test renders each one to catch drift.
|
|
25
25
|
*/
|
|
26
26
|
export declare const PROFILE_ATTRS: readonly ["props", "platform", "product", "audience", "otherprops", "base", "importance", "rev", "status"];
|
|
27
27
|
/** The key a hand-picked value is stored under. */
|
package/dist/profiling.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Conditional processing: which profiled content a .ditaval file, or a hand
|
|
3
3
|
// picked set of values, leaves out of a preview.
|
|
4
4
|
//
|
|
5
|
-
// Host-neutral and DOM-free. The renderer
|
|
5
|
+
// Host-neutral and DOM-free. The renderer
|
|
6
6
|
// already stamps every profiled element with `data-profile-keys`, a list of
|
|
7
7
|
// `attribute:value` pairs, and the stylesheet already hides anything carrying
|
|
8
8
|
// `.profile-filtered-out`. What was missing is the decision: does this
|
|
@@ -39,8 +39,8 @@ exports.pruneExcluded = pruneExcluded;
|
|
|
39
39
|
const sax_1 = __importDefault(require("sax"));
|
|
40
40
|
/**
|
|
41
41
|
* The attributes the renderer records in data-profile-keys, in its order.
|
|
42
|
-
* Kept in step with PROFILING_ATTRS in render/renderer.ts (
|
|
43
|
-
*
|
|
42
|
+
* Kept in step with PROFILING_ATTRS in render/renderer.ts (not exported from
|
|
43
|
+
* there); a test renders each one to catch drift.
|
|
44
44
|
*/
|
|
45
45
|
exports.PROFILE_ATTRS = ['props', 'platform', 'product', 'audience', 'otherprops', 'base', 'importance', 'rev', 'status'];
|
|
46
46
|
/**
|
|
@@ -292,16 +292,16 @@ function renderRef(node, ctx, renderChildren) {
|
|
|
292
292
|
const keyAttr = safeAttr('data-keys', keys);
|
|
293
293
|
const hrefAttr = href ? safeAttr('data-href', href) : '';
|
|
294
294
|
if (nav) {
|
|
295
|
-
return `<li class="map-tree-item map-tree-item--nav${boxClass}" role="treeitem"${keyAttr}${hrefAttr}${profileAttr}>
|
|
296
|
-
<a href="#" class="map-tree-link" data-href="${escapeAttr(href)}">${icon}${badge}<span class="map-tree-label">${nameAttr}</span></a>
|
|
297
|
-
${childrenHtml ? `<ul class="map-tree" role="group">${childrenHtml}</ul>` : ''}
|
|
298
|
-
${profileLabel}
|
|
295
|
+
return `<li class="map-tree-item map-tree-item--nav${boxClass}" role="treeitem"${keyAttr}${hrefAttr}${profileAttr}>
|
|
296
|
+
<a href="#" class="map-tree-link" data-href="${escapeAttr(href)}">${icon}${badge}<span class="map-tree-label">${nameAttr}</span></a>
|
|
297
|
+
${childrenHtml ? `<ul class="map-tree" role="group">${childrenHtml}</ul>` : ''}
|
|
298
|
+
${profileLabel}
|
|
299
299
|
</li>`;
|
|
300
300
|
}
|
|
301
|
-
return `<li class="map-tree-item map-tree-item--keydef${boxClass}" role="treeitem"${keyAttr}${hrefAttr}${profileAttr}>
|
|
302
|
-
${icon}${badge}<span class="map-tree-label map-tree-label--keydef">${nameAttr}</span>
|
|
303
|
-
${childrenHtml ? `<ul class="map-tree" role="group">${childrenHtml}</ul>` : ''}
|
|
304
|
-
${profileLabel}
|
|
301
|
+
return `<li class="map-tree-item map-tree-item--keydef${boxClass}" role="treeitem"${keyAttr}${hrefAttr}${profileAttr}>
|
|
302
|
+
${icon}${badge}<span class="map-tree-label map-tree-label--keydef">${nameAttr}</span>
|
|
303
|
+
${childrenHtml ? `<ul class="map-tree" role="group">${childrenHtml}</ul>` : ''}
|
|
304
|
+
${profileLabel}
|
|
305
305
|
</li>`;
|
|
306
306
|
}
|
|
307
307
|
/**
|
|
@@ -337,9 +337,9 @@ const MAP_BASE_TYPE_RENDERERS = {
|
|
|
337
337
|
.filter((c) => c.type === 'element')
|
|
338
338
|
.map((c) => renderChildren(c, bodyCtx))
|
|
339
339
|
.join('');
|
|
340
|
-
return `<div class="ditamap-container">
|
|
341
|
-
${titleHtml}
|
|
342
|
-
<ul class="map-tree" role="tree" aria-label="${escapeAttr(ctx.treeLabel || 'Document outline')}">${bodyHtml}</ul>
|
|
340
|
+
return `<div class="ditamap-container">
|
|
341
|
+
${titleHtml}
|
|
342
|
+
<ul class="map-tree" role="tree" aria-label="${escapeAttr(ctx.treeLabel || 'Document outline')}">${bodyHtml}</ul>
|
|
343
343
|
</div>`;
|
|
344
344
|
},
|
|
345
345
|
'map/map-title': (node, ctx, _renderChildren) => `<h1 class="map-title">${escapeAttr(extractText(node, ctx.resolveKey))}</h1>`,
|
|
@@ -352,10 +352,10 @@ const MAP_BASE_TYPE_RENDERERS = {
|
|
|
352
352
|
const profileKeys = (0, renderer_1.profilingKeysAttr)(effectiveProfiling);
|
|
353
353
|
const profileAttr = profileKeys ? safeAttr('data-profile-keys', profileKeys) : '';
|
|
354
354
|
const { boxClass, label: profileLabel } = ownProfilingMarkup(node);
|
|
355
|
-
return `<li class="map-tree-item map-tree-item--head${boxClass}" role="treeitem"${profileAttr}>
|
|
356
|
-
<span class="map-tree-label map-tree-label--head">${escapeAttr(displayName)}</span>
|
|
357
|
-
${childrenHtml ? `<ul class="map-tree" role="group">${childrenHtml}</ul>` : ''}
|
|
358
|
-
${profileLabel}
|
|
355
|
+
return `<li class="map-tree-item map-tree-item--head${boxClass}" role="treeitem"${profileAttr}>
|
|
356
|
+
<span class="map-tree-label map-tree-label--head">${escapeAttr(displayName)}</span>
|
|
357
|
+
${childrenHtml ? `<ul class="map-tree" role="group">${childrenHtml}</ul>` : ''}
|
|
358
|
+
${profileLabel}
|
|
359
359
|
</li>`;
|
|
360
360
|
},
|
|
361
361
|
'map/topicgroup': (node, ctx, renderChildren) => {
|
|
@@ -368,8 +368,8 @@ const MAP_BASE_TYPE_RENDERERS = {
|
|
|
368
368
|
// grouping), so it isn't a distinct treeitem -- role="group" alone,
|
|
369
369
|
// wrapping its children as if they were direct siblings of whatever
|
|
370
370
|
// contains this topicgroup.
|
|
371
|
-
return `<li class="map-tree-item map-tree-item--group" role="none">
|
|
372
|
-
<ul class="map-tree" role="group">${childrenHtml}</ul>
|
|
371
|
+
return `<li class="map-tree-item map-tree-item--group" role="none">
|
|
372
|
+
<ul class="map-tree" role="group">${childrenHtml}</ul>
|
|
373
373
|
</li>`;
|
|
374
374
|
},
|
|
375
375
|
'map/bookmap-structural': (node, ctx, renderChildren) => {
|
|
@@ -384,18 +384,18 @@ const MAP_BASE_TYPE_RENDERERS = {
|
|
|
384
384
|
const profileKeys = (0, renderer_1.profilingKeysAttr)(effectiveProfiling);
|
|
385
385
|
const profileAttr = profileKeys ? safeAttr('data-profile-keys', profileKeys) : '';
|
|
386
386
|
const { boxClass, label: profileLabel } = ownProfilingMarkup(node);
|
|
387
|
-
return `<li class="map-tree-item map-tree-item--structural${boxClass}" role="treeitem"${profileAttr}>
|
|
388
|
-
<span class="map-tree-label map-tree-label--structural">${escapeAttr(displayName)}</span>
|
|
389
|
-
${childrenHtml ? `<ul class="map-tree" role="group">${childrenHtml}</ul>` : ''}
|
|
390
|
-
${profileLabel}
|
|
387
|
+
return `<li class="map-tree-item map-tree-item--structural${boxClass}" role="treeitem"${profileAttr}>
|
|
388
|
+
<span class="map-tree-label map-tree-label--structural">${escapeAttr(displayName)}</span>
|
|
389
|
+
${childrenHtml ? `<ul class="map-tree" role="group">${childrenHtml}</ul>` : ''}
|
|
390
|
+
${profileLabel}
|
|
391
391
|
</li>`;
|
|
392
392
|
},
|
|
393
393
|
'map/keydef': renderRef,
|
|
394
394
|
'map/reltable': (node, ctx, renderChildren) => {
|
|
395
395
|
const relbody = node.children.filter((c) => c.type === 'element' && (c.baseType === 'map/relheader' || c.baseType === 'map/relrow'));
|
|
396
396
|
const bodyHtml = relbody.map((c) => renderChildren(c, ctx)).join('');
|
|
397
|
-
return `<div class="map-reltable"><h2 class="map-reltable-title">Related Information</h2>
|
|
398
|
-
<table class="map-reltable-table"><tbody>${bodyHtml}</tbody></table>
|
|
397
|
+
return `<div class="map-reltable"><h2 class="map-reltable-title">Related Information</h2>
|
|
398
|
+
<table class="map-reltable-table"><tbody>${bodyHtml}</tbody></table>
|
|
399
399
|
</div>`;
|
|
400
400
|
},
|
|
401
401
|
'map/relheader': (node, ctx) => {
|
package/package.json
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dita-viewer/core",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Host-neutral DITA parsing and HTML rendering core, shared by the VS Code DITA Viewer and obsidian-dita.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"dita",
|
|
7
|
-
"dita-ot",
|
|
8
|
-
"xml",
|
|
9
|
-
"documentation",
|
|
10
|
-
"renderer",
|
|
11
|
-
"obsidian",
|
|
12
|
-
"vscode"
|
|
13
|
-
],
|
|
14
|
-
"homepage": "https://github.com/aREversez/
|
|
15
|
-
"bugs": {
|
|
16
|
-
"url": "https://github.com/aREversez/
|
|
17
|
-
},
|
|
18
|
-
"repository": {
|
|
19
|
-
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/aREversez/
|
|
21
|
-
"directory": "packages/
|
|
22
|
-
},
|
|
23
|
-
"license": "MIT",
|
|
24
|
-
"author": "aREversez",
|
|
25
|
-
"main": "./dist/index.js",
|
|
26
|
-
"types": "./dist/index.d.ts",
|
|
27
|
-
"exports": {
|
|
28
|
-
".": {
|
|
29
|
-
"types": "./dist/index.d.ts",
|
|
30
|
-
"default": "./dist/index.js"
|
|
31
|
-
},
|
|
32
|
-
"./styles/dita-content.css": "./styles/dita-content.css",
|
|
33
|
-
"./styles/TOKENS.md": "./styles/TOKENS.md"
|
|
34
|
-
},
|
|
35
|
-
"files": [
|
|
36
|
-
"dist",
|
|
37
|
-
"styles",
|
|
38
|
-
"!dist/**/*.map"
|
|
39
|
-
],
|
|
40
|
-
"scripts": {
|
|
41
|
-
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
42
|
-
"build": "tsc -p tsconfig.build.json",
|
|
43
|
-
"pretest": "node -e \"require('fs').rmSync('dist-test',{recursive:true,force:true})\" && tsc -p tsconfig.test.json",
|
|
44
|
-
"test": "mocha --config .mocharc.json",
|
|
45
|
-
"prepublishOnly": "npm run build"
|
|
46
|
-
},
|
|
47
|
-
"dependencies": {
|
|
48
|
-
"sax": "^1.4.1"
|
|
49
|
-
},
|
|
50
|
-
"publishConfig": {
|
|
51
|
-
"access": "public"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@dita-viewer/core",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Host-neutral DITA parsing and HTML rendering core, shared by the VS Code DITA Viewer and obsidian-dita.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dita",
|
|
7
|
+
"dita-ot",
|
|
8
|
+
"xml",
|
|
9
|
+
"documentation",
|
|
10
|
+
"renderer",
|
|
11
|
+
"obsidian",
|
|
12
|
+
"vscode"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/aREversez/VS-Code-DITA-Viewer/tree/main/packages/core#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/aREversez/VS-Code-DITA-Viewer/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/aREversez/VS-Code-DITA-Viewer.git",
|
|
21
|
+
"directory": "packages/core"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"author": "aREversez",
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./styles/dita-content.css": "./styles/dita-content.css",
|
|
33
|
+
"./styles/TOKENS.md": "./styles/TOKENS.md"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"styles",
|
|
38
|
+
"!dist/**/*.map"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
42
|
+
"build": "tsc -p tsconfig.build.json",
|
|
43
|
+
"pretest": "node -e \"require('fs').rmSync('dist-test',{recursive:true,force:true})\" && tsc -p tsconfig.test.json",
|
|
44
|
+
"test": "mocha --config .mocharc.json",
|
|
45
|
+
"prepublishOnly": "npm run build"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"sax": "^1.4.1"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
}
|
|
53
|
+
}
|
package/styles/TOKENS.md
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
# Host tokens
|
|
2
|
-
|
|
3
|
-
`dita-content.css` does not know which application shows the rendered DITA. It
|
|
4
|
-
reads the custom properties below; the host defines them on the element that
|
|
5
|
-
carries the content (`:host` for a Shadow DOM, `:root` for a document).
|
|
6
|
-
|
|
7
|
-
| Token | Meaning |
|
|
8
|
-
| --- | --- |
|
|
9
|
-
| `--dita-fg` | Body text colour |
|
|
10
|
-
| `--dita-fg-muted` | Secondary text (shortdesc, captions, hints) |
|
|
11
|
-
| `--dita-bg` | Page background |
|
|
12
|
-
| `--dita-bg-elevated` | Background of floating chrome (menus, toasts) |
|
|
13
|
-
| `--dita-border` | Rules, table borders, dividers |
|
|
14
|
-
| `--dita-focus` | Focus ring and progress accent |
|
|
15
|
-
| `--dita-hover-bg` | Hover / highlighted row background |
|
|
16
|
-
| `--dita-selected-fg` | Text on a selected row |
|
|
17
|
-
| `--dita-link` | Link colour |
|
|
18
|
-
| `--dita-code-bg` | Code block background |
|
|
19
|
-
| `--dita-code-inline-bg` | Inline code and language-label background |
|
|
20
|
-
| `--dita-font` | Body font family |
|
|
21
|
-
|
|
22
|
-
Every use inside the stylesheet carries a fallback, so a host that defines only
|
|
23
|
-
some tokens still renders legibly.
|
|
24
|
-
|
|
25
|
-
## The palette
|
|
26
|
-
|
|
27
|
-
Callouts, profiling highlights, index chips and conref tints use `--color-*`
|
|
28
|
-
variables (`--color-note-bg`, `--color-warning-border`, `--color-profiling-bg`,
|
|
29
|
-
…). The stylesheet ships light and dark defaults for them. A host may redefine
|
|
30
|
-
any of them; deriving them from its own palette (for example with `color-mix`
|
|
31
|
-
against `--dita-bg`) is what makes them follow the active theme, in both light
|
|
32
|
-
and dark, without a per-theme list.
|
|
33
|
-
|
|
34
|
-
## Dark mode
|
|
35
|
-
|
|
36
|
-
Hosts that cannot express a colour as a function of their own variables may use
|
|
37
|
-
the scheme switch: `.vscode-dark` on the document root, or
|
|
38
|
-
`data-scheme="dark"` on a Shadow DOM host.
|
|
1
|
+
# Host tokens
|
|
2
|
+
|
|
3
|
+
`dita-content.css` does not know which application shows the rendered DITA. It
|
|
4
|
+
reads the custom properties below; the host defines them on the element that
|
|
5
|
+
carries the content (`:host` for a Shadow DOM, `:root` for a document).
|
|
6
|
+
|
|
7
|
+
| Token | Meaning |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| `--dita-fg` | Body text colour |
|
|
10
|
+
| `--dita-fg-muted` | Secondary text (shortdesc, captions, hints) |
|
|
11
|
+
| `--dita-bg` | Page background |
|
|
12
|
+
| `--dita-bg-elevated` | Background of floating chrome (menus, toasts) |
|
|
13
|
+
| `--dita-border` | Rules, table borders, dividers |
|
|
14
|
+
| `--dita-focus` | Focus ring and progress accent |
|
|
15
|
+
| `--dita-hover-bg` | Hover / highlighted row background |
|
|
16
|
+
| `--dita-selected-fg` | Text on a selected row |
|
|
17
|
+
| `--dita-link` | Link colour |
|
|
18
|
+
| `--dita-code-bg` | Code block background |
|
|
19
|
+
| `--dita-code-inline-bg` | Inline code and language-label background |
|
|
20
|
+
| `--dita-font` | Body font family |
|
|
21
|
+
|
|
22
|
+
Every use inside the stylesheet carries a fallback, so a host that defines only
|
|
23
|
+
some tokens still renders legibly.
|
|
24
|
+
|
|
25
|
+
## The palette
|
|
26
|
+
|
|
27
|
+
Callouts, profiling highlights, index chips and conref tints use `--color-*`
|
|
28
|
+
variables (`--color-note-bg`, `--color-warning-border`, `--color-profiling-bg`,
|
|
29
|
+
…). The stylesheet ships light and dark defaults for them. A host may redefine
|
|
30
|
+
any of them; deriving them from its own palette (for example with `color-mix`
|
|
31
|
+
against `--dita-bg`) is what makes them follow the active theme, in both light
|
|
32
|
+
and dark, without a per-theme list.
|
|
33
|
+
|
|
34
|
+
## Dark mode
|
|
35
|
+
|
|
36
|
+
Hosts that cannot express a colour as a function of their own variables may use
|
|
37
|
+
the scheme switch: `.vscode-dark` on the document root, or
|
|
38
|
+
`data-scheme="dark"` on a Shadow DOM host.
|