Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't transform files whose TOC is unchanged #169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ exports = module.exports = function transform(content, mode, maxHeaderLevel, tit

var wrappedToc = start + '\n' + toc + '\n' + end;

if (currentToc === toc) return { transformed: false };
if (currentToc === wrappedToc) return { transformed: false };

var data = updateSection(lines.join('\n'), wrappedToc, matchesStart, matchesEnd, true);
return { transformed : true, data : data, toc: toc, wrappedToc: wrappedToc };
Expand Down
5 changes: 1 addition & 4 deletions test/fixtures/readme-with-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ README to test doctoc with edge-case headers.
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of Contents

- [Single Backticks](#single-backticks)
- [Multiple Backticks](#multiple-backticks)
- [code tag](#code-tag)
- [pre tag](#pre-tag)
Out of date

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

Expand Down
4 changes: 1 addition & 3 deletions test/fixtures/readme-with-custom-title.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ README to test doctoc with user-specified titles.
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of Contents

- [Installation](#installation)
- [API](#api)
- [License](#license)
Out of date

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

Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/readme-with-weird-headers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ README to test doctoc with edge-case headers.
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of Contents

- [hasOwnProperty](#hasownproperty)
- [something else](#something-else)
Out of date

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

Expand Down