@dita-viewer/core 0.1.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 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,55 +1,77 @@
1
- # @dita-viewer/core
2
-
3
- Host-neutral DITA parsing and HTML rendering, shared by the
4
- [VS Code DITA Viewer](https://github.com/aREversez/VS-Code-DITA-Viewer) and
5
- [obsidian-dita](https://github.com/aREversez/obsidian-dita).
6
-
7
- ## What is in it
8
-
9
- | Path | Origin |
10
- | --- | --- |
11
- | `src/parser/`, `src/render/`, `src/editor/*.ts` | **Verbatim copies** of the same paths in the VS Code DITA Viewer, taken from `dev` at commit `596202d`, 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`. |
12
- | `src/language/ditaLanguageUtils.ts`, `src/language/referenceableFiles.ts` | **Verbatim copies** too (same commit): completion-context detection, tag-stack scanning, and the file walk behind `href` completion. Both are `vscode`-free. |
13
- | `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. |
14
- | `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. |
15
- | `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. |
16
- | `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. |
17
- | `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. |
18
- | `styles/TOKENS.md` | The contract between the stylesheet and a host. |
19
- | `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. |
20
-
21
- ## Keeping it in sync
22
-
23
- Do not edit the verbatim files here. Change them upstream, then copy them over
24
- and run `npm test`. Because they are byte-identical, `diff -r` against the
25
- upstream tree shows exactly what is out of date.
26
-
27
- The intended end state is that the VS Code extension depends on this package
28
- instead of holding its own copies. Two small upstream changes make that
29
- possible. The first is done: `openHrefTarget` now lives in the extension's own
30
- `editor/openHrefTarget.ts`, so `topicRender.ts` mentions no host and the
31
- `vscode` type stand-in is gone. The second is done in part: the extension's
32
- `media/styles.css` reads these `--dita-*` tokens in its content and outline
33
- rules, answered from VS Code's theme in one `:root` block, with rendering
34
- unchanged. It is not yet interchangeable with `styles/dita-content.css`; the
35
- open differences (selectors, three colour families this package folds into one
36
- token, two tokens nothing upstream reads yet) are listed in `ROADMAP.md`.
37
-
38
- ## Publishing to npm
39
-
40
- The `@dita-viewer` scope must belong to the publisher: create an npm
41
- organisation called `dita-viewer` (free for public packages), or rename the
42
- package under a user scope in both repositories.
43
-
44
- ```
45
- npm login # two-factor authentication is required
46
- npm run verify
47
- npm run check:pack # packs, installs the tarball into an empty project, requires it, type-checks it
48
- cd packages/dita-core
49
- npm version patch # or minor; keep it in step with what changed
50
- npm publish # publishConfig makes it public; prepublishOnly builds first
51
- ```
52
-
53
- A published version can never be reused, so run `check:pack` every time. Until
54
- the host-token and selector gaps in `ROADMAP.md` are closed, keep the version at
55
- `0.x`: the exported surface is allowed to change.
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.d.ts CHANGED
@@ -36,6 +36,19 @@ export { isExternalRef } from './language/ditaLanguageUtils';
36
36
  export type { MapEntry } from './render/mapTypeMap';
37
37
  export type { RoleLabelFormatter, RoleLabelInfo } from './render/mapTypeMap';
38
38
  export type { KeyMapOptions } from './keyMapForDocument';
39
+ export { lookupNamedEntity } from './parser/namedEntities';
40
+ export { BASE_TYPE_RENDERERS } from './render/baseTypeMap';
41
+ export { computeKeyrefSpacing, needsSpace } from './render/cjkSpacing';
42
+ export { mergeProfilingAttrs, profilingChipsHtml, profilingKeysAttr } from './render/renderer';
43
+ export { resolveConkeyref } from './editor/conkeyref';
44
+ export { collectMapKeys, isKeyContextAvailable, keySourceMaps, qualifiedNames, qualifiedNamesMulti } from './editor/keySpace';
45
+ export { DEFAULT_NOTE_LABELS, IMAGE_DIMENSIONS_CACHE_MAX, URL_SCHEME_RE, ZH_NOTE_LABELS, clearImageDimensionsCache, detectIndexLabel, detectNoteLabels, expandDitamapRefs, makeConrefRangeResolver, makeConrefResolver, makeFileCache, makeFileTitleResolver, makeIsInCurrentBook, readImageDimensions } from './editor/refResolvers';
46
+ export type { FileReader } from './editor/refResolvers';
47
+ export { buildRenderContext } from './editor/renderContext';
48
+ export { clearAllSourceOverlays, dependsOn, noteSourceDependencies, sourceOverlaySize, sourceStamp, trackSourceReads } from './editor/sourceText';
49
+ export { TOPIC_RENDER_CACHE_MAX_BYTES, clearTopicRenderCache, collectText, renderTopicCached, renderTopicToHtml, setTopicRenderCacheBudgetForTesting, stampFiles, topicRenderCacheBytesHeld, topicRenderCacheSize } from './editor/topicRender';
50
+ export { collectMapSymbols, collectTopicSymbols, collectUnknownElements, findConrefTargetOffset, findEnclosingKeydefKeys, findIdAttrAt, findKeyDefinitionOffset, findKeysAttrAt, findRefAttrAt, findUnclosedTag, getAttributesForTag, getAutoCloseTag, getCloseTagCompletion, getCompletionContext, getMapRefName, stripSameDocumentFragmentPrefix } from './language/ditaLanguageUtils';
51
+ export type { DocSymbolSpec } from './language/ditaLanguageUtils';
39
52
  /**
40
53
  * Host tokens the stylesheet reads (styles/dita-content.css). A host defines
41
54
  * these on the element that carries the rendered content; styles/TOKENS.md
package/dist/index.js CHANGED
@@ -2,12 +2,13 @@
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. Everything under ./parser, ./render and ./editor
6
- // is a verbatim copy of the VS Code DITA Viewer sources (see README), so a
7
- // change there should be made upstream and re-synced, not edited here.
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
- exports.HOST_TOKENS = exports.isExternalRef = void 0;
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;
11
+ exports.HOST_TOKENS = exports.stripSameDocumentFragmentPrefix = exports.getMapRefName = exports.getCompletionContext = exports.getCloseTagCompletion = exports.getAutoCloseTag = exports.getAttributesForTag = exports.findUnclosedTag = exports.findRefAttrAt = exports.findKeysAttrAt = exports.findKeyDefinitionOffset = void 0;
11
12
  var topicRender_1 = require("./editor/topicRender");
12
13
  Object.defineProperty(exports, "renderTopicXml", { enumerable: true, get: function () { return topicRender_1.renderTopicXml; } });
13
14
  Object.defineProperty(exports, "buildTitleMap", { enumerable: true, get: function () { return topicRender_1.buildTitleMap; } });
@@ -85,6 +86,80 @@ Object.defineProperty(exports, "isDitamapRef", { enumerable: true, get: function
85
86
  Object.defineProperty(exports, "renderMapDocument", { enumerable: true, get: function () { return mapTypeMap_2.renderMapDocument; } });
86
87
  var ditaLanguageUtils_3 = require("./language/ditaLanguageUtils");
87
88
  Object.defineProperty(exports, "isExternalRef", { enumerable: true, get: function () { return ditaLanguageUtils_3.isExternalRef; } });
89
+ // The rest of what the VS Code viewer imports from the copied modules: the
90
+ // render cache, the file and key resolvers, the source overlay, the editor
91
+ // language helpers, and the helpers its tests call. Their shapes follow the
92
+ // viewer's needs and may change while the version is 0.x.
93
+ var namedEntities_1 = require("./parser/namedEntities");
94
+ Object.defineProperty(exports, "lookupNamedEntity", { enumerable: true, get: function () { return namedEntities_1.lookupNamedEntity; } });
95
+ var baseTypeMap_2 = require("./render/baseTypeMap");
96
+ Object.defineProperty(exports, "BASE_TYPE_RENDERERS", { enumerable: true, get: function () { return baseTypeMap_2.BASE_TYPE_RENDERERS; } });
97
+ var cjkSpacing_1 = require("./render/cjkSpacing");
98
+ Object.defineProperty(exports, "computeKeyrefSpacing", { enumerable: true, get: function () { return cjkSpacing_1.computeKeyrefSpacing; } });
99
+ Object.defineProperty(exports, "needsSpace", { enumerable: true, get: function () { return cjkSpacing_1.needsSpace; } });
100
+ var renderer_2 = require("./render/renderer");
101
+ Object.defineProperty(exports, "mergeProfilingAttrs", { enumerable: true, get: function () { return renderer_2.mergeProfilingAttrs; } });
102
+ Object.defineProperty(exports, "profilingChipsHtml", { enumerable: true, get: function () { return renderer_2.profilingChipsHtml; } });
103
+ Object.defineProperty(exports, "profilingKeysAttr", { enumerable: true, get: function () { return renderer_2.profilingKeysAttr; } });
104
+ var conkeyref_1 = require("./editor/conkeyref");
105
+ Object.defineProperty(exports, "resolveConkeyref", { enumerable: true, get: function () { return conkeyref_1.resolveConkeyref; } });
106
+ var keySpace_2 = require("./editor/keySpace");
107
+ Object.defineProperty(exports, "collectMapKeys", { enumerable: true, get: function () { return keySpace_2.collectMapKeys; } });
108
+ Object.defineProperty(exports, "isKeyContextAvailable", { enumerable: true, get: function () { return keySpace_2.isKeyContextAvailable; } });
109
+ Object.defineProperty(exports, "keySourceMaps", { enumerable: true, get: function () { return keySpace_2.keySourceMaps; } });
110
+ Object.defineProperty(exports, "qualifiedNames", { enumerable: true, get: function () { return keySpace_2.qualifiedNames; } });
111
+ Object.defineProperty(exports, "qualifiedNamesMulti", { enumerable: true, get: function () { return keySpace_2.qualifiedNamesMulti; } });
112
+ var refResolvers_2 = require("./editor/refResolvers");
113
+ Object.defineProperty(exports, "DEFAULT_NOTE_LABELS", { enumerable: true, get: function () { return refResolvers_2.DEFAULT_NOTE_LABELS; } });
114
+ Object.defineProperty(exports, "IMAGE_DIMENSIONS_CACHE_MAX", { enumerable: true, get: function () { return refResolvers_2.IMAGE_DIMENSIONS_CACHE_MAX; } });
115
+ Object.defineProperty(exports, "URL_SCHEME_RE", { enumerable: true, get: function () { return refResolvers_2.URL_SCHEME_RE; } });
116
+ Object.defineProperty(exports, "ZH_NOTE_LABELS", { enumerable: true, get: function () { return refResolvers_2.ZH_NOTE_LABELS; } });
117
+ Object.defineProperty(exports, "clearImageDimensionsCache", { enumerable: true, get: function () { return refResolvers_2.clearImageDimensionsCache; } });
118
+ Object.defineProperty(exports, "detectIndexLabel", { enumerable: true, get: function () { return refResolvers_2.detectIndexLabel; } });
119
+ Object.defineProperty(exports, "detectNoteLabels", { enumerable: true, get: function () { return refResolvers_2.detectNoteLabels; } });
120
+ Object.defineProperty(exports, "expandDitamapRefs", { enumerable: true, get: function () { return refResolvers_2.expandDitamapRefs; } });
121
+ Object.defineProperty(exports, "makeConrefRangeResolver", { enumerable: true, get: function () { return refResolvers_2.makeConrefRangeResolver; } });
122
+ Object.defineProperty(exports, "makeConrefResolver", { enumerable: true, get: function () { return refResolvers_2.makeConrefResolver; } });
123
+ Object.defineProperty(exports, "makeFileCache", { enumerable: true, get: function () { return refResolvers_2.makeFileCache; } });
124
+ Object.defineProperty(exports, "makeFileTitleResolver", { enumerable: true, get: function () { return refResolvers_2.makeFileTitleResolver; } });
125
+ Object.defineProperty(exports, "makeIsInCurrentBook", { enumerable: true, get: function () { return refResolvers_2.makeIsInCurrentBook; } });
126
+ Object.defineProperty(exports, "readImageDimensions", { enumerable: true, get: function () { return refResolvers_2.readImageDimensions; } });
127
+ var renderContext_1 = require("./editor/renderContext");
128
+ Object.defineProperty(exports, "buildRenderContext", { enumerable: true, get: function () { return renderContext_1.buildRenderContext; } });
129
+ var sourceText_2 = require("./editor/sourceText");
130
+ Object.defineProperty(exports, "clearAllSourceOverlays", { enumerable: true, get: function () { return sourceText_2.clearAllSourceOverlays; } });
131
+ Object.defineProperty(exports, "dependsOn", { enumerable: true, get: function () { return sourceText_2.dependsOn; } });
132
+ Object.defineProperty(exports, "noteSourceDependencies", { enumerable: true, get: function () { return sourceText_2.noteSourceDependencies; } });
133
+ Object.defineProperty(exports, "sourceOverlaySize", { enumerable: true, get: function () { return sourceText_2.sourceOverlaySize; } });
134
+ Object.defineProperty(exports, "sourceStamp", { enumerable: true, get: function () { return sourceText_2.sourceStamp; } });
135
+ Object.defineProperty(exports, "trackSourceReads", { enumerable: true, get: function () { return sourceText_2.trackSourceReads; } });
136
+ var topicRender_2 = require("./editor/topicRender");
137
+ Object.defineProperty(exports, "TOPIC_RENDER_CACHE_MAX_BYTES", { enumerable: true, get: function () { return topicRender_2.TOPIC_RENDER_CACHE_MAX_BYTES; } });
138
+ Object.defineProperty(exports, "clearTopicRenderCache", { enumerable: true, get: function () { return topicRender_2.clearTopicRenderCache; } });
139
+ Object.defineProperty(exports, "collectText", { enumerable: true, get: function () { return topicRender_2.collectText; } });
140
+ Object.defineProperty(exports, "renderTopicCached", { enumerable: true, get: function () { return topicRender_2.renderTopicCached; } });
141
+ Object.defineProperty(exports, "renderTopicToHtml", { enumerable: true, get: function () { return topicRender_2.renderTopicToHtml; } });
142
+ Object.defineProperty(exports, "setTopicRenderCacheBudgetForTesting", { enumerable: true, get: function () { return topicRender_2.setTopicRenderCacheBudgetForTesting; } });
143
+ Object.defineProperty(exports, "stampFiles", { enumerable: true, get: function () { return topicRender_2.stampFiles; } });
144
+ Object.defineProperty(exports, "topicRenderCacheBytesHeld", { enumerable: true, get: function () { return topicRender_2.topicRenderCacheBytesHeld; } });
145
+ Object.defineProperty(exports, "topicRenderCacheSize", { enumerable: true, get: function () { return topicRender_2.topicRenderCacheSize; } });
146
+ var ditaLanguageUtils_4 = require("./language/ditaLanguageUtils");
147
+ Object.defineProperty(exports, "collectMapSymbols", { enumerable: true, get: function () { return ditaLanguageUtils_4.collectMapSymbols; } });
148
+ Object.defineProperty(exports, "collectTopicSymbols", { enumerable: true, get: function () { return ditaLanguageUtils_4.collectTopicSymbols; } });
149
+ Object.defineProperty(exports, "collectUnknownElements", { enumerable: true, get: function () { return ditaLanguageUtils_4.collectUnknownElements; } });
150
+ Object.defineProperty(exports, "findConrefTargetOffset", { enumerable: true, get: function () { return ditaLanguageUtils_4.findConrefTargetOffset; } });
151
+ Object.defineProperty(exports, "findEnclosingKeydefKeys", { enumerable: true, get: function () { return ditaLanguageUtils_4.findEnclosingKeydefKeys; } });
152
+ Object.defineProperty(exports, "findIdAttrAt", { enumerable: true, get: function () { return ditaLanguageUtils_4.findIdAttrAt; } });
153
+ Object.defineProperty(exports, "findKeyDefinitionOffset", { enumerable: true, get: function () { return ditaLanguageUtils_4.findKeyDefinitionOffset; } });
154
+ Object.defineProperty(exports, "findKeysAttrAt", { enumerable: true, get: function () { return ditaLanguageUtils_4.findKeysAttrAt; } });
155
+ Object.defineProperty(exports, "findRefAttrAt", { enumerable: true, get: function () { return ditaLanguageUtils_4.findRefAttrAt; } });
156
+ Object.defineProperty(exports, "findUnclosedTag", { enumerable: true, get: function () { return ditaLanguageUtils_4.findUnclosedTag; } });
157
+ Object.defineProperty(exports, "getAttributesForTag", { enumerable: true, get: function () { return ditaLanguageUtils_4.getAttributesForTag; } });
158
+ Object.defineProperty(exports, "getAutoCloseTag", { enumerable: true, get: function () { return ditaLanguageUtils_4.getAutoCloseTag; } });
159
+ Object.defineProperty(exports, "getCloseTagCompletion", { enumerable: true, get: function () { return ditaLanguageUtils_4.getCloseTagCompletion; } });
160
+ Object.defineProperty(exports, "getCompletionContext", { enumerable: true, get: function () { return ditaLanguageUtils_4.getCompletionContext; } });
161
+ Object.defineProperty(exports, "getMapRefName", { enumerable: true, get: function () { return ditaLanguageUtils_4.getMapRefName; } });
162
+ Object.defineProperty(exports, "stripSameDocumentFragmentPrefix", { enumerable: true, get: function () { return ditaLanguageUtils_4.stripSameDocumentFragmentPrefix; } });
88
163
  /**
89
164
  * Host tokens the stylesheet reads (styles/dita-content.css). A host defines
90
165
  * these on the element that carries the rendered content; styles/TOKENS.md
@@ -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 (a verbatim file we
24
- * cannot export from); a test renders each one to catch drift.
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 (a verbatim copy, see README)
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 (a verbatim file we
43
- * cannot export from); a test renders each one to catch drift.
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.1.0",
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/obsidian-dita/tree/main/packages/dita-core#readme",
15
- "bugs": {
16
- "url": "https://github.com/aREversez/obsidian-dita/issues"
17
- },
18
- "repository": {
19
- "type": "git",
20
- "url": "git+https://github.com/aREversez/obsidian-dita.git",
21
- "directory": "packages/dita-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
- }
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
+ }