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:
parent
6a9f85146b
commit
65968c4a1f
@ -56,6 +56,9 @@ public interface SpannableFactory {
|
|||||||
boolean isHeader,
|
boolean isHeader,
|
||||||
boolean isOdd);
|
boolean isOdd);
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
Object paragraph(boolean inTightList);
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
Object image(
|
Object image(
|
||||||
@NonNull SpannableTheme theme,
|
@NonNull SpannableTheme theme,
|
||||||
|
@ -103,6 +103,12 @@ public class SpannableFactoryDef implements SpannableFactory {
|
|||||||
return new TableRowSpan(theme, cells, isHeader, isOdd);
|
return new TableRowSpan(theme, cells, isHeader, isOdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Object paragraph(boolean inTightList) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Object image(@NonNull SpannableTheme theme, @NonNull String destination, @NonNull AsyncDrawable.Loader loader, @NonNull ImageSizeResolver imageSizeResolver, @Nullable ImageSize imageSize, boolean replacementTextIsLink) {
|
public Object image(@NonNull SpannableTheme theme, @NonNull String destination, @NonNull AsyncDrawable.Loader loader, @NonNull ImageSizeResolver imageSizeResolver, @Nullable ImageSize imageSize, boolean replacementTextIsLink) {
|
||||||
|
@ -380,14 +380,15 @@ public class SpannableMarkdownVisitor extends AbstractVisitor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(Paragraph paragraph) {
|
public void visit(Paragraph paragraph) {
|
||||||
|
|
||||||
final boolean inTightList = isInTightList(paragraph);
|
final boolean inTightList = isInTightList(paragraph);
|
||||||
|
|
||||||
if (!inTightList) {
|
if (!inTightList) {
|
||||||
newLine();
|
newLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final int length = builder.length();
|
||||||
visitChildren(paragraph);
|
visitChildren(paragraph);
|
||||||
|
setSpan(length, factory.paragraph(inTightList));
|
||||||
|
|
||||||
if (!inTightList) {
|
if (!inTightList) {
|
||||||
newLine();
|
newLine();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user