@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 +7 -0
- package/README.md +48 -10
- package/baseline-tests.sh +1 -1
- package/{src/cli/convert2jcr.js → bin/md2jcr.js} +4 -2
- package/package.json +4 -1
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
|
-
|
|
26
|
-
|
|
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
|
-
|
|
48
|
+
**Convert all markdown files in a directory:**
|
|
29
49
|
```bash
|
|
30
|
-
|
|
50
|
+
md2jcr test/fixtures/
|
|
31
51
|
```
|
|
32
|
-
|
|
52
|
+
|
|
53
|
+
**View output in console with verbose flag `-v`:**
|
|
33
54
|
```bash
|
|
34
|
-
|
|
55
|
+
md2jcr test/fixtures/simple.md -v
|
|
35
56
|
```
|
|
36
57
|
|
|
37
|
-
|
|
58
|
+
**View decoded XML output with `-v` and `-d` flags:**
|
|
38
59
|
```bash
|
|
39
|
-
|
|
60
|
+
md2jcr test/fixtures/simple.md -v -d
|
|
40
61
|
```
|
|
41
62
|
|
|
42
|
-
The converter will
|
|
43
|
-
|
|
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
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
1
3
|
/*
|
|
2
|
-
* Copyright
|
|
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.
|
|
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 .",
|