Skip to content

Duplicated "DON'T EDIT THIS SECTION" lines in README since v2.4.0 #340

@okuryu

Description

@okuryu

After upgrading to doctoc v2.4.0, the "DON'T EDIT THIS SECTION" header lines are being duplicated every time I run the command. This behavior does not occur in v2.3.0.

Steps to repro

README.md:

# H1

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [H2-1](#h2-1)
- [H2-2](#h2-2)
- [H2-3](#h2-3)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## H2-1

## H2-2

## H2-3

Run the latest doctoc:

npx doctoc@latest README.md --github

Observe that the "DON'T EDIT THIS SECTION" lines are added repeatedly instead of being updated in place.

diff --git a/README.md b/README.md
index 7ddf7a5..f1c9330 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,7 @@
 
 <!-- START doctoc generated TOC please keep comment here to allow auto update -->
 <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
+<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
 
 - [H2-1](#h2-1)
 - [H2-2](#h2-2)

Expected behavior

The TOC should be updated without duplicating the warning headers, consistent with the behavior in v2.3.0.

Additional context

Version 2.3.0: Works as expected (no duplication).

Version 2.4.0: Causes duplication.

Is this an intended breaking change? Also, is there a new option available in v2.4.0 to maintain the previous behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions