Skip to content

Commit 710a231

Browse files
committed
docs: fix typos and improve clarity in README.md
1 parent 068745f commit 710a231

File tree

1 file changed

+47
-40
lines changed

1 file changed

+47
-40
lines changed

README.md

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ or
3636
pnpm add -D html-loader
3737
```
3838

39-
Then add the plugin to your `webpack` config. For example:
39+
Then add the loader to your `webpack` configuration. For example:
4040

4141
**file.js**
4242

@@ -102,32 +102,33 @@ You may need to specify loaders for images in your configuration (recommended [`
102102

103103
Supported tags and attributes:
104104

105-
- the `src` attribute of the `audio` tag
106-
- the `src` attribute of the `embed` tag
107-
- the `src` attribute of the `img` tag
108-
- the `srcset` attribute of the `img` tag
109-
- the `src` attribute of the `input` tag
110-
- the `data` attribute of the `object` tag
111-
- the `src` attribute of the `script` tag
112-
- the `href` attribute of the `script` tag
113-
- the `xlink:href` attribute of the `script` tag
114-
- the `src` attribute of the `source` tag
115-
- the `srcset` attribute of the `source` tag
116-
- the `src` attribute of the `track` tag
117-
- the `poster` attribute of the `video` tag
118-
- the `src` attribute of the `video` tag
119-
- the `xlink:href` attribute of the `image` tag
120-
- the `href` attribute of the `image` tag
121-
- the `xlink:href` attribute of the `use` tag
122-
- the `href` attribute of the `use` tag
123-
- the `href` attribute of the `link` tag when the `rel` attribute contains `stylesheet`, `icon`, `shortcut icon`, `mask-icon`, `apple-touch-icon`, `apple-touch-icon-precomposed`, `apple-touch-startup-image`, `manifest`, `prefetch`, `preload` or when the `itemprop` attribute is `image`, `logo`, `screenshot`, `thumbnailurl`, `contenturl`, `downloadurl`, `duringmedia`, `embedurl`, `installurl`, `layoutimage`
124-
- the `imagesrcset` attribute of the `link` tag when the `rel` attribute contains `stylesheet`, `icon`, `shortcut icon`, `mask-icon`, `apple-touch-icon`, `apple-touch-icon-precomposed`, `apple-touch-startup-image`, `manifest`, `prefetch`, `preload`
125-
- the `content` attribute of the `meta` tag when the `name` attribute is `msapplication-tileimage`, `msapplication-square70x70logo`, `msapplication-square150x150logo`, `msapplication-wide310x150logo`, `msapplication-square310x310logo`, `msapplication-config`, `twitter:image` or when the `property` attribute is `og:image`, `og:image:url`, `og:image:secure_url`, `og:audio`, `og:audio:secure_url`, `og:video`, `og:video:secure_url`, `vk:image` or when the `itemprop` attribute is `image`, `logo`, `screenshot`, `thumbnailurl`, `contenturl`, `downloadurl`, `duringmedia`, `embedurl`, `installurl`, `layoutimage`
126-
- the `icon-uri` value component in `content` attribute of the `meta` tag when the `name` attribute is `msapplication-task`
105+
- The `src` attribute of the `audio` tag
106+
- The `src` attribute of the `embed` tag
107+
- The `src` attribute of the `img` tag
108+
- The `srcset` attribute of the `img` tag
109+
- The `src` attribute of the `input` tag
110+
- The `data` attribute of the `object` tag
111+
- The `src` attribute of the `script` tag
112+
- The `href` attribute of the `script` tag
113+
- The `xlink:href` attribute of the `script` tag
114+
- The `src` attribute of the `source` tag
115+
- The `srcset` attribute of the `source` tag
116+
- The `src` attribute of the `track` tag
117+
- The `poster` attribute of the `video` tag
118+
- The `src` attribute of the `video` tag
119+
- The `xlink:href` attribute of the `image` tag
120+
- The `href` attribute of the `image` tag
121+
- The `xlink:href` attribute of the `use` tag
122+
- The `href` attribute of the `use` tag
123+
- The `href` attribute of the `link` tag when the `rel` attribute contains `stylesheet`, `icon`, `shortcut icon`, `mask-icon`, `apple-touch-icon`, `apple-touch-icon-precomposed`, `apple-touch-startup-image`, `manifest`, `prefetch`, `preload` or when the `itemprop` attribute is `image`, `logo`, `screenshot`, `thumbnailurl`, `contenturl`, `downloadurl`, `duringmedia`, `embedurl`, `installurl`, `layoutimage`
124+
- The `imagesrcset` attribute of the `link` tag when the `rel` attribute contains `stylesheet`, `icon`, `shortcut icon`, `mask-icon`, `apple-touch-icon`, `apple-touch-icon-precomposed`, `apple-touch-startup-image`, `manifest`, `prefetch`, `preload`
125+
- The `content` attribute of the `meta` tag when the `name` attribute is `msapplication-tileimage`, `msapplication-square70x70logo`, `msapplication-square150x150logo`, `msapplication-wide310x150logo`, `msapplication-square310x310logo`, `msapplication-config`, `twitter:image` or when the `property` attribute is `og:image`, `og:image:url`, `og:image:secure_url`, `og:audio`, `og:audio:secure_url`, `og:video`, `og:video:secure_url`, `vk:image` or when the `itemprop` attribute is `image`, `logo`, `screenshot`, `thumbnailurl`, `contenturl`, `downloadurl`, `duringmedia`, `embedurl`, `installurl`, `layoutimage`
126+
- The `icon-uri` value component in `content` attribute of the `meta` tag when the `name` attribute is `msapplication-task`
127127

128128
#### `boolean`
129129

130-
The `true` value enables the processing of all default elements and attributes, the `false` value disables the processing of all attributes.
130+
- true: Enables processing of all default tags and attributes
131+
- false: Disables processing entirely
131132

132133
**webpack.config.js**
133134

@@ -150,7 +151,7 @@ module.exports = {
150151

151152
#### `object`
152153

153-
Allows you to specify which tags and attributes to process, filter them, filter urls and process sources starting with `/`.
154+
Allows you to specify which tags and attributes to process, filter them, filter URLs and process sources starting with `/`.
154155

155156
For example:
156157

@@ -291,7 +292,7 @@ module.exports = {
291292

292293
If the tag name is not specified it will process all the tags.
293294

294-
> You can use your custom filter to specify html elements to be processed.
295+
> You can use your custom filter to specify HTML elements to be processed.
295296
296297
For example:
297298

@@ -418,7 +419,7 @@ type urlFilter = (
418419

419420
Default: `undefined`
420421

421-
Allow to filter urls. All filtered urls will not be resolved (left in the code as they were written).
422+
Allow to filter URLs. All filtered URLs will not be resolved (left in the code as they were written).
422423
Non-requestable sources (for example `<img src="javascript:void(0)">`) are not handled by default.
423424

424425
```js
@@ -459,9 +460,9 @@ type scriptingEnabled = boolean;
459460

460461
Default: `true`
461462

462-
By default, the parser in `html-loader` interprets content inside `<noscript>` tags as `#text`, so processing of content inside this tag will be ignored.
463+
By default, the parser in `html-loader` interprets content inside `<noscript>` tags as plain `#text`, so processing of content inside these tags will is ignored during processing.
463464

464-
In order to enable processing inside `<noscript>` for content recognition by the parser as `#AST`, set this parameter to: `false`
465+
In order to enable processing inside `<noscript>` for content recognition by the parser as `#AST`, set this option to: `false`
465466

466467
Additional information: [scriptingEnabled](https://parse5.js.org/interfaces/parse5.ParserOptions.html#scriptingEnabled)
467468

@@ -496,11 +497,11 @@ type preprocessor = (content: string, loaderContext: LoaderContext) => string;
496497

497498
Default: `undefined`
498499

499-
Allows pre-processing of content before handling.
500+
Allows pre-processing of content before handling by the loader.
500501

501502
> [!WARNING]
502503
>
503-
> You should always return valid HTML
504+
> You should always return valid HTML.
504505
505506
**file.hbs**
506507

@@ -642,7 +643,7 @@ module.exports = {
642643
};
643644
```
644645

645-
You can also set the `postprocessor` option as an asynchronous function instance.
646+
You can also set the `postprocessor` option as an asynchronous `function` instance.
646647

647648
For example:
648649

@@ -698,7 +699,7 @@ type minimize =
698699

699700
Default: `true` in production mode, otherwise `false`
700701

701-
Tell `html-loader` to minimize HTML.
702+
Use this option to enable or customize HTML minimization with `html-loader`.
702703

703704
#### `boolean`
704705

@@ -743,7 +744,7 @@ module.exports = {
743744

744745
See [html-minifier-terser](https://github.com/DanielRuf/html-minifier-terser)'s documentation for more information on the available options.
745746

746-
The default rules can be overridden using the following options in your `webpack.conf.js`
747+
The default rules can be overridden using the following options in your `webpack.config.js`
747748

748749
**webpack.config.js**
749750

@@ -805,7 +806,7 @@ Default: `true`
805806
By default, `html-loader` generates JS modules that use the ES modules syntax.
806807
There are some cases in which using ES modules is beneficial, such as [module concatenation](https://webpack.js.org/plugins/module-concatenation-plugin/) and [tree shaking](https://webpack.js.org/guides/tree-shaking/).
807808

808-
You can enable a CommonJS modules syntax using:
809+
If you want to generate CommonJS modules instead (e.g., `module.exports =`), set:
809810

810811
**webpack.config.js**
811812

@@ -827,9 +828,9 @@ module.exports = {
827828

828829
## Examples
829830

830-
### Disable url resolving using the `<!-- webpackIgnore: true -->` comment
831+
### Disable URL resolving using the `<!-- webpackIgnore: true -->` comment
831832

832-
With `<!-- webpackIgnore: true -->` comment, one can disable sources handling for next tag.
833+
Use the `<!-- webpackIgnore: true -->` comment to prevent html-loader from processing URLs for the next HTML tag. This is useful when you don’t want Webpack to handle asset imports automatically.
833834

834835
```html
835836
<!-- Disabled url handling for the src attribute -->
@@ -1016,7 +1017,9 @@ module.exports = {
10161017

10171018
### Templating
10181019

1019-
You can use any template system. Below is an example for [handlebars](https://handlebarsjs.com/).
1020+
You can use any templating engine by leveraging the preprocessor option in html-loader. The preprocessor function receives the file content and the loader context, allowing you to transform the HTML before it’s processed by webpack.
1021+
1022+
Below is an example for [handlebars](https://handlebarsjs.com/).
10201023

10211024
**file.hbs**
10221025

@@ -1062,9 +1065,12 @@ module.exports = {
10621065
};
10631066
```
10641067

1068+
This setup will transform the `file.hbs` template using Handlebars before passing the result to `html-loader`.
1069+
10651070
### PostHTML
10661071

1067-
You can use [PostHTML](https://github.com/posthtml/posthtml) without any additional loaders.
1072+
You can use [PostHTML](https://github.com/posthtml/posthtml) to transform HTML before it's processed, without needing additional loaders.
1073+
This is useful for tasks like converting image formats, adding attributes, or restructuring markup.
10681074

10691075
**file.html**
10701076

@@ -1142,7 +1148,8 @@ module.exports = {
11421148

11431149
## Contributing
11441150

1145-
Please take a moment to read our contributing guidelines if you haven't yet done so.
1151+
We welcome all contributions!
1152+
If you're new here, please take a moment to review our contributing guidelines before submitting issues or pull requests.
11461153

11471154
[CONTRIBUTING](./.github/CONTRIBUTING.md)
11481155

0 commit comments

Comments
 (0)