@adobe/helix-md2jcr 1.1.38 → 1.2.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.2.0](https://github.com/adobe/helix-md2jcr/compare/v1.1.38...v1.2.0) (2025-10-06)
2
+
3
+
4
+ ### Features
5
+
6
+ * add global CLI command for md2jcr ([4705024](https://github.com/adobe/helix-md2jcr/commit/47050246625b58ea93d23ac8c7fc303edc81998f))
7
+
1
8
  ## [1.1.38](https://github.com/adobe/helix-md2jcr/compare/v1.1.37...v1.1.38) (2025-10-06)
2
9
 
3
10
 
package/README.md CHANGED
@@ -16,31 +16,69 @@ npm install
16
16
  ```
17
17
 
18
18
  ## Usage
19
+
20
+ ### Installation
21
+
19
22
  You can install the package via npm:
20
23
 
21
24
  ```bash
22
25
  npm install @adobe/helix-md2jcr
23
26
  ```
24
27
 
25
- ## Converting Markdown to JCR Nodes
26
- Running the following command will generate an XML file with the JCR structure alongside of the input file.
28
+ Or use it directly with `npx` without installing:
29
+
30
+ ```bash
31
+ npx @adobe/helix-md2jcr path/to/content.md
32
+ ```
33
+
34
+ ### Converting Markdown to JCR Nodes
35
+
36
+ The package includes a CLI tool `md2jcr` that converts markdown files to JCR XML format.
37
+
38
+ **Basic usage:**
39
+ ```bash
40
+ npx @adobe/helix-md2jcr path/to/content.md
41
+ ```
42
+
43
+ **Convert a single file:**
44
+ ```bash
45
+ md2jcr test/fixtures/simple.md
46
+ ```
27
47
 
28
- For example generating xml for the simple.md file, run:
48
+ **Convert all markdown files in a directory:**
29
49
  ```bash
30
- node ./src/cli/convert2jcr.js test/fixtures/simple.md
50
+ md2jcr test/fixtures/
31
51
  ```
32
- If you wish to see the output in the console, you can run the following command with the verbose flag -v
52
+
53
+ **View output in console with verbose flag `-v`:**
33
54
  ```bash
34
- node ./src/cli/convert2jcr.js test/fixtures/simple.md -v
55
+ md2jcr test/fixtures/simple.md -v
35
56
  ```
36
57
 
37
- If you wish to see the decoded output in the console you can run the following command with the verbose and decode flags -v and -d:
58
+ **View decoded XML output with `-v` and `-d` flags:**
38
59
  ```bash
39
- node ./src/cli/convert2jcr.js test/fixtures/simple.md -v -d
60
+ md2jcr test/fixtures/simple.md -v -d
40
61
  ```
41
62
 
42
- The converter will produce a `.xml` which is the generated document converted
43
- from markdown. This can be used to check for potential content changes due to conversion.
63
+ The converter will generate a `.xml` file alongside the markdown file containing the JCR structure. This can be used to check for potential content changes due to conversion.
64
+
65
+ ### Programmatic Usage
66
+
67
+ You can also use the library programmatically in your Node.js code:
68
+
69
+ ```javascript
70
+ import { md2jcr } from '@adobe/helix-md2jcr';
71
+
72
+ const markdown = '# Hello World\n\nThis is a test.';
73
+ const options = {
74
+ models: [...],
75
+ definition: {...},
76
+ filters: [...]
77
+ };
78
+
79
+ const xml = await md2jcr(markdown, options);
80
+ console.log(xml);
81
+ ```
44
82
 
45
83
  ## Baseline XML Files
46
84
  Running the ./baseline-tests.sh script will detect any md file under test/fixtures and execute the convert2jcr node script.
package/baseline-tests.sh CHANGED
@@ -36,7 +36,7 @@ done
36
36
  MD_DIR="test/fixtures"
37
37
 
38
38
  # Node script to execute
39
- NODE_SCRIPT="src/cli/convert2jcr.js"
39
+ NODE_SCRIPT="bin/md2jcr.js"
40
40
 
41
41
  # Check if the directory exists
42
42
  if [ ! -d "$MD_DIR" ]; then
@@ -1,5 +1,7 @@
1
+ #!/usr/bin/env node
2
+
1
3
  /*
2
- * Copyright 2021 Adobe. All rights reserved.
4
+ * Copyright 2024 Adobe. All rights reserved.
3
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
6
  * you may not use this file except in compliance with the License. You may obtain a copy
5
7
  * of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -16,7 +18,7 @@ import {
16
18
  } from 'fs/promises';
17
19
  import path from 'path';
18
20
  import { decode } from 'entities';
19
- import { md2jcr } from '../index.js';
21
+ import { md2jcr } from '../src/index.js';
20
22
 
21
23
  /**
22
24
  * Read a JSON file. If the file does not exist, return an empty object.
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@adobe/helix-md2jcr",
3
- "version": "1.1.38",
3
+ "version": "1.2.0",
4
4
  "description": "Helix Service that converts markdown to JCR content structure",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
7
+ "bin": {
8
+ "md2jcr": "./bin/md2jcr.js"
9
+ },
7
10
  "scripts": {
8
11
  "test": "c8 mocha 'test/*.tests.js'",
9
12
  "lint": "eslint .",