Change markwon render return type to Spanned
This commit is contained in:
		
							parent
							
								
									414a8763f2
								
							
						
					
					
						commit
						7c473b3d37
					
				| @ -2,6 +2,7 @@ package ru.noties.markwon; | ||||
| 
 | ||||
| import android.content.Context; | ||||
| import android.support.annotation.NonNull; | ||||
| import android.text.Spanned; | ||||
| import android.widget.TextView; | ||||
| 
 | ||||
| import org.commonmark.node.Node; | ||||
| @ -17,11 +18,11 @@ public abstract class Markwon { | ||||
|     public abstract Node parse(@NonNull String input); | ||||
| 
 | ||||
|     @NonNull | ||||
|     public abstract CharSequence render(@NonNull Node node); | ||||
|     public abstract Spanned render(@NonNull Node node); | ||||
| 
 | ||||
|     // parse + render | ||||
|     @NonNull | ||||
|     public abstract CharSequence toMarkdown(@NonNull String input); | ||||
|     public abstract Spanned toMarkdown(@NonNull String input); | ||||
| 
 | ||||
|     public abstract void setMarkdown(@NonNull TextView textView, @NonNull String markdown); | ||||
| 
 | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| package ru.noties.markwon; | ||||
| 
 | ||||
| import android.support.annotation.NonNull; | ||||
| import android.text.Spanned; | ||||
| import android.widget.TextView; | ||||
| 
 | ||||
| import org.commonmark.node.Node; | ||||
| @ -39,7 +40,7 @@ class MarkwonImpl extends Markwon { | ||||
| 
 | ||||
|     @NonNull | ||||
|     @Override | ||||
|     public CharSequence render(@NonNull Node node) { | ||||
|     public Spanned render(@NonNull Node node) { | ||||
| 
 | ||||
|         for (MarkwonPlugin plugin : plugins) { | ||||
|             plugin.beforeRender(node); | ||||
| @ -51,12 +52,12 @@ class MarkwonImpl extends Markwon { | ||||
|             plugin.afterRender(node, visitor); | ||||
|         } | ||||
| 
 | ||||
|         return visitor.builder().text(); | ||||
|         return visitor.builder().spannableStringBuilder(); | ||||
|     } | ||||
| 
 | ||||
|     @NonNull | ||||
|     @Override | ||||
|     public CharSequence toMarkdown(@NonNull String input) { | ||||
|     public Spanned toMarkdown(@NonNull String input) { | ||||
|         return render(parse(input)); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Dimitry Ivanov
						Dimitry Ivanov