Fix links in ext-table
This commit is contained in:
parent
f47124a2ac
commit
33f0dcb841
@ -125,10 +125,6 @@ public class TablePlugin extends AbstractMarkwonPlugin {
|
||||
|
||||
visitor.visitChildren(tableBlock);
|
||||
|
||||
// if (visitor.hasNext(tableBlock)) {
|
||||
// visitor.ensureNewLine();
|
||||
// visitor.forceNewLine();
|
||||
// }
|
||||
visitor.blockEnd(tableBlock);
|
||||
}
|
||||
})
|
||||
|
@ -143,7 +143,13 @@ public class TableRowSpan extends ReplacementSpan {
|
||||
|
||||
if (recreateLayouts(canvas.getWidth())) {
|
||||
width = canvas.getWidth();
|
||||
textPaint.set(paint);
|
||||
// @since $nap; it's important to cast to TextPaint in order to display links, etc
|
||||
if (paint instanceof TextPaint) {
|
||||
// there must be a reason why this method receives Paint instead of TextPaint...
|
||||
textPaint.set((TextPaint) paint);
|
||||
} else {
|
||||
textPaint.set(paint);
|
||||
}
|
||||
makeNewLayouts();
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
<activity android:name=".tasklist.TaskListActivity" />
|
||||
<activity android:name=".images.ImagesActivity" />
|
||||
<activity android:name=".notification.NotificationActivity" />
|
||||
<activity android:name=".table.TableActivity" />
|
||||
|
||||
</application>
|
||||
|
||||
|
@ -32,6 +32,7 @@ import io.noties.markwon.sample.notification.NotificationActivity;
|
||||
import io.noties.markwon.sample.precomputed.PrecomputedActivity;
|
||||
import io.noties.markwon.sample.recycler.RecyclerActivity;
|
||||
import io.noties.markwon.sample.simpleext.SimpleExtActivity;
|
||||
import io.noties.markwon.sample.table.TableActivity;
|
||||
import io.noties.markwon.sample.tasklist.TaskListActivity;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
@ -147,6 +148,10 @@ public class MainActivity extends Activity {
|
||||
activity = NotificationActivity.class;
|
||||
break;
|
||||
|
||||
case TABLE:
|
||||
activity = TableActivity.class;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalStateException("No Activity is associated with sample-item: " + item);
|
||||
}
|
||||
|
@ -33,7 +33,9 @@ public enum Sample {
|
||||
|
||||
IMAGES(R.string.sample_images),
|
||||
|
||||
REMOTE_VIEWS(R.string.sample_remote_views);
|
||||
REMOTE_VIEWS(R.string.sample_remote_views),
|
||||
|
||||
TABLE(R.string.sample_table);
|
||||
|
||||
private final int textResId;
|
||||
|
||||
|
@ -0,0 +1,57 @@
|
||||
package io.noties.markwon.sample.table;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.ext.tables.TablePlugin;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import io.noties.markwon.sample.ActivityWithMenuOptions;
|
||||
import io.noties.markwon.sample.MenuOptions;
|
||||
import io.noties.markwon.sample.R;
|
||||
|
||||
public class TableActivity extends ActivityWithMenuOptions {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MenuOptions menuOptions() {
|
||||
return MenuOptions.create()
|
||||
.add("tableAndLinkify", this::tableAndLinkify);
|
||||
}
|
||||
|
||||
private TextView textView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_text_view);
|
||||
textView = findViewById(R.id.text_view);
|
||||
|
||||
tableAndLinkify();
|
||||
}
|
||||
|
||||
private void tableAndLinkify() {
|
||||
final String md = "" +
|
||||
"| HEADER | HEADER | HEADER |\n" +
|
||||
"|:----:|:----:|:----:|\n" +
|
||||
"| 测试 | 测试 | 测试 |\n" +
|
||||
"| 测试 | 测试 | 测测测12345试测试测试 |\n" +
|
||||
"| 测试 | 测试 | 123445 |\n" +
|
||||
"| 测试 | 测试 | (650) 555-1212 |\n" +
|
||||
"| 测试 | 测试 | [link](#) |\n" +
|
||||
"\n" +
|
||||
"测试\n" +
|
||||
"\n" +
|
||||
"[https://www.baidu.com](https://www.baidu.com)";
|
||||
|
||||
final Markwon markwon = Markwon.builder(this)
|
||||
.usePlugin(LinkifyPlugin.create())
|
||||
.usePlugin(TablePlugin.create(this))
|
||||
.build();
|
||||
|
||||
markwon.setMarkdown(textView, md);
|
||||
}
|
||||
}
|
@ -37,4 +37,5 @@
|
||||
|
||||
<string name="sample_remote_views"># \# Notification\n\nExample usage in notifications and other remote views</string>
|
||||
|
||||
<string name="sample_table"># \# Table\n\nUsage of tables in a `TextView`</string>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user