Skip to content

Commit

Permalink
Fix pretty printing of marc:leader (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
dr0i committed Sep 5, 2024
1 parent 9c0b4af commit cdbde42
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,11 @@ private void writeEscaped(final String str) {
private void writeLeader() {
final String leader = leaderBuilder.toString();
if (leaderBuilder.length() > 0) {
prettyPrintIndentation();
prettyPrintIndentationLeader();
writeTagLeader(Tag.leader::open);
writeRawLeader(leader);
writeTagLeader(Tag.leader::close);
prettyPrintNewLine();
prettyPrintNewLineLeader();
}
}

Expand All @@ -462,12 +462,25 @@ private void prettyPrintIndentation() {
}
}

private void prettyPrintIndentationLeader() {
if (formatted) {
final String prefix = String.join("", Collections.nCopies(indentationLevel, INDENT));
writeRawLeader(prefix);
}
}

private void prettyPrintNewLine() {
if (formatted) {
builder.append(NEW_LINE);
}
}

private void prettyPrintNewLineLeader() {
if (formatted) {
writeRawLeader(NEW_LINE);
}
}

private void sendAndClearData() {
getReceiver().process(builder.toString());
builder.delete(0, builder.length());
Expand Down

0 comments on commit cdbde42

Please sign in to comment.