Paragraph text can now explicitly be spanned

Background:
Consumers of the library may for instance want line spacing for the
paragraph text but TextView's `lineSpacingMultiplier` and/or
`lineSpacingExtra` apply line spacing to all lines.

With this change, paragraphs may explicitly be spanned with a paragraph
affecting span such as `LineHeightSpan` while the other tags
(e.g. headings) will be unaffected.
This commit is contained in:
Cyrus Bakhtiari-Haftlang 2018-08-13 15:20:24 +02:00
parent 6a9f85146b
commit 65968c4a1f
3 changed files with 11 additions and 1 deletions

View File

@ -56,6 +56,9 @@ public interface SpannableFactory {
boolean isHeader,
boolean isOdd);
@Nullable
Object paragraph(boolean inTightList);
@Nullable
Object image(
@NonNull SpannableTheme theme,

View File

@ -103,6 +103,12 @@ public class SpannableFactoryDef implements SpannableFactory {
return new TableRowSpan(theme, cells, isHeader, isOdd);
}
@Nullable
@Override
public Object paragraph(boolean inTightList) {
return null;
}
@Nullable
@Override
public Object image(@NonNull SpannableTheme theme, @NonNull String destination, @NonNull AsyncDrawable.Loader loader, @NonNull ImageSizeResolver imageSizeResolver, @Nullable ImageSize imageSize, boolean replacementTextIsLink) {

View File

@ -380,14 +380,15 @@ public class SpannableMarkdownVisitor extends AbstractVisitor {
@Override
public void visit(Paragraph paragraph) {
final boolean inTightList = isInTightList(paragraph);
if (!inTightList) {
newLine();
}
final int length = builder.length();
visitChildren(paragraph);
setSpan(length, factory.paragraph(inTightList));
if (!inTightList) {
newLine();