Commit 53ca4a75 by 胡学良

编译器支持表格功能

parent ae532045
......@@ -13,8 +13,10 @@ import java.util.List;
import java.util.concurrent.Executors;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.editor.MarkwonEditor;
import io.noties.markwon.editor.MarkwonEditorTextWatcher;
import io.noties.markwon.ext.tables.TablePlugin;
import io.noties.markwon.movement.MovementMethodPlugin;
/**
......@@ -64,8 +66,11 @@ public class MarkdownEditorActivity extends AppCompatActivity {
binding.toolbar.addItemDecoration(new SpacesItemDecoration(50));
//通过Markwon实现Markdown的实时预览
Markwon.builder(this)
.usePlugin(MovementMethodPlugin.create(ScrollingMovementMethod.getInstance()));
// List<MarkwonPlugin> list = new ArrayList<>();
// list.add(MovementMethodPlugin.create(ScrollingMovementMethod.getInstance()));
// list.add(TablePlugin.create(this));
Markwon.builder(this)
.usePlugin(MovementMethodPlugin.create(ScrollingMovementMethod.getInstance()));
final Markwon markwon = Markwon.create(this);
......
......@@ -8,6 +8,7 @@ import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Spanned;
import android.util.Log;
......@@ -24,6 +25,8 @@ import java.util.ArrayList;
import java.util.List;
import io.noties.markwon.Markwon;
import io.noties.markwon.ext.tables.TablePlugin;
import io.noties.markwon.ext.tables.TableTheme;
/**
* @author 胡学良
......@@ -68,7 +71,17 @@ public class ViewPageActivity extends ActivityGroup {
if (position == 1) {
EditText editText = (EditText) markdownEditorView.findViewById(R.id.markdown_first_edit_text);
String string = editText.getText().toString();
Markwon markwon = Markwon.create(getApplicationContext());
TableTheme tableTheme = TableTheme.emptyBuilder()
.tableBorderColor(Color.RED)
.tableBorderWidth(0)
.tableCellPadding(0)
.tableHeaderRowBackgroundColor(Color.YELLOW)
.tableEvenRowBackgroundColor(Color.GREEN)
.build();
Markwon markwon = Markwon.builder(getApplicationContext())
.usePlugin(TablePlugin.create(tableTheme)).build();
Spanned markdown = markwon.toMarkdown(string);
TextView textView = (TextView) showMarkdownView.findViewById(R.id.txt_markdown);
textView.setText(markdown);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment