Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class LocationTextExtractionStrategy : ITextExtractionStrategy {

private TextRenderInfo lastTextRenderInfo;

private string elementSeparator = "";
private string newLine = "\n";

/// <summary>Creates a new text extraction renderer.</summary>
public LocationTextExtractionStrategy()
: this(new LocationTextExtractionStrategy.ITextChunkLocationStrategyImpl()) {
Expand All @@ -60,6 +63,16 @@ public LocationTextExtractionStrategy(LocationTextExtractionStrategy.ITextChunkL
tclStrat = strat;
}

/// <summary>
/// Sets the string values used to separate elements and lines when formatting output.
/// </summary>
/// <param name="elementSeparator">The string to use as a separator between elements. Cannot be null.</param>
/// <param name="newLine">The string to use to represent a new line. Cannot be null.</param>
public void SetSeparators(string elementSeparator, string newLine) {
this.elementSeparator = elementSeparator;
this.newLine = newLine;
}

/// <summary>
/// Changes the behavior of text extraction so that if the parameter is set to
/// <see langword="true"/>
Expand Down Expand Up @@ -166,12 +179,12 @@ public virtual String GetResultantText() {
// we only insert a blank space if the trailing character of the previous string wasn't a space, and the leading character of the current string isn't a space
if (IsChunkAtWordBoundary(chunk, lastChunk) && !StartsWithSpace(chunk.text) && !EndsWithSpace(lastChunk.text
)) {
sb.Append(' ');
sb.Append(elementSeparator);
}
sb.Append(chunk.text);
}
else {
sb.Append('\n');
sb.Append(newLine);
sb.Append(chunk.text);
}
}
Expand Down