Class ParagraphFilter
java.lang.Object
org.shredzone.commons.text.filter.ParagraphFilter
- All Implemented Interfaces:
Function<CharSequence,CharSequence>
,TextFilter
A filter that detects paragraphs and surrounds them with a HTML
<p>
container. Paragraphs are separated by empty lines. Additionally, single EOLs can be
replaced with <br />
tags.
This filter expects a normalized text (only LF is accepted as EOL marker, see
NormalizeFilter
).
- Author:
- Richard "Shred" Körber
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapply(CharSequence text)
Applies the filter on aCharSequence
and returns a newCharSequence
with the modified text.void
setFoldLines(boolean foldLines)
Also fold single EOL marker.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.shredzone.commons.text.TextFilter
toStringBuilder
-
Constructor Details
-
ParagraphFilter
public ParagraphFilter()
-
-
Method Details
-
setFoldLines
Also fold single EOL marker.- Parameters:
foldLines
-true
to create<br />
tags for single EOL markers,false
to keep the EOL marker. Defaults totrue
.
-
apply
Description copied from interface:TextFilter
Applies the filter on aCharSequence
and returns a newCharSequence
with the modified text.- Specified by:
apply
in interfaceFunction<CharSequence,CharSequence>
- Specified by:
apply
in interfaceTextFilter
- Parameters:
text
-CharSequence
with the contents to be filtered. If this is aStringBuilder
instance, its contents may have changed after invocation, and this instance should not be used any more.- Returns:
CharSequence
with the filtered text.
-