Open shivakumars opened 4 years ago
Hello @shivakumars !
Please share the code that you use to render markdown
Sure,
val markwon = Markwon.create(this@MainActivity)
val mdEditor = MarkwonEditor.create(markwon)
editor.addTextChangedListener(MarkwonEditorTextWatcher.withPreRender(
mdEditor,
Executors.newCachedThreadPool(),
editor))
Please refer to the documentation of how to additionally add styling whilst editing
Firstly, thank you for pointing me with the right way. I followed the document and now I could see the format is applied.
But When a markdown is typed as follows, "**b**" "**c**"
The second line is not getting formatted.
The above image from the APK built from the sample module in this repo.
I debugged the issue and at handleMarkdownSpan
, the span start I get for "**b**\n**c**" is 8. So the matcher tries to match "*c**". Please correct me if I'm wrong.
Hello @shivakumars !
This actually is a bug. I've looked at it briefly and it seems to be caused by a single new-line in markdown to be treated as a space. Text diffing fails (it considers **\n**
to be replaced with a
) and thus second span receives wrong position. This can be solved with markdown treating soft breaks as new lines. For example:
final Markwon markwon = Markwon.builder(this)
/* your other plugins */
.usePlugin(SoftBreakAddsNewLinePlugin.create())
.build();
Of cause this would mean that in display/preview mode this markdown should also treat soft breaks as new lines, otherwise content will be different
It actually is not a bug but a requirement for editor - soft breaks must be rendered as new lines (no matter how they are going to be rendered). Let me think how to seamlessly integrate it into editor
Here are my dependencies,
layout XML,
Am I doing something wrong...