V1.0.2 (#17)
* Removing trailing new lines from parsed markdown * Fix for heading break height and thematic break height * Tables can have no borders (0)
This commit is contained in:
parent
6e2dd36e4f
commit
7a318527d9
@ -6,7 +6,7 @@ org.gradle.configureondemand=true
|
||||
android.enableBuildCache=true
|
||||
android.buildCacheDir=build/pre-dex-cache
|
||||
|
||||
VERSION_NAME=1.0.1
|
||||
VERSION_NAME=1.0.2
|
||||
|
||||
GROUP=ru.noties
|
||||
POM_DESCRIPTION=Markwon
|
||||
|
@ -160,6 +160,24 @@ public class SpannableBuilder {
|
||||
impl.setSpan(span.what, span.start, span.end, span.flags);
|
||||
}
|
||||
|
||||
// now, let's remove trailing newLines (so small amounts of text are displayed correctly)
|
||||
// @since 1.0.2
|
||||
|
||||
final int length = impl.length();
|
||||
if (length > 0) {
|
||||
int amount = 0;
|
||||
for (int i = length - 1; i >=0 ; i--) {
|
||||
if (Character.isWhitespace(impl.charAt(i))) {
|
||||
amount += 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (amount > 0) {
|
||||
impl.replace(length - amount, length, "");
|
||||
}
|
||||
}
|
||||
|
||||
return impl;
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,9 @@ public class HeadingSpan extends MetricAffectingSpan implements LeadingMarginSpa
|
||||
theme.applyHeadingBreakStyle(paint);
|
||||
|
||||
final float height = paint.getStrokeWidth();
|
||||
|
||||
if (height > .0F) {
|
||||
|
||||
final int b = (int) (bottom - height + .5F);
|
||||
|
||||
final int left;
|
||||
@ -70,3 +73,4 @@ public class HeadingSpan extends MetricAffectingSpan implements LeadingMarginSpa
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ public class SpannableTheme {
|
||||
}
|
||||
paint.setColor(color);
|
||||
paint.setStyle(Paint.Style.FILL);
|
||||
if (headingBreakHeight != 0) {
|
||||
if (headingBreakHeight >= 0) {
|
||||
//noinspection SuspiciousNameCombination
|
||||
paint.setStrokeWidth(headingBreakHeight);
|
||||
}
|
||||
@ -374,7 +374,7 @@ public class SpannableTheme {
|
||||
paint.setColor(color);
|
||||
paint.setStyle(Paint.Style.FILL);
|
||||
|
||||
if (thematicBreakHeight != 0) {
|
||||
if (thematicBreakHeight >= 0) {
|
||||
//noinspection SuspiciousNameCombination
|
||||
paint.setStrokeWidth(thematicBreakHeight);
|
||||
}
|
||||
@ -384,6 +384,16 @@ public class SpannableTheme {
|
||||
return tableCellPadding;
|
||||
}
|
||||
|
||||
public int tableBorderWidth(@NonNull Paint paint) {
|
||||
final int out;
|
||||
if (tableBorderWidth == -1) {
|
||||
out = (int) (paint.getStrokeWidth() + .5F);
|
||||
} else {
|
||||
out = tableBorderWidth;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public void applyTableBorderStyle(@NonNull Paint paint) {
|
||||
|
||||
final int color;
|
||||
@ -393,10 +403,6 @@ public class SpannableTheme {
|
||||
color = tableBorderColor;
|
||||
}
|
||||
|
||||
if (tableBorderWidth != 0) {
|
||||
paint.setStrokeWidth(tableBorderWidth);
|
||||
}
|
||||
|
||||
paint.setColor(color);
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
}
|
||||
@ -435,14 +441,14 @@ public class SpannableTheme {
|
||||
private int codeMultilineMargin;
|
||||
private Typeface codeTypeface;
|
||||
private int codeTextSize;
|
||||
private int headingBreakHeight;
|
||||
private int headingBreakHeight = -1;
|
||||
private int headingBreakColor;
|
||||
private float scriptTextSizeRatio;
|
||||
private int thematicBreakColor;
|
||||
private int thematicBreakHeight;
|
||||
private int thematicBreakHeight = -1;
|
||||
private int tableCellPadding;
|
||||
private int tableBorderColor;
|
||||
private int tableBorderWidth;
|
||||
private int tableBorderWidth = -1;
|
||||
private int tableOddRowBackgroundColor;
|
||||
private Drawable taskListDrawable;
|
||||
|
||||
|
@ -169,10 +169,14 @@ public class TableRowSpan extends ReplacementSpan {
|
||||
}
|
||||
}
|
||||
|
||||
rect.set(0, 0, w, bottom - top);
|
||||
|
||||
theme.applyTableBorderStyle(this.paint);
|
||||
|
||||
final int borderWidth = theme.tableBorderWidth(paint);
|
||||
final boolean drawBorder = borderWidth > 0;
|
||||
if (drawBorder) {
|
||||
rect.set(0, 0, w, bottom - top);
|
||||
}
|
||||
|
||||
StaticLayout layout;
|
||||
for (int i = 0; i < size; i++) {
|
||||
layout = layouts.get(i);
|
||||
@ -180,7 +184,10 @@ public class TableRowSpan extends ReplacementSpan {
|
||||
try {
|
||||
|
||||
canvas.translate(x + (i * w), top - heightDiff);
|
||||
|
||||
if (drawBorder) {
|
||||
canvas.drawRect(rect, this.paint);
|
||||
}
|
||||
|
||||
canvas.translate(padding, padding + heightDiff);
|
||||
layout.draw(canvas);
|
||||
|
Loading…
x
Reference in New Issue
Block a user