Skip to content

Commit

Permalink
fix mutable toc options
Browse files Browse the repository at this point in the history
  • Loading branch information
vsch committed Apr 18, 2020
1 parent c770a31 commit 21c6d4a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions VERSION-TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- [Release 0.60.0](#release-0600)
- [API Refactoring](#api-refactoring)
- [Next 0.61.xx](#next-061xx)
- [Next 0.61.12](#next-06112)
- [0.61.12](#06112)
- [0.61.10](#06110)
- [0.61.8](#0618)
- [0.61.6](#0616)
Expand Down Expand Up @@ -218,7 +218,7 @@ Please give feedback on the upcoming changes if you have concerns about breaking
* [ ] Fix: Html converter to not add spaces between end of inline marker and next punctuation:
`.,:;`

## Next 0.61.12
## 0.61.12

* Fix: update docx4j to 8.1.6
* Fix: docx rendering tests for full spec example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,23 @@ public TocOptions toImmutable() {
return new TocOptions(this);
}

/**
* Used to normalize title and titleLevel after changing titleRaw or rawTitle
*/
public void normalizeFromRaw() {
if (title != null) {
CharSequence charSequence = rawTitle.trim();
int markers = BasedSequence.of(charSequence).countLeading(CharPredicate.HASH);
if (markers >= 1 && markers <= 6) rawTitleLevel = markers;
String useTitle = rawTitle.substring(markers).trim();
this.title = useTitle.isEmpty() ? " " : useTitle;
} else {
this.title = "";
}

this.titleLevel = Math.max(1, Math.min(rawTitleLevel, 6));
}

@NotNull
@Override
public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) {
Expand Down

0 comments on commit 21c6d4a

Please sign in to comment.