comment-block-replacer 0.1.11 → 0.1.13
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 +19 -0
- package/package.json +3 -3
- package/src/index.js +2 -2
- package/test/index.test.js +46 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.1.13](https://github.com/DavidWells/markdown-magic/compare/comment-block-replacer@0.1.12...comment-block-replacer@0.1.13) (2026-01-19)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package comment-block-replacer
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.1.12](https://github.com/DavidWells/markdown-magic/compare/comment-block-replacer@0.1.11...comment-block-replacer@0.1.12) (2026-01-19)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **block-replacer:** use correct pattern keys for removeComments ([9b79efe](https://github.com/DavidWells/markdown-magic/commit/9b79efed8633994c524c858638f95360715dbafd))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [0.1.11](https://github.com/DavidWells/markdown-magic/compare/comment-block-replacer@0.1.10...comment-block-replacer@0.1.11) (2026-01-11)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package comment-block-replacer
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comment-block-replacer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Process files with comment block replacements",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"release:major": "pnpm run build && pnpm version major && pnpm publish"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"comment-block-transformer": "0.5.
|
|
18
|
+
"comment-block-transformer": "0.5.5",
|
|
19
19
|
"is-valid-path": "^0.1.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "3d60211919bdc910870a92270b64a7aeed5e44fc"
|
|
29
29
|
}
|
package/src/index.js
CHANGED
|
@@ -119,8 +119,8 @@ async function processFile(opts = {}) {
|
|
|
119
119
|
|
|
120
120
|
if (outputPath && (result.isChanged || result.isNewPath)) {
|
|
121
121
|
let cleanContents = result.updatedContents
|
|
122
|
-
if (result.stripComments && result.patterns.
|
|
123
|
-
cleanContents = result.updatedContents.replace(result.patterns.
|
|
122
|
+
if (result.stripComments && result.patterns.open && result.patterns.close) {
|
|
123
|
+
cleanContents = result.updatedContents.replace(result.patterns.open, '').replace(result.patterns.close, '')
|
|
124
124
|
}
|
|
125
125
|
await writeFile(outputPath, cleanContents)
|
|
126
126
|
}
|
package/test/index.test.js
CHANGED
|
@@ -243,7 +243,7 @@ TotallyCustom uppercase
|
|
|
243
243
|
content with comments
|
|
244
244
|
BlockHere
|
|
245
245
|
`
|
|
246
|
-
|
|
246
|
+
|
|
247
247
|
/** @type {ProcessFileOptions} */
|
|
248
248
|
const options = {
|
|
249
249
|
content,
|
|
@@ -263,9 +263,53 @@ BlockHere
|
|
|
263
263
|
const result = await processFile(options)
|
|
264
264
|
|
|
265
265
|
console.log('result', result)
|
|
266
|
-
|
|
266
|
+
|
|
267
267
|
assert.is(result.stripComments, true)
|
|
268
268
|
assert.is(result.isNewPath, true)
|
|
269
269
|
})
|
|
270
270
|
|
|
271
|
+
test('removeComments should strip comment blocks from output file', async () => {
|
|
272
|
+
const content = `# Test Document
|
|
273
|
+
|
|
274
|
+
<!-- block uppercase -->
|
|
275
|
+
hello world
|
|
276
|
+
<!-- /block -->
|
|
277
|
+
|
|
278
|
+
Some content in between.
|
|
279
|
+
|
|
280
|
+
<!-- block wordcount -->
|
|
281
|
+
one two three four five
|
|
282
|
+
<!-- /block -->
|
|
283
|
+
|
|
284
|
+
End of document.
|
|
285
|
+
`
|
|
286
|
+
|
|
287
|
+
const removeCommentsOutput = path.join(testDir, 'stripped.md')
|
|
288
|
+
|
|
289
|
+
/** @type {ProcessFileOptions} */
|
|
290
|
+
const options = {
|
|
291
|
+
content,
|
|
292
|
+
outputPath: removeCommentsOutput,
|
|
293
|
+
removeComments: true,
|
|
294
|
+
transforms: mockTransforms
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const result = await processFile(options)
|
|
298
|
+
|
|
299
|
+
assert.is(result.stripComments, true, 'stripComments should be true')
|
|
300
|
+
assert.is(result.isNewPath, true, 'isNewPath should be true')
|
|
301
|
+
assert.is(result.isChanged, true, 'isChanged should be true')
|
|
302
|
+
|
|
303
|
+
// Read the output file and verify comments are stripped
|
|
304
|
+
const outputContent = await fs.readFile(removeCommentsOutput, 'utf8')
|
|
305
|
+
|
|
306
|
+
// Should contain the transformed content
|
|
307
|
+
assert.ok(outputContent.includes('HELLO WORLD'), 'should have transformed content')
|
|
308
|
+
assert.ok(outputContent.includes('Word count: 5'), 'should have wordcount transform')
|
|
309
|
+
|
|
310
|
+
// Should NOT contain comment blocks
|
|
311
|
+
assert.not.ok(outputContent.includes('<!-- block'), 'should not have opening comment')
|
|
312
|
+
assert.not.ok(outputContent.includes('<!-- /block'), 'should not have closing comment')
|
|
313
|
+
})
|
|
314
|
+
|
|
271
315
|
test.run()
|