Skip to content

Commit 88912e5

Browse files
committed
docs(remark-includes): update for path resolution and usage
Update the README to clarify how include paths are resolved when processing in-memory strings, consolidate usage examples, and document directive requirements and error handling behavior. Assisted-by: GPT-5-3 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent f4b98dd commit 88912e5

1 file changed

Lines changed: 13 additions & 20 deletions

File tree

  • lib/node_modules/@stdlib/_tools/remark/plugins/remark-includes

lib/node_modules/@stdlib/_tools/remark/plugins/remark-includes/README.md

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,24 @@ Attaches a plugin to a [remark][remark] processor in order to insert content fro
3737
<!-- eslint-disable node/no-sync -->
3838

3939
```javascript
40+
var join = require( 'path' ).join;
4041
var remark = require( 'remark' );
4142

43+
var opts = {
44+
'dir': join( __dirname, 'snippets' )
45+
};
46+
4247
var str = '# Hello World!\n';
4348
str += '\n';
44-
str += '<!-- <include path="./docs/snippets/foo.md"> -->\n';
49+
str += '<!-- <include path="./foo.md"> -->\n';
4550
str += '\n';
4651
str += '<!-- </include> -->\n';
4752

48-
var vfile = remark().use( includes ).processSync( str );
53+
var vfile = remark().use( includes, opts ).processSync( str );
4954
```
5055

56+
By default, include paths are resolved relative to the processed file's directory. Accordingly, when processing an in-memory string without a file path, includes may not be resolved unless a base directory is provided via the `dir` option.
57+
5158
The plugin recognizes HTML comments of the form
5259

5360
```html
@@ -58,30 +65,16 @@ The plugin recognizes HTML comments of the form
5865

5966
and inserts the parsed Markdown content of the referenced file between the opening and closing comment tags.
6067

68+
The opening include directive requires a `path` attribute with a double-quoted value.
69+
6170
The plugin accepts the following `options`:
6271

6372
- **dir**: base directory for resolving include paths. Default: `null` (resolved relative to the processed file's directory).
6473

65-
To specify a base directory from which to resolve include paths:
66-
67-
<!-- eslint-disable node/no-sync -->
68-
69-
```javascript
70-
var remark = require( 'remark' );
71-
72-
var opts = {
73-
'dir': '/absolute/path/to/snippets'
74-
};
75-
76-
var str = '<!-- <include path="./foo.md"> -->\n';
77-
str += '\n';
78-
str += '<!-- </include> -->\n';
79-
80-
var vfile = remark().use( includes, opts ).processSync( str );
81-
```
82-
8374
If a referenced file cannot be found, the plugin issues a warning and leaves the include block unchanged.
8475

76+
If an opening include directive does not have a matching closing include directive, the plugin issues a warning and leaves the include block unchanged.
77+
8578
</section>
8679

8780
<!-- /.usage -->

0 commit comments

Comments
 (0)