Markwon/library-view
Cyrus Bakhtiari-Haftlang 6c25acf29e MarkwonView and MarkwonViewCompat now support styling from XML
The styles that are denoted with an asterisk (*), when defined,
completely override the default spans. The others, when defined, add
spans before the default spans (if any) so that when reversed, take
precedence. Example:

```
<ru.noties.markwon.view.MarkwonViewCompat
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:mv_H2Style="?android:textAppearanceLarge"
    app:mv_markdown="## Opening hours" />
```
In the above case, as ?android:textAppearanceLarge most likely is
resolved into an actual style, the spans that are added by the Markwon-
library (including heading line break) will no be added.

```
<ru.noties.markwon.view.MarkwonViewCompat
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:mv_CodeSpanStyle="?textAppearanceSmall"
    app:mv_markdown="`private int count = 5`" />
```
Conversely, defining a style for mv_CodeSpanStyle will still result in
that background is added to the code text and it will by styled
according to the resolved style of `android:textAppearanceSmall`.

Supported style attributes:
*mv_H1Style
*mv_H2Style
*mv_H3Style
*mv_H4Style
*mv_H5Style
*mv_H6Style

*mv_EmphasisStyle
*mv_StrongEmphasisStyle

mv_BlockQuoteStyle
mv_CodeSpanStyle
mv_MultilineCodeSpanStyle
mv_OrderedListItemStyle
mv_BulletListItemStyle
mv_TaskListItemStyle
mv_TableRowStyle
mv_ParagraphStyle
mv_LinkStyle
2018-08-14 12:54:57 +02:00
..

Markwon View

maven|markwon-view

This is simple library containing 2 views that are able to display markdown:

  • MarkwonView - extends android.view.TextView
  • MarkwonViewCompat - extends android.support.v7.widget.AppCompatTextView

Both of them implement common IMarkwonView interface:

public interface IMarkwonView {

    interface ConfigurationProvider {
        @NonNull
        SpannableConfiguration provide(@NonNull Context context);
    }

    void setConfigurationProvider(@NonNull ConfigurationProvider provider);

    void setMarkdown(@Nullable String markdown);
    void setMarkdown(@Nullable SpannableConfiguration configuration, @Nullable String markdown);

    @Nullable
    String getMarkdown();
}

Both views support layout-preview in Android Studio (with some exceptions, for example, bold span is not rendered due to some limitations of layout preview). These are XML attributes:

app:mv_markdown="string"
app:mv_configurationProvider="string"

mv_markdown accepts a string and represents raw markdown

mv_configurationProvider accepts a string and represents a full class name of a class of type ConfigurationProvider, for example: com.example.my.package.MyConfigurationProvider (this class must have an empty constructor in order to be instantiated via reflection).

Please note that those views parse markdown in main thread, so their usage must be for relatively small markdown portions only