Documentation for Simbo's Packages
    Preparing search index...

    Module @simbo/inject-between-html-comments - v2.0.0

    Inject Between HTML Comments

    📦 @simbo/inject-between-html-comments

    Inject content between HTML comment markers inside a string.

    Useful for markdown manipulation, code generation, documentation updates, or template modifications where placeholders are wrapped in comments.

    • Replace content between all occurrences of matching HTML comment blocks

    • Supports custom comment names (e.g., <!-- INJECT:foo --> … <!-- /INJECT:foo -->)

    • Configurable options for inline vs. block insertion

    • Optional trimming of injected content

    • Fully typed with TypeScript

    Requires Node.js ^22.22.2 || ^24.15.0 || >=26.0.0.

    Install @simbo/inject-between-html-comments from the npm registry:

    npm i [-D] @simbo/inject-between-html-comments
    

    For a complete API reference, see the documentation.

    Injected content is inserted literally: replacement sequences such as $& and $$ are preserved.

    import { injectBetweenHtmlComments } from '@simbo/inject-between-html-comments';

    const content = `
    # A Document

    <!-- INJECT -->

    Generated content.

    <!-- /INJECT -->
    `;

    const result = injectBetweenHtmlComments(content, 'Hello World!');

    /*
    # A Document

    <!-- INJECT -->

    Hello World!

    <!-- /INJECT -->
    */

    MIT © Simon Lepel

    Options
    TextOption
    injectBetweenHtmlComments