@ox-content/napi 2.88.0 → 2.90.0
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/index.d.ts +107 -0
- package/index.js +7 -0
- package/package.json +8 -8
package/index.d.ts
CHANGED
|
@@ -34,6 +34,17 @@ export declare class IncrementalMarkdownRenderer {
|
|
|
34
34
|
get pendingMarkdown(): string
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Splices the caller's highlighting back over the blocks
|
|
39
|
+
* `highlightHtmlCodeBlocks` left pending.
|
|
40
|
+
*
|
|
41
|
+
* `replacements` lines up with the `pending` list it returned: entry `i` is a
|
|
42
|
+
* full `<pre>` element for pending block `i`, or an empty string to leave that
|
|
43
|
+
* block as it is. This keeps a page that needs one exotic grammar off the
|
|
44
|
+
* HTML round trip, instead of surrendering the whole document for it.
|
|
45
|
+
*/
|
|
46
|
+
export declare function applyPendingHighlights(html: string, replacements: Array<string>): string
|
|
47
|
+
|
|
37
48
|
/**
|
|
38
49
|
* Builds a Markdown collection manifest directly from files on the Rust side.
|
|
39
50
|
*
|
|
@@ -178,6 +189,9 @@ export declare function generateSearchModuleFromOptions(options: JsSearchRuntime
|
|
|
178
189
|
/** Generates a bare SSG HTML page without navigation or styles. */
|
|
179
190
|
export declare function generateSsgBareHtml(content: string, title: string): string
|
|
180
191
|
|
|
192
|
+
/** Generates a bare SSG HTML page carrying head metadata and injected markup. */
|
|
193
|
+
export declare function generateSsgBarePage(page: JsSsgBarePage): string
|
|
194
|
+
|
|
181
195
|
/** Generates SSG HTML page with navigation and search. */
|
|
182
196
|
export declare function generateSsgHtml(pageData: JsSsgPageData, navGroups: Array<JsSsgNavGroup>, config: JsSsgConfig): string
|
|
183
197
|
|
|
@@ -199,6 +213,36 @@ export declare function getSsgPageLocale(urlPath: string, defaultLocale: string,
|
|
|
199
213
|
/** Converts a markdown file path to a relative SSG URL path. */
|
|
200
214
|
export declare function getSsgUrlPath(inputPath: string, srcDir: string): string
|
|
201
215
|
|
|
216
|
+
/**
|
|
217
|
+
* Highlights one fenced code block, returning the full `<pre>` element.
|
|
218
|
+
*
|
|
219
|
+
* Returns `null` when no grammar claims `lang`, which is the caller's signal
|
|
220
|
+
* to fall back — either to another highlighter or to emitting the code
|
|
221
|
+
* unhighlighted. Callers that want to decide before paying for the call can
|
|
222
|
+
* ask [`supports_highlight_language`] instead.
|
|
223
|
+
*/
|
|
224
|
+
export declare function highlightCodeBlock(code: string, lang: string): string | null
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Highlights every code block in a rendered document in one call.
|
|
228
|
+
*
|
|
229
|
+
* The alternative is walking the page through an HTML parser and serializer
|
|
230
|
+
* to find the blocks and splice results back, which on the documentation
|
|
231
|
+
* corpus costs an order of magnitude more than the highlighting itself.
|
|
232
|
+
*/
|
|
233
|
+
export declare function highlightHtmlCodeBlocks(html: string): JsHighlightedDocument
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Highlights a document off the main thread, so pages overlap.
|
|
237
|
+
*
|
|
238
|
+
* The synchronous binding holds the event loop for the whole pass, which
|
|
239
|
+
* makes a caller's concurrency worth nothing: `Promise.all` over the
|
|
240
|
+
* documentation corpus measures the same as awaiting the pages one at a
|
|
241
|
+
* time. Running the pass as a task lets a build that already asks for
|
|
242
|
+
* several pages at once actually get them at once.
|
|
243
|
+
*/
|
|
244
|
+
export declare function highlightHtmlCodeBlocksAsync(html: string): Promise<JsHighlightedDocument>
|
|
245
|
+
|
|
202
246
|
/** Result of i18n checking. */
|
|
203
247
|
export interface I18NCheckResult {
|
|
204
248
|
/** All diagnostics. */
|
|
@@ -836,6 +880,24 @@ export interface JsHeroNotice {
|
|
|
836
880
|
body?: Array<string>
|
|
837
881
|
}
|
|
838
882
|
|
|
883
|
+
/** Result of highlighting every code block in a rendered document. */
|
|
884
|
+
export interface JsHighlightedDocument {
|
|
885
|
+
/** The document with each handled block replaced. */
|
|
886
|
+
html: string
|
|
887
|
+
/**
|
|
888
|
+
* Languages of elements the native pass could not read, which means the
|
|
889
|
+
* caller's own highlighter has to produce the whole page. Non-empty
|
|
890
|
+
* leaves `html` untouched and `pending` empty.
|
|
891
|
+
*/
|
|
892
|
+
skipped: Array<string>
|
|
893
|
+
/**
|
|
894
|
+
* Well-formed blocks whose language has no native grammar, in document
|
|
895
|
+
* order. Highlight each one and hand the results to
|
|
896
|
+
* `applyPendingHighlights`; they are still in `html`, unchanged.
|
|
897
|
+
*/
|
|
898
|
+
pending: Array<JsPendingBlock>
|
|
899
|
+
}
|
|
900
|
+
|
|
839
901
|
/** Configuration for generated i18n runtime modules. */
|
|
840
902
|
export interface JsI18NRuntimeConfig {
|
|
841
903
|
/** Default locale tag. */
|
|
@@ -1039,6 +1101,14 @@ export interface JsParserOptions {
|
|
|
1039
1101
|
autolinks?: boolean
|
|
1040
1102
|
}
|
|
1041
1103
|
|
|
1104
|
+
/** A block the native pass left for the caller's highlighter. */
|
|
1105
|
+
export interface JsPendingBlock {
|
|
1106
|
+
/** The `language-…` class the block carries. */
|
|
1107
|
+
language: string
|
|
1108
|
+
/** The block's source text, already unescaped. */
|
|
1109
|
+
source: string
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1042
1112
|
/** Options for [`super::transform_pm_embeds`]. */
|
|
1043
1113
|
export interface JsPmOptions {
|
|
1044
1114
|
/**
|
|
@@ -1250,6 +1320,37 @@ export interface JsSourceOrigin {
|
|
|
1250
1320
|
column: number
|
|
1251
1321
|
}
|
|
1252
1322
|
|
|
1323
|
+
/**
|
|
1324
|
+
* Head metadata and injected markup for a bare SSG page.
|
|
1325
|
+
*
|
|
1326
|
+
* Every field is optional. A value with none of them set renders the same
|
|
1327
|
+
* document bare mode emitted before any of this existed.
|
|
1328
|
+
*/
|
|
1329
|
+
export interface JsSsgBarePage {
|
|
1330
|
+
/** Page title. */
|
|
1331
|
+
title: string
|
|
1332
|
+
/** Rendered page body. */
|
|
1333
|
+
content: string
|
|
1334
|
+
/** `lang` attribute. Defaults to `en`. */
|
|
1335
|
+
lang?: string
|
|
1336
|
+
/** `dir` attribute. Omitted when absent. */
|
|
1337
|
+
dir?: string
|
|
1338
|
+
/** Page description for `description` and the OG/Twitter variants. */
|
|
1339
|
+
description?: string
|
|
1340
|
+
/** Absolute page URL for `<link rel="canonical">` and `og:url`. */
|
|
1341
|
+
canonicalUrl?: string
|
|
1342
|
+
/** Site name for `og:site_name`. */
|
|
1343
|
+
siteName?: string
|
|
1344
|
+
/** Image URL for `og:image` and `twitter:image`. */
|
|
1345
|
+
ogImage?: string
|
|
1346
|
+
/** Raw markup appended to `<head>`. */
|
|
1347
|
+
head?: string
|
|
1348
|
+
/** Raw markup inserted directly after `<body>`. */
|
|
1349
|
+
bodyStart?: string
|
|
1350
|
+
/** Raw markup inserted directly before `</body>`. */
|
|
1351
|
+
bodyEnd?: string
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1253
1354
|
/** SSG configuration. */
|
|
1254
1355
|
export interface JsSsgConfig {
|
|
1255
1356
|
/** Site name. */
|
|
@@ -1785,6 +1886,9 @@ export interface Mf2ValidateResult {
|
|
|
1785
1886
|
astJson?: string
|
|
1786
1887
|
}
|
|
1787
1888
|
|
|
1889
|
+
/** Every language name and alias the native highlighter answers to. */
|
|
1890
|
+
export declare function nativeHighlightLanguages(): Array<string>
|
|
1891
|
+
|
|
1788
1892
|
/** Normalizes VitePress-specific frontmatter into ox-content's entry-page shape. */
|
|
1789
1893
|
export declare function normalizeVitePressFrontmatter(frontmatter: any): any
|
|
1790
1894
|
|
|
@@ -1880,6 +1984,9 @@ export declare function sanitizeHtml(html: string, options?: JsSanitizeOptions |
|
|
|
1880
1984
|
*/
|
|
1881
1985
|
export declare function searchIndex(indexJson: string, query: string, options?: JsSearchOptions | undefined | null): Array<JsSearchResult>
|
|
1882
1986
|
|
|
1987
|
+
/** Whether a fenced code block tagged `lang` will be highlighted natively. */
|
|
1988
|
+
export declare function supportsHighlightLanguage(lang: string): boolean
|
|
1989
|
+
|
|
1883
1990
|
/** Table of contents entry. */
|
|
1884
1991
|
export interface TocEntry {
|
|
1885
1992
|
/** Heading depth (1-6). */
|
package/index.js
CHANGED
|
@@ -209,6 +209,13 @@ module.exports.collectSearchMarkdownFiles = binding.collectSearchMarkdownFiles;
|
|
|
209
209
|
module.exports.normalizeVitePressFrontmatter = binding.normalizeVitePressFrontmatter;
|
|
210
210
|
module.exports.generateSsgHtml = binding.generateSsgHtml;
|
|
211
211
|
module.exports.generateSsgBareHtml = binding.generateSsgBareHtml;
|
|
212
|
+
module.exports.highlightCodeBlock = binding.highlightCodeBlock;
|
|
213
|
+
module.exports.applyPendingHighlights = binding.applyPendingHighlights;
|
|
214
|
+
module.exports.highlightHtmlCodeBlocks = binding.highlightHtmlCodeBlocks;
|
|
215
|
+
module.exports.highlightHtmlCodeBlocksAsync = binding.highlightHtmlCodeBlocksAsync;
|
|
216
|
+
module.exports.supportsHighlightLanguage = binding.supportsHighlightLanguage;
|
|
217
|
+
module.exports.nativeHighlightLanguages = binding.nativeHighlightLanguages;
|
|
218
|
+
module.exports.generateSsgBarePage = binding.generateSsgBarePage;
|
|
212
219
|
module.exports.getGitLastUpdated = binding.getGitLastUpdated;
|
|
213
220
|
module.exports.resolveSsgRoutePaths = binding.resolveSsgRoutePaths;
|
|
214
221
|
module.exports.getSsgOutputPath = binding.getSsgOutputPath;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ox-content/napi",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.90.0",
|
|
4
4
|
"description": "Node.js bindings for Ox Content - High-performance Markdown parser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
]
|
|
48
48
|
},
|
|
49
49
|
"optionalDependencies": {
|
|
50
|
-
"@ox-content/binding-darwin-x64": "2.
|
|
51
|
-
"@ox-content/binding-darwin-arm64": "2.
|
|
52
|
-
"@ox-content/binding-linux-x64-gnu": "2.
|
|
53
|
-
"@ox-content/binding-linux-x64-musl": "2.
|
|
54
|
-
"@ox-content/binding-linux-arm64-gnu": "2.
|
|
55
|
-
"@ox-content/binding-linux-arm64-musl": "2.
|
|
56
|
-
"@ox-content/binding-win32-x64-msvc": "2.
|
|
50
|
+
"@ox-content/binding-darwin-x64": "2.90.0",
|
|
51
|
+
"@ox-content/binding-darwin-arm64": "2.90.0",
|
|
52
|
+
"@ox-content/binding-linux-x64-gnu": "2.90.0",
|
|
53
|
+
"@ox-content/binding-linux-x64-musl": "2.90.0",
|
|
54
|
+
"@ox-content/binding-linux-arm64-gnu": "2.90.0",
|
|
55
|
+
"@ox-content/binding-linux-arm64-musl": "2.90.0",
|
|
56
|
+
"@ox-content/binding-win32-x64-msvc": "2.90.0"
|
|
57
57
|
}
|
|
58
58
|
}
|