Android markdown library (no WebView)

Overview

logo

Markwon

Build

Markwon is a markdown library for Android. It parses markdown following commonmark-spec with the help of amazing commonmark-java library and renders result as Android-native Spannables. No HTML is involved as an intermediate step. No WebView is required. It's extremely fast, feature-rich and extensible.

It gives ability to display markdown in all TextView widgets (TextView, Button, Switch, CheckBox, etc), Toasts and all other places that accept Spanned content. Library provides reasonable defaults to display style of a markdown content but also gives all the means to tweak the appearance if desired. All markdown features listed in commonmark-spec are supported (including support for inlined/block HTML code, markdown tables, images and syntax highlight).

Markwon comes with a sample application. It is a collection of library usages that comes with search and source code for each code sample.

Since version 4.2.0 Markwon comes with an editor to highlight markdown input as user types (for example in EditText).

Installation

stable snapshot

implementation "io.noties.markwon:core:${markwonVersion}"

Full list of available artifacts is present in the install section of the documentation web-site.

Please visit documentation web-site for further reference.

You can find previous version of Markwon in 2.x.x and 3.x.x branches

Supported markdown features:

  • Emphasis (*, _)
  • Strong emphasis (**, __)
  • Strike-through (~~)
  • Headers (#{1,6})
  • Links ([]() && [][])
  • Images
  • Thematic break (---, ***, ___)
  • Quotes & nested quotes (>{1,})
  • Ordered & non-ordered lists & nested ones
  • Inline code
  • Code blocks
  • Tables (with limitations)
  • Syntax highlight
  • LaTeX formulas
  • HTML
    • Emphasis (<i>, <em>, <cite>, <dfn>)
    • Strong emphasis (<b>, <strong>)
    • SuperScript (<sup>)
    • SubScript (<sub>)
    • Underline (<u>, ins)
    • Strike-through (<s>, <strike>, <del>)
    • Link (a)
    • Lists (ul, ol)
    • Images (img will require configured image loader)
    • Blockquote (blockquote)
    • Heading (h1, h2, h3, h4, h5, h6)
    • there is support to render any HTML tag
  • Task lists:
  • Not done
    • Done with X
    • and or small x

Screenshots

Taken with default configuration (except for image loading) in sample app:

By default configuration uses TextView textColor for styling, so changing textColor changes style


Documentation

Please visit documentation web-site for reference

Consulting

Paid consulting is available. Please reach me out at markwon+consulting[at]noties.io to discuss your idea or a project


Demo

Based on this cheatsheet


Headers


Header 1

Header 2

Header 3

Header 4

Header 5
Header 6

Emphasis

Emphasis, aka italics, with asterisks or underscores.

Strong emphasis, aka bold, with asterisks or underscores.

Combined emphasis with asterisks and underscores.

Strikethrough uses two tildes. Scratch this.


Lists

  1. First ordered list item
  2. Another item
  • Unordered sub-list.
  1. Actual numbers don't matter, just that it's a number

  2. Ordered sub-list

  3. And another item.

    You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).

    To have a line break without a paragraph, you will need to use two trailing spaces. Note that this line is separate, but within the same paragraph. (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)

  • Unordered list can use asterisks
  • Or minuses
  • Or pluses

Links

I'm an inline-style link

I'm a reference-style link

I'm a relative reference to a repository file

You can use numbers for reference-style link definitions

Or leave it empty and use the link text itself.


Code

Inline code has back-ticks around it.

var s = "JavaScript syntax highlighting";
alert(s);
s = "Python syntax highlighting"
print s
/**
 * Helper method to obtain a Parser with registered strike-through &amp; table extensions
 * &amp; task lists (added in 1.0.1)
 *
 * @return a Parser instance that is supported by this library
 * @since 1.0.0
 */
@NonNull
public static Parser createParser() {
  return new Parser.Builder()
      .extensions(Arrays.asList(
          StrikethroughExtension.create(),
          TablesExtension.create(),
          TaskListExtension.create()
      ))
      .build();
}
<ScrollView
  android:id="@+id/scroll_view"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_marginTop="?android:attr/actionBarSize">

  <TextView
    android:id="@+id/text"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="16dip"
    android:lineSpacingExtra="2dip"
    android:textSize="16sp"
    tools:text="yo\nman" />

</ScrollView>
No language indicated, so no syntax highlighting.
But let's throw in a <b>tag</b>.

Tables

Colons can be used to align columns.

Tables Are Cool
col 3 is right-aligned $1600
col 2 is centered $12
zebra stripes are neat $1

There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.

Markdown Less Pretty
Still renders nicely
1 2 3

Blockquotes

Blockquotes are very handy in email to emulate reply text. This line is part of the same quote.

Quote break.

This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can put Markdown into a blockquote.

Nested quotes

Hello!

And to you!


Inline HTML

<u><i>H<sup>T<sub>M</sub></sup><b><s>L</s></b></i></u>

HTML


Horizontal Rule

Three or more...


Hyphens (-)


Asterisks (*)


Underscores (_)

License

  Copyright 2019 Dimitry Ivanov ([email protected])

  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.
Comments
  • Weird glitch with Tables?

    Weird glitch with Tables?

    • Markwon version: 4.3.1

    Hi Noties, I don't know if this is a mistake on my end, or is an actual problem, but this is what I have. Keep in mind I encounter this rarely.

    this is the markwon table I'm trying to render:

    |   Date  |  Time  |  Who   |   What  | Link |
    |:--------:|:-------:|:-------:|:-------:|:-------:|
    | 18th June | 7:30AM PST / 2:30PM GMT | [Gradle](https://gradle.org/) | Building Android apps with Gradle | [Link](https://reddit.com/r/androiddev/comments/c22a31/were_part_of_the_gradle_team_ask_us_anything/) |
    | 20th June | 9AM PST / 4PM GMT | [Nerdery](https://www.nerdery.com/) | Remote Android working | [Link](https://www.reddit.com/r/androiddev/comments/c2vo8n/were_part_of_the_nerdery_team_ask_us_anything/) |
    | 24th June | 10AM PST / 5PM GMT | [Hinge](https://hinge.co/) | General Android development / design | [Link](https://www.reddit.com/r/androiddev/comments/c4pv9q/were_part_of_the_hinge_team_ask_us_anything/) |
    | 25th June | 1PM PST / 8PM GMT | [Bugsnag](https://www.bugsnag.com/) | Mobile crash reporting | [Link](https://www.reddit.com/r/androiddev/comments/c5chdo/were_part_of_the_bugsnag_team_ask_us_anything/) |
    | 15th July | 11AM PST / 6PM GMT | [Pandora](https://play.google.com/store/apps/details?id=com.pandora.android) | Android dev | [Link](https://www.reddit.com/r/androiddev/comments/cdj9tn/were_part_of_the_pandora_android_team_ask_us/) |
    | 16th July | 11AM PST / 6PM GMT | [Reddit](https://play.google.com/store/apps/details?id=com.reddit.frontpage) | Android dev | [Link](https://www.reddit.com/r/androiddev/comments/ce028h/were_the_team_thats_working_on_the_reddit_app_ask/) |
    | 1st August | 12PM PST / 7PM GMT | Android Engineering | Android Q | [Link](https://www.reddit.com/r/androiddev/comments/ci4tdq/were_on_the_engineering_team_for_android_q_ask_us/) |
    | 29th August | 8:30AM PST / 3:30PM GMT | [TomTom](https://www.tomtom.com) | Android dev | [Link](https://www.reddit.com/r/androiddev/comments/cx1xlt/we_are_part_of_the_maps_apis_sdk_team_for_tomtom/) |
    

    This is my simple view:

    <TextView
        android:id="@+id/page"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />
    

    and this is how it comes out:

    table-glitch

    I tried removing everything extra, but I keep getting this. What could it be?

    Thanks in advance.

    bug 
    opened by KirkBushman 24
  • RecyclerView click event getting blocked

    RecyclerView click event getting blocked

    • Markwon version: 4.3.1

    When i set any text using below code, parent recyclerview item view click is not working.

    Markwon markwon = Markwon.builder(aViewHolder.mContext)
                        .usePlugin(StrikethroughPlugin.create())
                        .usePlugin(new AbstractMarkwonPlugin() {
                            @Override
                            public void configureParser(@NonNull Parser.Builder builder) {
                                builder.inlineParserFactory(inlineParserFactory);
                            }
                        })
                        .build();
    
    final TextView lTextview = findViewById(R.id.textview);
    markwon.setMarkdown(lTextview, aMessage);
    
    final ConstraintLayout parent = findViewById(R.id.parent);
    parent.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Toast.makeText(getApplicationContext(), "Clicked on TextView", Toast.LENGTH_SHORT).show();
                }
            });
    

    Toast is not coming. But when i set individual click listener on textview than it's working normal.

    opened by gbhaumikkumar14 24
  • How to add padding to code block?

    How to add padding to code block?

    Hi, Im trying to style code / codeblock. I'd like to lower the font size and add padding around it, while preserving the original height. Or atleast left right paddings, I dont like that the bounding box wraps the text with 0 padding.

    Basically want this https://i.imgur.com/TYA97EF.png

    Is this possbile?

    opened by ursusursus 22
  • Canvas: trying to draw too large(143769912bytes)

    Canvas: trying to draw too large(143769912bytes)

    • Markwon version: 4.6.1

    A user reported in my downstream app Nextcloud Notes an issue when rendering an image.

    The following markdown leads reproducible to the below stacktrace:

    ![](http://otakurevolution.com/storyimgs/falldog/GundamTimeline/Falldogs_GundamTimeline_v13_April2020.png)
    
    java.lang.RuntimeException: Canvas: trying to draw too large(143769912bytes) bitmap.
    	at android.graphics.RecordingCanvas.throwIfCannotDraw(RecordingCanvas.java:280)
    	at android.graphics.BaseRecordingCanvas.drawBitmap(BaseRecordingCanvas.java:88)
    	at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:548)
    	at io.noties.markwon.image.AsyncDrawable.draw(AsyncDrawable.java:326)
    	at io.noties.markwon.image.AsyncDrawableSpan.draw(AsyncDrawableSpan.java:126)
    	at android.text.TextLine.handleReplacement(TextLine.java:1011)
    	at android.text.TextLine.handleRun(TextLine.java:1158)
    	at android.text.TextLine.drawRun(TextLine.java:491)
    	at android.text.TextLine.draw(TextLine.java:286)
    	at android.text.Layout.drawText(Layout.java:576)
    	at android.widget.Editor.drawHardwareAcceleratedInner(Editor.java:1957)
    	at android.widget.Editor.drawHardwareAccelerated(Editor.java:1876)
    	at android.widget.Editor.onDraw(Editor.java:1816)
    	at android.widget.TextView.onDraw(TextView.java:7989)
    	at android.view.View.draw(View.java:21975)
    	at android.view.View.updateDisplayListIfDirty(View.java:20852)
    	at android.view.View.draw(View.java:21707)
    	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
    	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
    	at android.view.View.draw(View.java:21978)
    	at android.widget.ScrollView.draw(ScrollView.java:1835)
    	at android.view.View.updateDisplayListIfDirty(View.java:20852)
    	at android.view.View.draw(View.java:21707)
    	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
    	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
    	at android.view.View.draw(View.java:21978)
    	at android.view.View.updateDisplayListIfDirty(View.java:20852)
    	at android.view.View.draw(View.java:21707)
    	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
    	at androidx.coordinatorlayout.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1277)
    	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
    	at android.view.View.updateDisplayListIfDirty(View.java:20843)
    	at android.view.View.draw(View.java:21707)
    	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
    	at androidx.fragment.app.FragmentContainerView.drawChild(FragmentContainerView.java:235)
    	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
    	at androidx.fragment.app.FragmentContainerView.dispatchDraw(FragmentContainerView.java:223)
    	at android.view.View.draw(View.java:21978)
    	at android.view.View.updateDisplayListIfDirty(View.java:20852)
    	at android.view.View.draw(View.java:21707)
    	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
    	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
    	at android.view.View.updateDisplayListIfDirty(View.java:20843)
    	at android.view.View.draw(View.java:21707)
    	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
    	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
    	at android.view.View.updateDisplayListIfDirty(View.java:20843)
    	at android.view.View.draw(View.java:21707)
    	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
    	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
    	at android.view.View.updateDisplayListIfDirty(View.java:20843)
    	at android.view.View.draw(View.java:21707)
    	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
    	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
    	at android.view.View.updateDisplayListIfDirty(View.java:20843)
    	at android.view.View.draw(View.java:21707)
    	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
    	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
    	at android.view.View.updateDisplayListIfDirty(View.java:20843)
    	at android.view.View.draw(View.java:21707)
    	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
    	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
    	at android.view.View.draw(View.java:21978)
    	at com.android.internal.policy.DecorView.draw(DecorView.java:808)
    	at android.view.View.updateDisplayListIfDirty(View.java:20852)
    	at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:581)
    	at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:587)
    	at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:664)
    	at android.view.ViewRootImpl.draw(ViewRootImpl.java:3767)
    	at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3495)
    	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2779)
    	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1745)
    	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7768)
    	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:967)
    	at android.view.Choreographer.doCallbacks(Choreographer.java:791)
    	at android.view.Choreographer.doFrame(Choreographer.java:726)
    	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952)
    	at android.os.Handler.handleCallback(Handler.java:883)
    	at android.os.Handler.dispatchMessage(Handler.java:100)
    	at android.os.Looper.loop(Looper.java:214)
    	at android.app.ActivityThread.main(ActivityThread.java:7356)
    	at java.lang.reflect.Method.invoke(Native Method)
    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940)
    
    

    I have the following information additionally from the users device:

    OS Version: 3.18.91-g8bbffc1d427(eng.root.20210107.120301)
    OS API Level: 29
    Device: heroltexx
    Manufacturer: samsung
    Model (and Product): SM-G930F (heroltexx)
    
    1. Can we avoid the crash at all?
    2. Is it thrown by intention?
    3. How am i supposed to catch this exception? It currently crashes the whole application i don't know how i could catch it...

    Expected behavior is that the app does not crash but render the alt text instead if it ain't possible to render an image.

    enhancement 
    opened by stefan-niedermann 19
  • Async drawable doesn't show up if it's the only thing in the text view

    Async drawable doesn't show up if it's the only thing in the text view

    • Markwon version: 4.2.1-SNAPSHOT + GlidePlugin

    Async drawable doesn't show up if it's the only thing in the text view.

    In the source code of the ReplacementSpan there's this suspicious javadoc

       /**
         * Returns the width of the span. Extending classes can set the height of the span by updating
         * attributes of {@link android.graphics.Paint.FontMetricsInt}. If the span covers the whole
         * text, and the height is not set,
         * {@link #draw(Canvas, CharSequence, int, int, float, int, int, int, Paint)} will not be
         * called for the span.
         */
         public abstract int getSize(...)
    

    And AsyncDrawable.initWithKnownDimensions(...) is only called if AsyncDrawableSpan.draw(...) of the parent span was called.

    bug 
    opened by Kaned1as 19
  • Table rendering and ANRs

    Table rendering and ANRs

    • Markwon version: {4.0.2}

    I had plans since a year integrating this lib in FastHub, matter of fact I have actually forked it back in 2017 https://github.com/k0shk0sh/FastHub/blob/ee2c95dec4873633abdfc26eb0895929915edd90/app/src/main/java/com/fastaccess/github/platform/markwon/mention/MentionExtension.kt#L12 trying to integrate @, #, :emoji: because I notice that's the only thing missing and its still, but with the possibility of adding own plugin, that became possible and finally decided its time to switch to this lib, you done amazing work and can't even think of how troublesome it is to implement this lib :D. Enough complements :p, I got an issue when using TablePlugin in a large issue description where it contains multiple tables specifically this: https://github.com/k0shk0sh/FastHub/issues/823 . is there a better way of loading the tables in a better way to avoid ANRs?

    enhancement discussion 
    opened by k0shk0sh 18
  • Images loaded with coil don't show when using transformations

    Images loaded with coil don't show when using transformations

    • Markwon version: 4.4.0

    When using the coil plugin and applying transformations as explained in the documentation images are not displayed (only the placeholder appears) when returning to a previously displayed TextView with markdown.

    It doesn't seem to matter which transformations you use and how many. Removing the transformations makes the issue go away.

    Markwon configuration:

    Markwon.builder(activity)
        .usePlugin(
            CoilImagesPlugin.create(
                object : CoilImagesPlugin.CoilStore {
                    override fun load(drawable: AsyncDrawable): LoadRequest {
                        return LoadRequest.Builder(context)
                            .transformations(
                                RoundedCornersWithoutCropTransformation(14f)
                            )
                            .data(drawable.destination)
                            .placeholder(R.drawable.image_placeholder)
                            .build()
                    }
    
                    override fun cancel(disposable: RequestDisposable) {
                        disposable.dispose()
                    }   
                },
                ImageLoader.Builder(activity)
                    .okHttpClient(okHttpClient)
                    .placeholder(R.drawable.image_placeholder)
                    .build()
            )
        )
        .build()
    

    Steps to reproduce:

    1. Open a fragment with a TextView that is populated using Markwon with some markdown containing images.
    2. Put the app to background.
    3. Reopen the app from recents.
    4. Observe: the images are not displayed anymore (only placeholders are shown). If an image didn't load in step 2 (e.g. you advanced too quickly or the loading failed) it will load now (if not blocked by some external factors), but also just once.
    bug 
    opened by ubuntudroid 17
  • Animating spans on text set

    Animating spans on text set

    • Markwon version: 4.6.0
    1. Please specify expected/actual behavior This is a question rather than an issue but I can't seem to find the way raising it other than filing an issue.

    2. Please specify conditions/steps to reproduce (layout, code, markdown used, etc) Out team wants to achieve a simple animation involving BackgroundSpan when the TextView's value is being set or when the view is attached to window. So now I am curious of where @noties would recommend such a mechanism should be placed among plugins. untitled-YGz642Uz-D9X2

    opened by c-b-h 14
  • Image on a newline is not parsed correctly

    Image on a newline is not parsed correctly

    With markdown like this:

    Sample image:
    
    <img src="https://upload.wikimedia.org/wikipedia/en/f/f4/Unrealtournament.jpg" />
    

    Image is parsed as HtmlBlock by Commonmark parser, not as HtmlInline, later this is handled by SpannableMarkdownVisitor::visit(HtmlBlock htmlBlock) which assumes tag as null and passes it to Html.fromHtml which doesn't support images.

    image

    bug html 
    opened by Kaned1as 14
  • Title and Links not working when using BetterLinkMovementMethod

    Title and Links not working when using BetterLinkMovementMethod

    • Markwon version: {4.3.1}

    Hello @noties I am using markwon everywhere in my application. Earlier i have added BetterLinkMovementMethod Method to support click and long click on URL, Phone and Email spans. But now i added Markwon support to almost everywhere in app.

    Problem i am facing is when i add normal link like www.google.com or +91123456790 or [email protected] it's highlighting and functionality is working fine. But when i add [title] and (link) in bracket to show only title instead of link it's not highlighting.

    opened by gbhaumikkumar14 13
  • html tags disappear

    html tags disappear

    • Markwon version: 4.3.1
    1. Please specify expected/actual behavior I want the output of <owo>Hello!</owo> <strong>ok</strong> to be unchanged but what actually happens is the html tags get removed: Hello! ok
    2. Please specify conditions/steps to reproduce (layout, code, markdown used, etc)
    private val markwon: Markwon = Markwon.builder(applicationContext).build()
    markwon.setMarkdown(messageArea, "<owo>Hello!</owo> <whatever>ok</whatever>")
    

    I'm trying to make a chat app so I dont want people typing in html code. Thanks!

    question 
    opened by Supertigerr 13
  • Request to add app to Awesome Markwon section

    Request to add app to Awesome Markwon section

    Please provide the following:

    • Project name : Zettel Notes
    • Project URL (repository, store listing, web page) : https://play.google.com/store/apps/details?id=org.eu.thedoc.zettelnotes
    • https://znotes.thedoc.eu.org/

    Please make sure that there is the awesome label selected for this issue.

    🙌

    opened by damionx7 0
  • Can I use another Android View in between Markwon RecyclerView?

    Can I use another Android View in between Markwon RecyclerView?

    • Markwon version: 4.6.2
    1. I saw the demo app, in which there a Recycler-View example, and your repo says that it's not the Web view, which could be meant that your are using the different kind of view together to render the Markdown Output. E.G. : ImageView, TextView, etc

    2. So my question is, can I add my custom view in between ? Let's say I want to add my custom shape view, or the video view along the Markwon Recyclerview, E.g. After my 2 paragraphs of information I want to add a Video View and then continue with the remaining content.

    So is it possible ? How can I achieve that ?

    opened by Meet-Miyani 0
  • HTML ordered lists initial position

    HTML ordered lists initial position

    Fixes #381 missing initial values when processing html ordered lists

    • Adds an example for html ordered lists to showcase the initial starting value being taken into account
    • Takes the tag start attribute into account when creating the initial list number

    | BEFORE | AFTER | | --- | --- | |before-markwon|after-markwon

    opened by ouchadam 0
  • [Question] How to change image gravity?

    [Question] How to change image gravity?

    • Markwon version: 4.6.2

    Both the title and description image are not aligned the same way emojis are, with gravity center_vectical. image

    Is it possible to make them aligned the same way the tittle picture is in this picture? image

    1. Please specify expected/actual behavior Markdown images have gravity set to center_vertical, and would look like emojis in picture above (not the same in size, just alignment), or like in the second picture.

    2. Please specify conditions/steps to reproduce (layout, code, markdown used, etc.) To create the 2nd picture I just hardcoded an image and set the gravity to center_vertical. I tried setting the gravity in the TextView to center_vertical but the way the image was aligned didn't change.

      <LinearLayout
            android:layout_width="match_parent"
            android:orientation="horizontal"
            android:layout_height="wrap_content">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:src="@drawable/pic_buff1"/>
            <com.habitrpg.android.habitica.ui.views.EllipsisTextView
                android:id="@+id/checkedTextView"
                style="@style/Subheader3"
                android:textColor="?attr/textColorPrimary"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:lineSpacingExtra="2sp"
                android:layout_gravity="center_vertical"
                android:textSize="15sp"
                android:letterSpacing="0.025"
                tools:text="Habit Title" />
        </LinearLayout>
    
    opened by DorianK29 0
  • How to make Latex show in RemoteView?

    How to make Latex show in RemoteView?

    • Markwon version: 4.6.2
    1. Please specify expected/actual behavior

    I need to display the Latex formula in an Android AppWidget. I use Markwon inside the App, but I can't assign a value because I can't get the TextView object in the AppWidget. Is there any way to solve this?

    1. Please specify conditions/steps to reproduce (layout, code, markdown used, etc)
    Spanned xxx = markwon.toMarkdown("$$\n"+"xxx"+"\n$$");
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_xxx);
    views.setTextViewText(R.id.tv_xxx, xxx);
    

    ask for help

    opened by zhouzhuo810 1
Releases(v4.6.2)
  • v4.6.2(Feb 8, 2021)

  • v4.6.1(Dec 28, 2020)

    Changed

    • core - CustomTypefaceSpan new mergeStyles functionality and new factory method(#298)
      Thanks @c-b-h
    • image-coil - update Coil to 0.13.0 (#303)
      Thanks @ubuntudroid

    Deprecated

    • core - CustomTypefaceSpan(Typeface) constructor, use CustomTypefaceSpan.create(Typeface) or CustomTypefaceSpan.create(Typeface, boolean) factory methods instead
    Source code(tar.gz)
    Source code(zip)
  • v4.6.0(Sep 18, 2020)

    Added

    • ext-tables - TableAwareMovementMethod a special movement method to handle clicks inside tables (#289)

    Changed

    • ext-tasklist - changed implementation to be in line with GFM (Github flavored markdown), task list item is a regular list item (BulletList and OrderedList can contain it). Internal implementation changed from block parsing to node post processing (#291)
    • image-glide - update to 4.11.0 version
    • inline-parser - revert parsing index when InlineProcessor returns null as result
    • image-coil - update Coil to 0.12.0 (Coil changelog) (#284)
      Thanks @magnusvs
    Source code(tar.gz)
    Source code(zip)
  • v4.5.1(Aug 13, 2020)

    Changed

    • image-coil - use coil-base as api dependency (would require explicit coil dependency) (#274)

    Fixed

    • image-coil - deliver image result if it loaded before request disposable is created (#272)
    • ext-tables - fix column width rounding issue
    Source code(tar.gz)
    Source code(zip)
  • v4.5.0(Aug 5, 2020)

    Added

    • core - MovementMethodPlugin.none(), MovementMethodPlugin.link() factory methods
    • core - CorePlugin hasExplicitMovementMethod configuration method to not add implicit LinkMovementMethod in afterSetText
    • core - MarkwonTheme isLinkedUnderlined attribute for links(#270)
      Thanks to @dallasgutauckis
    • ext-latex - JLatexMathTheme.Padding.of(int,int,int,int) factory method
    • app-sample - example application

    Changed

    • html - SimpleTagHandler visits children tags if supplied tag is block one (#235)
    • inline-parser - BangInlineProcessor properly returns null if no image node is found (possible to define other inline parsers that use ! as special character)
    • image - AsyncDrawable won't trigger loading if it has result (aim: RecyclerView due to multiple attach/detach events of a View)
    • image - AsyncDrawable will resume result if it is Animatable and was playing before detach event (aim: RecyclerView) (#241)
    • core - MarkwonReducer filter out LinkReferenceDefinition nodes

    Fixed

    • image-glide cache RequestManager in GlideImagesPlugin#create(Context) factory method (#259)

    Deprecated

    • core - MovementMethodPlugin.create() use explicit MovementMethodPlugin.link() instead

    Removed

    • image - AsyncDrawable#hasKnownDimentions (deprecated in 4.2.1)
    • app and sample applications (merged together in a app-sample single app)
    Source code(tar.gz)
    Source code(zip)
  • v4.4.0(May 19, 2020)

    • TextViewSpan to obtain TextView in which markdown is displayed (applied by CorePlugin)
    • TextLayoutSpan to obtain Layout in which markdown is displayed (applied by TablePlugin, more specifically TableRowSpan to propagate layout in which cell content is displayed)
    • HtmlEmptyTagReplacement now is configurable by HtmlPlugin, iframe handling (#235)
    • AsyncDrawable now uses TextView width without padding instead of width of canvas
    • Support for images inside table cells (ext-tables module)
    • Expose enabledBlockTypes in CorePlugin
    • Update jlatexmath-android dependency (#225)
    • Update image-coil module (Coil version 0.10.1) (#244)
      Thanks to @tylerbwong
    • Rename UrlProcessor to ImageDestinationProcessor (io.noties.markwon.urlprocessor -> io.noties.markwon.image.destination) and limit its usage to process only destination URL of images (was used to also process links before)
    • fallbackToRawInputWhenEmpty Markwon.Builder configuration to fallback to raw input if rendered markdown is empty (#242)
    Source code(tar.gz)
    Source code(zip)
  • v4.3.1(Apr 1, 2020)

  • v4.3.0(Mar 18, 2020)

    • add MarkwonInlineParserPlugin in inline-parser module
    • JLatexMathPlugin now supports inline LaTeX structures via MarkwonInlineParserPlugin dependency (must be explicitly added to Markwon whilst configuring)
    • JLatexMathPlugin: add theme (to customize both inlines and blocks)
    • add JLatexMathPlugin.ErrorHandler to catch latex rendering errors and (optionally) display error drawable (#204)
    • JLatexMathPlugin add text color customization (#207)
    • JLatexMathPlugin will use text color of widget in which it is displayed if color is not set explicitly
    • add SoftBreakAddsNewLinePlugin plugin (core module)
    • LinkResolverDef defaults to https when a link does not have scheme information (#75)
    • add option abstraction for sample module allowing switching of multiple cases in runtime via menu
    • non-empty bounds for AsyncDrawable when no dimensions are not yet available (#189)
    • linkify - option to use LinkifyCompat in LinkifyPlugin (#201)
      Thanks to @drakeet
    • MarkwonVisitor.BlockHandler and BlockHandlerDef implementation to control how blocks insert new lines after them
    // default usage: new blocks parser, no inlines
    final Markwon markwon = Markwon.builder(this)
        .usePlugin(JLatexMathPlugin.create(textSize))
        .build();
    
    // legacy blocks (pre `4.3.0`) parsing, no inlines
    final Markwon markwon =  Markwon.builder(this)
            .usePlugin(JLatexMathPlugin.create(textView.getTextSize(), builder -> builder.blocksLegacy(true)))
            .build();
    
    // new blocks parsing and inline parsing
    final Markwon markwon =  Markwon.builder(this)
            .usePlugin(JLatexMathPlugin.create(textView.getTextSize(), builder -> {
                // blocksEnabled and blocksLegacy can be omitted
                builder
                        .blocksEnabled(true)
                        .blocksLegacy(false)
                        .inlinesEnabled(true);
            }))
            .build();
    
    Source code(tar.gz)
    Source code(zip)
  • v4.2.2(Feb 26, 2020)

    • Fixed AsyncDrawable display when it has placeholder with empty bounds (#189)
    • Fixed syntax-highlight where code input is empty string (#192)
    • Add appendFactory/prependFactory in MarkwonSpansFactory.Builder for more explicit SpanFactory ordering (#193)
    Source code(tar.gz)
    Source code(zip)
  • v4.2.1(Feb 2, 2020)

    • Fix SpannableBuilder subSequence method
    • Introduce Nougat check in BulletListItemSpan to position bullet (for bullets to be positioned correctly when nested inside other LeadingMarginSpans)
    • Reduced number of invalidations in AsyncDrawable when result is ready
    • AsyncDrawable#hasKnownDimentions -> AsyncDrawable#hasKnownDimensions typo fix
    Source code(tar.gz)
    Source code(zip)
  • v4.2.0(Nov 15, 2019)

    • MarkwonEditor to highlight markdown input whilst editing (new module: markwon-editor)
    • CoilImagesPlugin image loader based on Coil library (new module: markwon-image-coil) (#166, #174)
      Thanks to @tylerbwong
    • MarkwonInlineParser to customize inline parsing (new module: markwon-inline-parser)
    • Update commonmark-java to 0.13.0 (and commonmark spec 0.29)
    • Markwon#configuration method to expose MarkwonConfiguration via public API
    • HeadingSpan#getLevel getter
    • Add SvgPictureMediaDecoder in image module to deal with SVG without dimensions (#165)
    • LinkSpan#getLink method
    • LinkifyPlugin applies link span that is configured by Markwon (obtain via span factory)
    • LinkifyPlugin is thread-safe
    Source code(tar.gz)
    Source code(zip)
  • v4.1.2(Oct 16, 2019)

  • v4.1.1(Aug 29, 2019)

    • markwon-ext-tables: fix padding between subsequent table blocks (#159)
    • markwon-images: print a single warning instead full stacktrace in case when SVG or GIF are not present in the classpath (#160)
    • Make Markwon instance thread-safe by using a single MarkwonVisitor for each render call (#157)
    • Add CoreProps.CODE_BLOCK_INFO with code-block info (language)
    Source code(tar.gz)
    Source code(zip)
  • v4.1.0(Aug 6, 2019)

    • Add Markwon.TextSetter interface to be able to use PrecomputedText/PrecomputedTextCompat
    • Add PrecomputedTextSetterCompat and compileOnly dependency on androidx.core:core (clients must have this dependency in the classpath)
    • Add requirePlugin(Class) and getPlugins for Markwon instance
    • TablePlugin -> defer table invalidation (via View.post), so only one invalidation happens with each draw-call
    • AsyncDrawableSpan -> defer invalidation
    Source code(tar.gz)
    Source code(zip)
  • v4.0.2(Jul 15, 2019)

    • Fix JLatexMathPlugin formula placeholder (cannot have line breaks) (#149)
    • Fix JLatexMathPlugin to update resulting formula bounds when fitCanvas=true and formula exceed canvas width (scale down keeping formula width/height ratio)
    Source code(tar.gz)
    Source code(zip)
  • v4.0.1(Jul 3, 2019)

  • v4.0.0(Jul 1, 2019)

    • maven group-id change to io.noties.markwon (was ru.noties.markwon)
    • package name change to io.notier.markwon.* (was ru.noties.markwon.*)
    • androidx artifacts (#76)
    • Markwon#builder does not require explicit CorePlugin (added automatically), use Markwon#builderNoCore() to obtain a builder without CorePlugin
    • Removed Priority abstraction and MarkwonPlugin#priority (use MarkwonPlugin.Registry)
    • Removed MarkwonPlugin#configureHtmlRenderer (for configuration use HtmlPlugin directly)
    • Removed MarkwonPlugin#configureImages (for configuration use ImagesPlugin directly)
    • Added MarkwonPlugin.Registry and MarkwonPlugin#configure(Registry) method
    • CorePlugin#addOnTextAddedListener (process raw text added)
    • ImageSizeResolver signature change (accept AsyncDrawable)
    • LinkResolver is now an independent entity (previously part of LinkSpan)
    • AsyncDrawableScheduler can now be called multiple times without performance penalty
    • AsyncDrawable now exposes its destination, image-size, last known dimensions (canvas, text-size)
    • AsyncDrawableLoader signature change (accept AsyncDrawable)
    • Add LastLineSpacingSpan
    • Add MarkwonConfiguration.Builder#asyncDrawableLoader method
    • ImagesPlugin removed from core artifact (also removed images-gif, images-okhttp and images-svg artifacts and their plugins)
    • ImagesPlugin exposes configuration (adding scheme-handler, media-decoder, etc)
    • ImagesPlugin allows multiple images with the same source (URL)
    • Add PlaceholderProvider and ErrorHandler to ImagesPlugin
    • GIF and SVG media-decoders are automatically added to ImagesPlugin if required libraries are found in the classpath
    • ImageItem is now abstract, has 2 implementations: withResult, withDecodingNeeded
    • Add images-glide, images-picasso, linkify, simple-ext modules
    • JLatexMathPlugin is now independent of ImagesPlugin
    • Fix wrong JLatexMathPlugin formulas sizes (#138)
    • JLatexMathPlugin has backgroundProvider, executorService configuration
    • HtmlPlugin is self-contained (all configuration is moved in the plugin itself)
    Source code(tar.gz)
    Source code(zip)
  • v3.1.0(Jul 1, 2019)

    • AsyncDrawable exposes ImageSize, ImageSizeResolver and last known dimensions (canvas width and text size)
    • AsyncDrawableLoader load and cancel signatures change - both accept an AsyncDrawable
    • Fix for multiple images with the same source in AsyncDrawableLoader

    With this release Markwon 3.x.x version goes into maintenance mode. No new features will be added in 3.x.x version, development is focused on 4.x.x version.

    Source code(tar.gz)
    Source code(zip)
  • v3.0.2(Jun 19, 2019)

  • v3.0.1(Jun 18, 2019)

    • Add AsyncDrawableLoader.Builder#implementation method (#109 )
    • AsyncDrawable allow placeholder to have independent size (#115 )
    • addFactory method for MarkwonSpansFactory
    • Add optional spans for list blocks (bullet and ordered)
    • AsyncDrawable placeholder bounds fix
    • SpannableBuilder setSpans allow array of arrays
    • Add requireFactory method to MarkwonSpansFactory
    • Add DrawableUtils
    Source code(tar.gz)
    Source code(zip)
  • v3.0.0(Mar 18, 2019)

    • Plugins, plugins, plugins
    • Split basic functionality blocks into standalone modules
    • Maven artifacts group changed to ru.noties.markwon (previously had been ru.noties)
    • removed markwon, markwon-image-loader, markwon-html-pareser-api, markwon-html-parser-impl, markwon-view modules
    • new module system: core, ext-latex, ext-strikethrough, ext-tables, ext-tasklist, html, image-gif, image-okhttp, image-svg, recycler, recycler-table, syntax-highlight
    • Add BufferType option for Markwon configuration
    • Fix typo in AsyncDrawable waitingForDimensions
    • New tests format
    • Markwon.render returns Spanned instance of generic CharSequence
    • LinkMovementMethod is applied implicitly if not set on a TextView explicitly
    • Split code and codeBlock spans and factories
    • Add CustomTypefaceSpan
    • Add NoCopySpansFactory
    • Add placeholder to image loading

    Generally speaking there are a lot of changes. Most of them are not backwards-compatible. The main point of this release is the Plugin system that allows more fluent configuration and opens the possibility of extending Markwon with 3rd party functionality in a simple and intuitive fashion. Please refer to the documentation web-site that has information on how to start migration.

    The shortest excerpt of this release can be expressed like this:

    // previous v2.x.x way
    Markwon.setMarkdown(textView, "**Hello there!**");
    
    // 3.x.x
    Markwon.create(context)
            .setMarkdown(textView, "**Hello there!**");
    

    But there is much more to it, please visit documentation web-site to get the full picture of latest changes.

    Source code(tar.gz)
    Source code(zip)
    markwon-3.0.0-debug.apk(752.10 KB)
  • v2.0.2(Mar 14, 2019)

  • v2.0.1(Dec 10, 2018)

    • SpannableMarkdownVisitor Rename blockQuoteIndent to blockIndent
    • Fixed block new lines logic for block quote and paragraph (#82)
    • AsyncDrawable fix no dimensions bug (#81)
    • Update SpannableTheme to use Px instead of Dimension annotation
    • Allow TaskListSpan isDone mutation
    • Updated commonmark-java to 0.12.1
    • Add OrderedListItemSpan measure utility method (#78)
    • Add SpannableBuilder#getSpans method
    • Fix DataUri scheme handler in image-loader (#74)
    • Introduced a "copy" builder for SpannableThem Thanks @c-b-h 🙌
    Source code(tar.gz)
    Source code(zip)
    markwon-sample-2.0.1-debug.apk(702.10 KB)
  • v2.0.0(Sep 17, 2018)

    • Add html-parser-api and html-parser-impl modules
    • Add HtmlEmptyTagReplacement
    • Implement Appendable and CharSequence in SpannableBuilder
    • Renamed library modules to reflect maven artifact names
    • Rename markwon-syntax to markwon-syntax-highlight
    • Add HtmlRenderer asbtraction
    • Add CssInlineStyleParser
    • Fix Theme#listItemColor and OL
    • Fix task list block parser to revert parsing state when line is not matching
    • Defined test format files
    • image-loader add datauri parser
    • image-loader add support for inline data uri image references
    • Add travis configuration
    • Fix image with width greater than canvas scaled
    • Fix blockquote span
    • Dealing with white spaces at the end of a document
    • image-loader add SchemeHandler abstraction
    • Add sample-latex-math module
    Source code(tar.gz)
    Source code(zip)
    markwon-sample-2.0.0-debug.apk(713.94 KB)
  • v1.1.1(Aug 18, 2018)

  • v1.1.0(Jul 30, 2018)

    • Update commonmark to 0.11.0 and android-gif to 1.2.14
    • Add syntax highlight functionality (library-syntax module and markwon-syntax artifact)
    • Add headingTypeface, headingTextSizes to SpannableTheme Thanks to @edenman
    • Introduce MediaDecoder abstraction to image-loader module
    • Introduce SpannableFactory Thanks for idea to @c-b-h
    • Update sample application to use syntax-highlight
    • Update sample application to use clickable placeholder for GIF media
    Source code(tar.gz)
    Source code(zip)
    markwon-sample-1.1.0-debug.apk(680.51 KB)
  • v1.0.6(Jun 26, 2018)

    • Fix bullet list item size (depend on text size and not top-bottom arguments)
    • Add ability to specify MovementMethod when applying markdown to a TextView
    • Markdown images size is also resolved via ImageSizeResolver
      • Moved ImageSize, ImageSizeResolver and ImageSizeResolverDef to ru.noties.markwon.renderer package (one level up, previously ru.noties.markwon.renderer.html)
    Source code(tar.gz)
    Source code(zip)
    markwon-sample-1.0.6-debug.apk(657.42 KB)
  • v1.0.5(May 22, 2018)

    • Change LinkSpan to extend URLSpan. Allow default linkColor (if not set explicitly)

    • Fit an image without dimensions to canvas width (and keep ratio)

    • Add support for separate color for code blocks (#37) Thanks to @arcnor 🙌

    Source code(tar.gz)
    Source code(zip)
  • v1.0.4(Mar 18, 2018)

  • v1.0.3(Jan 13, 2018)

Owner
Dimitry
Small bits and big bytes
Dimitry
Irineu A. Silva 2 Feb 17, 2022
A library to show emoji in TextView, EditText (like WhatsApp) for Android

Discontinued This projected is discontinued. Please consider using other alternative, i.e EmojiCompat. Contact me if you want to continue working on a

Hieu Rocker 3.6k Jan 5, 2023
Android library contain custom realisation of EditText component for masking and formatting input text

Masked-Edittext Masked-Edittext android library EditText widget wrapper add masking and formatting input text functionality. Install Maven <dependency

Evgeny Safronov 600 Nov 29, 2022
library to implement and render emojis For Android

Release Notes SuperNova-Emoji SuperNova-Emoji is a library to implement and render emojis. Minimum SDK Level: 9 (2.3) Contact Java Usage To use defaul

Hani Al-momani 360 Jan 3, 2023
Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Provides easy means to validate with dependencies.

android-formidable-validation Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Pr

Linden 147 Nov 20, 2022
Lightweight android library for highlighting sections of a textview, with optional callbacks.

Linker Lightweight android library for highlighting Strings inside of a textview (ignoring case), with optional callbacks. Language: Java MinSDK: 17 J

Josh Gainey 35 Apr 30, 2022
Awesome Android Typeahead library - User mention plugin, UI widget for auto complete user mention using the at sign (@) like Twitter or Facebook.

android-typeahead Awesome Android Typeahead library - User mention plugin, UI widget for auto complete user mention using the at sign (@) like Twitter

Arab Agile 11 Jun 4, 2019
Digipad is a simple library for Android that only show a numeric keyboard onscreen

Digipad is a simple library for Android that only show a numeric keyboard onscreen Adding dependencies Add this to your build.gradle:

Yoga C. Pranata 7 Jun 24, 2022
Android UI component library with stateful

Android UI component library with stateful

null 0 Oct 13, 2021
IconabTextView - Android UI component library with stateful

IconabTextView - Android UI component library with stateful

Burhan Cabiroglu 1 Oct 15, 2021
A simple Android library to protect part of text using Span

Text Protector A simple Android library to "protect" part of text using Span What is this? This is a small library for replacing part of a text in a T

Oleg Nestyuk 4 May 16, 2022
A single EditText instead of a classical form. Library that implements flavienlaurent's singleinputform

material-singleinputform A single EditText instead of a classical form. This Library is a library implementation of flavienlaurent's "Single input for

Jan Heinrich Reimer 200 Nov 14, 2022
💰 A library to dynamically format your EditTexts to take currency inputs

CurrencyEditText A library to dynamically format your EditTexts to take currency inputs. Gradle Dependency Add the dependency to your app's build.grad

Cotta & Cush Limited 115 Dec 28, 2022
Library project with a custom view that implements the Float Label pattern

AndroidFloatLabel This repository contains an Android library project for Android 4.0+ with a custom view that implements the Float Label pattern (htt

Ian G. Clifton 475 Dec 27, 2022
A single EditText instead of a classical form. Library that implements flavienlaurent's singleinputform

material-singleinputform A single EditText instead of a classical form. This Library is a library implementation of flavienlaurent's "Single input for

Jan Heinrich Reimer 200 Nov 14, 2022
User input masking library repo.

More GIFs [~3 MB] Migration Guide: v.6 This update brings breaking changes. Namely, the autocomplete flag is now a part of the CaretGravity enum, thus

red_mad_robot 1.2k Dec 20, 2022
A TextView library that allows the user to increase/decrease font size with a two finger gesture by the user.

PinchZoomTextView Library This library allows you to have a TextView that will grow/shrink the font size using gestures from the user. Usage To have a

null 311 Nov 23, 2022
A simple library for hide and show text with animation.

ViewMore TextView ViewMore TextView allows you to use a TextView by hiding the content of the text by a number of established lines and to display all

Michele Quintavalle 81 Dec 23, 2022
Micro Template 📃 A very tiny and simple text templating library for Kotlin.

Micro Template ?? A very tiny and simple text templating library for Kotlin. It has very limited features, so it's intended to be used for short templ

Matteo Mirk 24 Aug 20, 2022