@ox-content/napi 2.89.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 +73 -0
- package/index.js +6 -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
|
*
|
|
@@ -202,6 +213,36 @@ export declare function getSsgPageLocale(urlPath: string, defaultLocale: string,
|
|
|
202
213
|
/** Converts a markdown file path to a relative SSG URL path. */
|
|
203
214
|
export declare function getSsgUrlPath(inputPath: string, srcDir: string): string
|
|
204
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
|
+
|
|
205
246
|
/** Result of i18n checking. */
|
|
206
247
|
export interface I18NCheckResult {
|
|
207
248
|
/** All diagnostics. */
|
|
@@ -839,6 +880,24 @@ export interface JsHeroNotice {
|
|
|
839
880
|
body?: Array<string>
|
|
840
881
|
}
|
|
841
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
|
+
|
|
842
901
|
/** Configuration for generated i18n runtime modules. */
|
|
843
902
|
export interface JsI18NRuntimeConfig {
|
|
844
903
|
/** Default locale tag. */
|
|
@@ -1042,6 +1101,14 @@ export interface JsParserOptions {
|
|
|
1042
1101
|
autolinks?: boolean
|
|
1043
1102
|
}
|
|
1044
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
|
+
|
|
1045
1112
|
/** Options for [`super::transform_pm_embeds`]. */
|
|
1046
1113
|
export interface JsPmOptions {
|
|
1047
1114
|
/**
|
|
@@ -1819,6 +1886,9 @@ export interface Mf2ValidateResult {
|
|
|
1819
1886
|
astJson?: string
|
|
1820
1887
|
}
|
|
1821
1888
|
|
|
1889
|
+
/** Every language name and alias the native highlighter answers to. */
|
|
1890
|
+
export declare function nativeHighlightLanguages(): Array<string>
|
|
1891
|
+
|
|
1822
1892
|
/** Normalizes VitePress-specific frontmatter into ox-content's entry-page shape. */
|
|
1823
1893
|
export declare function normalizeVitePressFrontmatter(frontmatter: any): any
|
|
1824
1894
|
|
|
@@ -1914,6 +1984,9 @@ export declare function sanitizeHtml(html: string, options?: JsSanitizeOptions |
|
|
|
1914
1984
|
*/
|
|
1915
1985
|
export declare function searchIndex(indexJson: string, query: string, options?: JsSearchOptions | undefined | null): Array<JsSearchResult>
|
|
1916
1986
|
|
|
1987
|
+
/** Whether a fenced code block tagged `lang` will be highlighted natively. */
|
|
1988
|
+
export declare function supportsHighlightLanguage(lang: string): boolean
|
|
1989
|
+
|
|
1917
1990
|
/** Table of contents entry. */
|
|
1918
1991
|
export interface TocEntry {
|
|
1919
1992
|
/** Heading depth (1-6). */
|
package/index.js
CHANGED
|
@@ -209,6 +209,12 @@ 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;
|
|
212
218
|
module.exports.generateSsgBarePage = binding.generateSsgBarePage;
|
|
213
219
|
module.exports.getGitLastUpdated = binding.getGitLastUpdated;
|
|
214
220
|
module.exports.resolveSsgRoutePaths = binding.resolveSsgRoutePaths;
|
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
|
}
|