@ox-content/napi 3.0.0-alpha.13 → 3.0.0-alpha.15

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.
Files changed (3) hide show
  1. package/index.d.ts +63 -3
  2. package/index.js +2 -0
  3. package/package.json +8 -8
package/index.d.ts CHANGED
@@ -885,11 +885,35 @@ export interface JsEditThisPageOptions {
885
885
  */
886
886
  branch?: string
887
887
  /**
888
- * Root directory used to relativize `sourcePath`.
888
+ * Where the source root sits inside the repository. Prefixed to the
889
+ * page path, which is then taken relative to `src_dir`.
889
890
  *
890
- * Default: no extra root prefix.
891
+ * Default: no prefix, and the page path stays relative to the process's
892
+ * working directory.
891
893
  */
892
894
  rootDir?: string
895
+ /**
896
+ * Absolute path of the source root on disk, supplied by the build so
897
+ * `root_dir` can be joined with the page's path inside that root.
898
+ *
899
+ * Default: none, which makes `root_dir` inert.
900
+ */
901
+ srcDir?: string
902
+ /**
903
+ * Forge whose edit-URL shape to use: `github`, `gitlab`, `bitbucket`,
904
+ * or `gitea`.
905
+ *
906
+ * Default: inferred from the `repo_url` host, falling back to
907
+ * `github`. An unrecognized value is inferred the same way.
908
+ */
909
+ provider?: string
910
+ /**
911
+ * Edit-URL template, which wins over `provider`. Understands
912
+ * `{repoUrl}`, `{branch}`, and `{path}`; other braces stay literal.
913
+ *
914
+ * Default: the pattern for the resolved provider.
915
+ */
916
+ urlPattern?: string
893
917
  /**
894
918
  * Link label.
895
919
  *
@@ -1507,6 +1531,16 @@ export interface JsMathOptions {
1507
1531
  enabled?: boolean
1508
1532
  }
1509
1533
 
1534
+ /** A parsed document on its way to a JavaScript `transformers` hook. */
1535
+ export interface JsMdastTransformResult {
1536
+ /** The tree, as mdast JSON. */
1537
+ astJson: string
1538
+ /** Frontmatter as JSON, which the tree has no room for. */
1539
+ frontmatter: string
1540
+ /** Preprocessing and parse errors collected so far. */
1541
+ errors: Array<string>
1542
+ }
1543
+
1510
1544
  /** Built-in media embed transform switches. */
1511
1545
  export interface JsMediaEmbedsOptions {
1512
1546
  /**
@@ -3165,7 +3199,13 @@ export declare function prepareSource(source: string, options?: JsSourceOptions
3165
3199
  */
3166
3200
  export declare function prepareSourceRaw(source: string, options?: JsSourceOptions | undefined | null): Uint8Array
3167
3201
 
3168
- /** Renders an AST (provided as JSON) to HTML. */
3202
+ /**
3203
+ * Renders an mdast (provided as JSON) to HTML.
3204
+ *
3205
+ * The counterpart to [`parse`]: a tree rewritten in JavaScript comes back
3206
+ * through here and is rendered by the same renderer the original would
3207
+ * have used.
3208
+ */
3169
3209
  export declare function render(astJson: string): RenderResult
3170
3210
 
3171
3211
  /**
@@ -3241,6 +3281,26 @@ export declare function transformAsync(source: string, options?: JsTransformOpti
3241
3281
  /** Numbers headings, figures, and tables, and links `@id` references to them. */
3242
3282
  export declare function transformCrossReferences(html: string, options: JsCrossReferencesOptions): JsCrossReferenceOutput
3243
3283
 
3284
+ /**
3285
+ * Finishes a transform from an mdast a JavaScript `transformers` hook may
3286
+ * have rewritten.
3287
+ *
3288
+ * `transformMdastRaw` produces the tree; this renders it and runs
3289
+ * everything that follows rendering — HTML postprocessing, sanitization,
3290
+ * the table of contents, and the MDX metadata — so a rewritten tree loses
3291
+ * none of it. `frontmatterJson` is carried through untouched.
3292
+ */
3293
+ export declare function transformFromMdast(astJson: string, frontmatterJson: string, options?: JsTransformOptions | undefined | null): TransformResult
3294
+
3295
+ /**
3296
+ * Runs a transform up to the point where the tree exists.
3297
+ *
3298
+ * The counterpart to `transformFromMdast`: frontmatter is parsed and the
3299
+ * opt-in Markdown features are expanded, then the tree is handed over as
3300
+ * JSON for a `transformers` hook to rewrite.
3301
+ */
3302
+ export declare function transformMdast(source: string, options?: JsTransformOptions | undefined | null): JsMdastTransformResult
3303
+
3244
3304
  /**
3245
3305
  * Transforms Markdown into a raw mdast transfer buffer.
3246
3306
  *
package/index.js CHANGED
@@ -171,6 +171,8 @@ module.exports.render = binding.render;
171
171
  module.exports.transform = binding.transform;
172
172
  module.exports.transformAsync = binding.transformAsync;
173
173
  module.exports.transformMdastRaw = binding.transformMdastRaw;
174
+ module.exports.transformMdast = binding.transformMdast;
175
+ module.exports.transformFromMdast = binding.transformFromMdast;
174
176
  module.exports.sanitizeHtml = binding.sanitizeHtml;
175
177
  module.exports.transformMediaEmbeds = binding.transformMediaEmbeds;
176
178
  module.exports.transformMediaEmbedsWithDiagnostics = binding.transformMediaEmbedsWithDiagnostics;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ox-content/napi",
3
- "version": "3.0.0-alpha.13",
3
+ "version": "3.0.0-alpha.15",
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": "3.0.0-alpha.13",
51
- "@ox-content/binding-darwin-arm64": "3.0.0-alpha.13",
52
- "@ox-content/binding-linux-x64-gnu": "3.0.0-alpha.13",
53
- "@ox-content/binding-linux-x64-musl": "3.0.0-alpha.13",
54
- "@ox-content/binding-linux-arm64-gnu": "3.0.0-alpha.13",
55
- "@ox-content/binding-linux-arm64-musl": "3.0.0-alpha.13",
56
- "@ox-content/binding-win32-x64-msvc": "3.0.0-alpha.13"
50
+ "@ox-content/binding-darwin-x64": "3.0.0-alpha.15",
51
+ "@ox-content/binding-darwin-arm64": "3.0.0-alpha.15",
52
+ "@ox-content/binding-linux-x64-gnu": "3.0.0-alpha.15",
53
+ "@ox-content/binding-linux-x64-musl": "3.0.0-alpha.15",
54
+ "@ox-content/binding-linux-arm64-gnu": "3.0.0-alpha.15",
55
+ "@ox-content/binding-linux-arm64-musl": "3.0.0-alpha.15",
56
+ "@ox-content/binding-win32-x64-msvc": "3.0.0-alpha.15"
57
57
  }
58
58
  }