Giter Club home page Giter Club logo

rxmarkdown's Introduction

RxMarkdown

License API Android Arsenal

RxMarkdown is an Android library that helps to display simple markdown text in android.widget.EditText or android.widget.TextView, at same time, it supports code high light .

It is backed by RxJava, implementing complicated APIs as handy reactive observables.

中文:README-zh-rCN.md

Demo apk : DOWNLOAD

QR Code : CLICK

Change Log : SEE

RxMarkdown.gif

Gradle

implementation 'com.yydcdut:markdown-processor:0.1.3'
implementation 'com.yydcdut:rxmarkdown-wrapper:0.1.3'

Or if you don't want to use RxJava, you can simply refer to markdown-processor :

implementation 'com.yydcdut:markdown-processor:0.1.3'

Support Syntax

RxMarkdown now provides 2 factories to parse markdown, TextFactory and EditFactory .

TextFactory : Supports most of the markdown syntax,but it will destroy the integrity of the content. So, it applies to render in TextView .

EditFactory : Supports some syntax,and it won't destroy the integrity of the content, the parsing speed is faster than TextFactory , So, it applies to real-time preview in EditText .

TextFactory

  • Header # / ## / ### / #### / ##### / #######
  • BlockQuote >
  • Nested BlockQuote > >
  • Emphasis Bold ** __
  • Emphasis Italic * _
  • Nested Bold && Italic
  • Ordered List 1.
  • Nested Ordered List
  • UnOrdered List * / + / -
  • Nested UnOrdered List
  • Image ![]()
  • Hyper Link []()
  • Inline Code
  • Code
  • Backslash \
  • Horizontal Rules *** / ***** / --- / -----------------
  • Strike Through ~~
  • Footnote [^]
  • Todo - [ ] / - [x]
  • Table | Table | Table |
  • code high light

Other Syntax

  • Center Align []

EditFactory

  • Header # / ## / ### / #### / ##### / #######
  • BlockQuote >
  • Nested BlockQuote > >
  • Emphasis Bold ** __
  • Emphasis Italic * _
  • Nested Bold && Italic
  • Ordered List 1.
  • Nested Ordered List
  • UnOrdered List * / + / -
  • Nested UnOrdered List
  • Image ![]()
  • Hyper Link []()
  • Inline Code
  • Code
  • Backslash \
  • Horizontal Rules *** / ***** / --- / -----------------
  • Strike Through ~~
  • Footnote [^]
  • Todo - [ ] / - [x]
  • Table | Table | Table |
  • code high light

Other Syntax

  • Center Align []

HtmlFactory

//TODO

Quick Start

Setup

implementation 'com.yydcdut:markdown-processor:0.1.3'
implementation 'com.yydcdut:rxmarkdown-wrapper:0.1.3'

implementation 'io.reactivex:rxandroid:1.2.0'
implementation 'io.reactivex:rxjava:1.1.5'

Configuration

All options in Configuration builder are optional. Use only those you really want to customize (RxMDConfiguration#Builder and MarkdownConfiguration#Builder are the same usage):

RxMDConfiguration rxMDConfiguration = new RxMDConfiguration.Builder(context)
        .setHeader1RelativeSize(1.6f)//default relative size of header1
        .setHeader2RelativeSize(1.5f)//default relative size of header2
        .setHeader3RelativeSize(1.4f)//default relative size of header3
        .setHeader4RelativeSize(1.3f)//default relative size of header4
        .setHeader5RelativeSize(1.2f)//default relative size of header5
        .setHeader6RelativeSize(1.1f)//default relative size of header6
        .setBlockQuotesLineColor(Color.LTGRAY)//default color of block quotes line
        .setBlockQuotesBgColor(Color.LTGRAY, Color.RED, Color.BLUE)//default color of block quotes background and nested background
        .setBlockQuotesRelativeSize(Color.LTGRAY, Color.RED, Color.BLUE)//default relative size of block quotes text size
        .setHorizontalRulesColor(Color.LTGRAY)//default color of horizontal rules's background
        .setHorizontalRulesHeight(Color.LTGRAY)//default height of horizontal rules
        .setCodeFontColor(Color.LTGRAY)//default color of inline code's font
        .setCodeBgColor(Color.LTGRAY)//default color of inline code's background
        .setTheme(new ThemeDefault())//default code block theme
        .setTodoColor(Color.DKGRAY)//default color of todo
        .setTodoDoneColor(Color.DKGRAY)//default color of done
        .setOnTodoClickCallback(new OnTodoClickCallback() {//todo or done click callback
        	@Override
        	public CharSequence onTodoClicked(View view, String line) {
                return textView.getText();
        	}
        })
        .setUnOrderListColor(Color.BLACK)//default color of unorder list
        .setLinkFontColor(Color.RED)//default color of link text
        .showLinkUnderline(true)//default value of whether displays link underline
        .setOnLinkClickCallback(new OnLinkClickCallback() {//link click callback
        	@Override
        	public void onLinkClicked(View view, String link) {
        	}
        })
        .setRxMDImageLoader(new DefaultLoader(context))//default image loader
        .setDefaultImageSize(100, 100)//default image width & height
        .build();

Rx Usage

  • EditText , live preview :

    RxMarkdown.live(rxMDEditText)
            .config(rxMDConfiguration)
            .factory(EditFactory.create())
            .intoObservable()
            .subscribe();
  • cancel real-time preview :

    rxMDEditText.clear();
  • TextView render :

    RxMarkdown.with(content, this)
            .config(rxMDConfiguration)
            .factory(TextFactory.create())
            .intoObservable()
            .subscribeOn(Schedulers.computation())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Subscriber<CharSequence>() {
                @Override
                public void onCompleted() {}
    
                @Override
                public void onError(Throwable e) {}
    
                @Override
                public void onNext(CharSequence charSequence) {
                    rxMDTextView.setText(charSequence, TextView.BufferType.SPANNABLE);
                }
            });

non-Rx Usage

  • EditText , live preview :

    MarkdownProcessor markdownProcessor = new MarkdownProcessor(this);
    markdownProcessor.config(markdownConfiguration);
    markdownProcessor.factory(EditFactory.create());
    markdownProcessor.live(markdownEditText);
  • cancel real-time preview :

    markdownEditText.clear();
  • TextView render :

    MarkdownProcessor markdownProcessor = new MarkdownProcessor(this);
    markdownProcessor.factory(TextFactory.create());
    markdownProcessor.config(markdownConfiguration);
    textView.setText(markdownProcessor.parse(content));

Note

RxMDImageLoader

  • Acceptable URIs examples

    "http://web.com/image.png" // from Web
    "file:///mnt/sdcard/image.png" // from SD card
    "assets://image.png" // from assets
    "drawable://" + R.drawable.img // from drawables (non-9patch images)
  • Custom image loader

    public class MDLoader implements RxMDImageLoader {
        @Nullable
        @Override
        public byte[] loadSync(@NonNull String url) throws IOException {
            return new byte[0];
        }
    }

Image Size

The image of 320 pixels width and 320 pixels height will display on the screen :

![image](http://web.com/image.png/320$320)

Code HighLight Theme

The lib supports some themes, ThemeDefault, ThemeDesert, ThemeSonsOfObsidian and ThemeSunburst.

ThemeDefault ThemeDesert ThemeSonsOfObsidian ThemeSunburst
ThemeDefault ThemeDesert ThemeSonsOfObsidian ThemeSunburst

You can implement the interface Theme to realize your own theme.

public class CodeHighLightTheme implements Theme {

    @Override
    public int getBackgroundColor() {//background color
        return 0xffcccccc;
    }

    @Override
    public int getTypeColor() {//color for type
        return 0xff660066;
    }

    @Override
    public int getKeyWordColor() {//color for keyword
        return 0xff000088;
    }

    @Override
    public int getLiteralColor() {//color for literal
        return 0xff006666;
    }

    @Override
    public int getCommentColor() {//color for comment
        return 0xff880000;
    }

    @Override
    public int getStringColor() {//color for string
        return 0xff008800;
    }

    @Override
    public int getPunctuationColor() {//color for punctuation
        return 0xff666600;
    }

    @Override
    public int getTagColor() {//color for html/xml tag
        return 0xff000088;
    }

    @Override
    public int getPlainTextColor() {//color for a plain text
        return 0xff000000;
    }

    @Override
    public int getDecimalColor() {//color for a markup declaration such as a DOCTYPE
        return 0xff000000;
    }

    @Override
    public int getAttributeNameColor() {//color for html/xml attribute name
        return 0xff660066;
    }

    @Override
    public int getAttributeValueColor() {//color for html/xml attribute value
        return 0xff008800;
    }

    @Override
    public int getOpnColor() {//color for opn
        return 0xff666600;
    }

    @Override
    public int getCloColor() {//color for clo
        return 0xff666600;
    }

    @Override
    public int getVarColor() {//color for var
        return 0xff660066;
    }

    @Override
    public int getFunColor() {//color for fun
        return Color.RED;
    }

    @Override
    public int getNocodeColor() {color for nocode
        return 0xff000000;
    }
}

License

Copyright 2016 yydcdut

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

rxmarkdown's People

Contributors

korelstar avatar tshinezheng avatar yydcdut avatar ztrap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rxmarkdown's Issues

horizontal ruler (---) is too fat

As a user i would like to have the option to configure the height of a horizontal ruler to enhance the design.
Alternativeley this issue would be solved for me if the height would be decreased hardcoded to 1px.

The library doesn't remove the initial spaces

Hi!!

First of all, great work!

I realised that the library doesn't print spans correctly if there are spaces after line breaks. If you work with a rich editor nowadays, it removes the spaces and formats the code. Should this library contain this behaviour? I don't know if it's a bug or a feature.

Thanks.

Styling not applied when restarting app with prefilled EditText

Hi! First of all: Awesome library, saves a lot of time!

I use this in combination with an EditText which saves it's content and re-inserts it when you restart the app. Like copy and paste. It works like a charm, but with some markdown formatting options, the text doesn't get styled when the text is put back into the EditText.

Bold and italics with underscores

Currently the library will properly display Bold or italics only if asterisks syntax is used:

*italics* and **bold**

It would be nice if the library would display also bold and italics created using underscores syntax:
_italics_ and __bold__

EditText: continue lists with the used sign

Given you are start edit a given Markdown snippet with a list using the --sign
When you press Enter to start a new line / new list item
Then the library should start the new list item with the sign that has been used in the list before.

Current behavior:

*-sign is used always for new list items
unbenannt

IndexOutOfBoundsException

I'm sorry, i do not know how to reproduce this, but there are many crashes on my app that have this stacktrace in common:

java.lang.IndexOutOfBoundsException:
  at com.yydcdut.rxmarkdown.live.CodeLive.onTextChanged (CodeLive.java:71)
  at com.yydcdut.rxmarkdown.live.LivePrepare.onTextChanged (LivePrepare.java:81)
  at com.yydcdut.rxmarkdown.RxMDEditText.onTextChanged4Controller (RxMDEditText.java:253)
  at com.yydcdut.rxmarkdown.RxMDEditText.access$700 (RxMDEditText.java:45)
  at com.yydcdut.rxmarkdown.RxMDEditText$EditTextWatcher.onTextChanged (RxMDEditText.java:177)

Auto-link URLs

It would be nice, if for any URL, a link is created automatically.

For RxMDEditText, every URL should be auto-linked (regardless if it is inside of a []() or not). However, there will be a conflict between positioning the cursor by clicking and open the link by clicking. Therefore, I would propose to open the link by long-clicking (maybe using an additional menu), so that normal clicking still performs cursor positioning.

For RxMDTextView, links outside of a []() should be linked. Here, opening the link can be called by normal clicking.

Bug: Windows line-breaks lead to Exception

I have a RxMDEditText (from release 0.1.1-beta) pre-filled with the following content:

# Test
1. Test
- Test

If the line-breaks are windows-style (\r\n), then the formatting doesn't work and when I try to change the text of the note, the following exception occurs:

java.lang.StringIndexOutOfBoundsException: length=23; regionStart=-1; regionLength=7
    at java.lang.AbstractStringBuilder.startEndAndLength(AbstractStringBuilder.java:211)
    at java.lang.AbstractStringBuilder.replace0(AbstractStringBuilder.java:437)
    at java.lang.StringBuilder.replace(StringBuilder.java:637)
    at com.yydcdut.rxmarkdown.syntax.edit.OrderListSyntax.findTrueIndex(OrderListSyntax.java:133)
    at com.yydcdut.rxmarkdown.syntax.edit.OrderListSyntax.findTrueIndex(OrderListSyntax.java:134)
    at com.yydcdut.rxmarkdown.syntax.edit.OrderListSyntax.format(OrderListSyntax.java:58)
    at com.yydcdut.rxmarkdown.syntax.edit.EditFactory.parse(EditFactory.java:168)
    at com.yydcdut.rxmarkdown.RxMDEditText.format(RxMDEditText.java:287)
    at com.yydcdut.rxmarkdown.RxMDEditText.access$800(RxMDEditText.java:45)
    at com.yydcdut.rxmarkdown.RxMDEditText$EditTextWatcher.afterTextChanged(RxMDEditText.java:186)
    at android.widget.TextView.sendAfterTextChanged(TextView.java:8004)
    at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:10165)
    at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:1043)
    at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:560)
    at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:492)
    at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:491)
    at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:685)
    at android.view.inputmethod.BaseInputConnection.commitText(BaseInputConnection.java:197)
    at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:184)
    at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:286)
    at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5461)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Please note: if the line-breaks are unix-style (\n), then everything is fine.

CodeBlock misplaces cursor

While deleting Codeblock, the cursor moves to position 0.

```
Hi, I am CodeBlock
```
something

While deleting something cursor moves to ```[here]
and again back press changes cursor position to starting of the editor.

List should be interconvertible

Ordered List and Unordered list should be interconvertible.

1. something
2. here[cursor]

now if I select Unordered list, it should change to

* something
* here[cursor]

IndexOutOfBoundsException caused by BlockQuotesController

I'm getting a reproducable IndexOutOfBoundsException caused by BlockQuotesController. Way to reproduce:

Type Test into a RxMDEditText. Then press 4 times backspace in order to remove all characters. On removing the third character, the following exception is thrown:

java.lang.IndexOutOfBoundsException: getChars (1 ... 2) ends beyond length 1
    at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1090)
    at android.text.SpannableStringBuilder.getChars(SpannableStringBuilder.java:972)
    at android.text.TextUtils.getChars(TextUtils.java:87)
    at android.text.SpannableStringBuilder.<init>(SpannableStringBuilder.java:65)
    at android.text.SpannableStringBuilder.subSequence(SpannableStringBuilder.java:964)
    at com.yydcdut.rxmarkdown.edit.BlockQuotesController.onTextChanged(BlockQuotesController.java:74)
    at com.yydcdut.rxmarkdown.RxMDEditText.onTextChanged4Controller(RxMDEditText.java:265)
    at com.yydcdut.rxmarkdown.RxMDEditText.access$800(RxMDEditText.java:54)
    at com.yydcdut.rxmarkdown.RxMDEditText$1.onTextChanged(RxMDEditText.java:186)
    at android.widget.TextView.sendOnTextChanged(TextView.java:7991)
    at android.widget.TextView.handleTextChanged(TextView.java:8053)
    at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:10157)
    at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:1033)
    at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:559)
    at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:492)
    at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:491)
    at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:685)
    at android.view.inputmethod.BaseInputConnection.setComposingText(BaseInputConnection.java:445)
    at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:340)
    at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

HTTPS urls for images

Hi!
It will be really nice if you can add HTTPS url for images (not only HTTP like now).
Thanks!

IndexOutOfBoundsException: getChars (59 ... 60) ends beyond length 59

this error happen when i type text in edittext and then I delet the text

java.lang.IndexOutOfBoundsException: getChars (59 ... 60) ends beyond length 59 at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1018) at android.text.SpannableStringBuilder.getChars(SpannableStringBuilder.java:915) at android.text.TextUtils.getChars(TextUtils.java:81) at android.text.SpannableStringBuilder.<init>(SpannableStringBuilder.java:64) at android.text.SpannableStringBuilder.subSequence(SpannableStringBuilder.java:907) at com.yydcdut.rxmarkdown.edit.BlockQuotesController.onTextChanged(BlockQuotesController.java:74) at com.yydcdut.rxmarkdown.RxMDEditText.onTextChanged4Controller(RxMDEditText.java:291) at com.yydcdut.rxmarkdown.RxMDEditText.access$900(RxMDEditText.java:54) at com.yydcdut.rxmarkdown.RxMDEditText$EditTextWatcher.onTextChanged(RxMDEditText.java:212) at android.widget.TextView.sendOnTextChanged(TextView.java:7704) at android.widget.TextView.handleTextChanged(TextView.java:7764) at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:9481) at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:964) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:515) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:454) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:33) at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:685) at android.view.inputmethod.BaseInputConnection.setComposingText(BaseInputConnection.java:445) at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:340) at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5319) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1016) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)

Trouble with links

I'm trying to render and react to links in text view. As far as I see links don't react, even with specifying a listener for links is not triggered. Is this an intended behaviour or am I doing something wrong?

Thank you.

Backslash

Hi, this string with backslash \. is shown as \.; Or 120\-140 is shown as 120\-140; I think they must be . and 120-140

Version: 0.1.2
Android emulator: v8.0
SDK 27

Sublists broken?

Hi!

I'm a nextcloud and nextcloud-notes user (which is using this library) and I've noticed a problem with sublists / nested lists. I've created a list in the nextcloud web interface (using Firefox on Linux) but it's not correctly displayed in the notes app. I've already reported the issue here (including screenshots):

nextcloud/notes-android#232

I tried some workarounds (like increasing indentation) but it didn't help (I'm not a markdown expert, though). Can you have a look at it please?

Demo 卡顿

RxMDEditText内, 上下滑动卡顿,没有了滑动惯性

Some style issues

Hi @yydcdut,
first of all: thanks for this great lib! I am planning to use it in the Nextcloud Notes-app.
Currently i am struggling with some style issues we experienced while testing.
Maybe these style issues could be fixed or at least a configuration option could be provided by you for these?

  • 1.) Headings in TextView have a padding or margin on the left side: (fixed in #10)

hadings

Expected behavior: There is no padding or margin or there is a configuration to disable it or set it to zero.

  • 2.) Very long quotes (> Text) that do not fit into a single line crash on the grey border (TextView && EditView)

quote

Expected behavior: Even if the line breaks because it does not fit into a single row the padding/margin on the left side should be equal to the first line.
Bonus: Make the padding configurable (i personally would like to have some more padding here)

提问

我想问个问题

MDImageSpan源码中, 在构造函数内根据URL传入的参数初始化了图片的width and height, 需求等请求完成图片后,自己去计算高度和宽度。因为我的需求是不需要用户在URL中设置图片大小,总是让图片填充屏幕宽度,高度适应,按比例缩放,我该在哪里做修改呢?

Gives error in List

When pressing Enter in Ordered/Unordered List with no text, it should delete List. But its giving
java.lang.StringIndexOutOfBoundsException

This happens when I do this at the end of my Editor.

Workflow proposals

Dear @yydcdut,

please do not misunderstood this request as critic. For the outstanding people it would be very helpful to

  • tag your versions with the git tagging system (e. g. git tag 0.1.0)
  • write all your issues in english

Outstanding people can not help implement features or fix bugs, if they do not understand what's the issue.

Regards

Image size

The image loaded don't keep their ratio.
We can only set fixe image size.
Can be very nice to have wrap_content/match_parent and scaleType for the image.

Thanks

Pasting images

Hello, im trying to use the edittext widget, i need users to be able to past images (copied from webpage in chrome) into it but the images are pasted as a green/azure square with the DefaultLoader. Is there any way to get the images correctly when pasted?

EditText: color all markdown symbols in gray

Coloring all markdown symbols for which the respective formatting was applied (especially # in headings, */_ in emphasizing, > in quotes) would

  • increase readability of the text,
  • allows to concentrate on the content,
  • puts the technical aspects of markdown into the background
  • and still allows for the editing of these symbols.

Here is an example, where this is used:
Screenshot of Nextcloud Notes
However, I don't see that this is useful for lists. But for headings, emphasizing and quotes, this would be very nice.

Stop creating new list items on multiple Enter-presses

Given you edited a list and want to continue with a normal paragraph. You press Enter, a new list item is generated (using a *-sign).
When you do not enter anything but press enter again
Then the empty list template (The *-sign) should be removed and a empty line should be inserted to enable the user to go ahead with a normal paragraph.

Current behavior
If you press enter x times, there are generated x new empty list items

unbenannt

ArrayIndexOutOfBoundsException

java.lang.ArrayIndexOutOfBoundsException: length=6; index=6
        at com.yydcdut.markdown.syntax.text.ImageSyntax.contains(ImageSyntax.java:97)
        at com.yydcdut.markdown.syntax.text.ImageSyntax.isMatch(ImageSyntax.java:54)
        at com.yydcdut.markdown.syntax.text.TextSyntaxAdapter.isMatch(TextSyntaxAdapter.java:57)
        at com.yydcdut.markdown.chain.MultiSyntaxChain.handleSyntax(MultiSyntaxChain.java:45)
        at com.yydcdut.markdown.chain.SyntaxMultiChains.handleSyntax(SyntaxMultiChains.java:53)
        at com.yydcdut.markdown.chain.SyntaxDoElseChain.handleSyntax(SyntaxDoElseChain.java:58)
        at com.yydcdut.markdown.chain.SyntaxDoElseChain.handleSyntax(SyntaxDoElseChain.java:58)
        at com.yydcdut.markdown.chain.SyntaxDoElseChain.handleSyntax(SyntaxDoElseChain.java:58)
        at com.yydcdut.markdown.chain.SyntaxChain.handleSyntax(SyntaxChain.java:49)
        at com.yydcdut.markdown.syntax.text.TextFactory.parseByLine(TextFactory.java:210)
        at com.yydcdut.markdown.syntax.text.TextFactory.parse(TextFactory.java:193)
        at com.yydcdut.markdown.MarkdownProcessor.parse(MarkdownProcessor.java:32)

Version:0.1.2-alpha
Android emulator: v8.0
SDK 27

Code:

val markdownProcessor = MarkdownProcessor(context)
markdownProcessor.factory(TextFactory.create())
//markdownProcessor.config(MarkdownConfiguration.Builder(context!!).build())
text_content.text = markdownProcessor.parse("Abc \\!")

URLSpans don't work properly

If we got:

This is another [link](http://deathstar-qa.herokuapp.com/reporting) please

It's not printing the url span properly, it just prints the text.

I've checked the code, and also I've been retrieving the spans, and it seems the span is there
URLSpan[] spans = stringBuilder.getSpans(0, charSequence.length(), URLSpan.class);
but it's not being drawn properly:

screenshot_20170403-163147

line-height (space between the lines) is too small

As a user i would like to have the option to configure the line-height to enhance readability.
Alternativeley this issue would be solved for me if the line-height would be increased hardcoded by 50%.

Rendering of **Text**

The Library is really working well and appreciate its responsiveness compared to other MarkDown renders I've interacted with. But, I have encountered problem while rendering bold text of the form Text

TodoClickCallback should return lineNumber instead of content

Multiple lines might contain the same content. Therefore, one can not safely replace the checked/unchecked-checkbox.

The solution would be to provide the lineNumber instead od the lineContent in the callback.

Example:

.setOnTodoClickCallback(new OnTodoClickCallback() {//todo or done click callback
@Override
public CharSequence onTodoClicked(View view, int lineNumber) {
return noteContent.getText();
}```

Demo Edit and Show 在结尾处输入 # 空格崩溃

03-14 09:45:54.424 10100-10100/com.yydcdut.markdowndemo E/InputEventSender: Exception dispatching finished signal.
03-14 09:45:54.424 10100-10100/com.yydcdut.markdowndemo E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback
03-14 09:45:54.424 10100-10100/com.yydcdut.markdowndemo E/MessageQueue-JNI: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
                                                                                at java.lang.AbstractStringBuilder.replace(AbstractStringBuilder.java:820)
                                                                                at java.lang.StringBuilder.replace(StringBuilder.java:267)
                                                                                at com.yydcdut.rxmarkdown.grammar.edit.HeaderGrammar.format(HeaderGrammar.java:123)
                                                                                at com.yydcdut.rxmarkdown.edit.HeaderController.format(HeaderController.java:93)
                                                                                at com.yydcdut.rxmarkdown.edit.HeaderController.onTextChanged(HeaderController.java:81)
                                                                                at com.yydcdut.rxmarkdown.RxMDEditText.onTextChanged4Controller(RxMDEditText.java:291)
                                                                                at com.yydcdut.rxmarkdown.RxMDEditText.access$900(RxMDEditText.java:54)
                                                                                at com.yydcdut.rxmarkdown.RxMDEditText$EditTextWatcher.onTextChanged(RxMDEditText.java:212)
                                                                                at android.widget.TextView.sendOnTextChanged(TextView.java:8187)
                                                                                at android.widget.TextView.handleTextChanged(TextView.java:8249)
                                                                                at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:10371)
                                                                                at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:1208)
                                                                                at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:578)
                                                                                at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:509)
                                                                                at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:508)
                                                                                at android.text.method.QwertyKeyListener.onKeyDown(QwertyKeyListener.java:223)
                                                                                at android.text.method.TextKeyListener.onKeyDown(TextKeyListener.java:136)
                                                                                at android.widget.TextView.doKeyDown(TextView.java:6285)
                                                                                at android.widget.TextView.onKeyDown(TextView.java:6075)
                                                                                at android.view.KeyEvent.dispatch(KeyEvent.java:2688)
                                                                                at android.view.View.dispatchKeyEvent(View.java:9960)
                                                                                at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1630)
                                                                                at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1630)
                                                                                at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1630)
                                                                                at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1630)
                                                                                at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1630)
                                                                                at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1630)
                                                                                at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1630)
                                                                                at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:405)
                                                                                at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1798)
                                                                                at android.app.Activity.dispatchKeyEvent(Activity.java:3021)
                                                                                at android.support.v7.internal.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:49)
                                                                                at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:265)
                                                                                at android.support.v7.internal.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:49)
                                                                                at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:319)
                                                                                at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4331)
                                                                                at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4302)
                                                                                at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3853)
                                                                                at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3906)
                                                                                at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3872)
                                                                                at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3999)
                                                                                at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3880)
                                                                                at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4056)
                                                                                at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3853)
                                                                                at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3906)
                                                                                at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3872)
                                                                                at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3880)
                                                                                at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3853)
                                                                                at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3906)
                                                                                at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3872)
                                                                                at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4032)
                                                                            	at android.view.ViewRootImpl$ImeInputStage.onFinishedIn

看了下,有点费解

Markdown gets not rendered in RxMDTextView when setting another text

I have a strange problem: I have a RxMDTextView and set the content via setContent(text). This works perfectly.

But when i am trying to apply another content (I have a synchronisation callback which gives me a new content snippet that i want to apply) i am calling again setContent(newText). It sets the text correctly, but it does not get parsed.

Instead it looks like this:

device-2018-08-24-144009

If you want to have a look into the code: This is where i tried it: https://github.com/stefan-niedermann/nextcloud-notes/pull/450/files#diff-90525f4d9cdb0df716cb3648b662ac45R119

Next steps of development?

Hey there!

I just would like to know your plan/schedule with this library.

  • Do you intend to get out of beta (and when roughly) ?
  • When do you plan to release 0.1.1 ?

Greetings,
djuelg

Check-Boxes in every line-start of long paragraph

I use Android App "Nextcloud Notes" (https://github.com/stefan-niedermann/nextcloud-notes).

Problem:

In view-mode you get a checkbox at every line's start within a long paragraph when viewing on small devices which force line-breaks.

start snip

Test ToDo

  • lore ipsum infernalis lore ipsum infernalis lore ipsum infernalis

stop snip

Steps to reproduce the issue:

Android version:** 7.1.2 LineageOs
Device: Sony Xperia Z
System language: German
App version: 0.1.21
App source: F-Droid

  • open the app
  • click on a note
  • use the edit button
  • insert long text with checkbox

Image markdown

Image formated like this doesn't work
![](https://tctechcrunch2011.files.wordpress.com/2015/05/dave-mcclure41.jpg?w=738)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.