Remove ext tests from core module
This commit is contained in:
		
							parent
							
								
									078d4dfc38
								
							
						
					
					
						commit
						5a18aa3a01
					
				| @ -38,21 +38,6 @@ | ||||
|                     android:host="*" | ||||
|                     android:scheme="https" /> | ||||
| 
 | ||||
|                 <!--<data--> | ||||
|                 <!--android:host="*"--> | ||||
|                 <!--android:scheme="http"--> | ||||
|                 <!--android:mimeType="text/toMarkdown"/>--> | ||||
| 
 | ||||
|                 <!--<data--> | ||||
|                 <!--android:host="*"--> | ||||
|                 <!--android:scheme="file"--> | ||||
|                 <!--android:mimeType="text/toMarkdown"/>--> | ||||
| 
 | ||||
|                 <!--<data--> | ||||
|                 <!--android:host="*"--> | ||||
|                 <!--android:scheme="https"--> | ||||
|                 <!--android:mimeType="text/toMarkdown"/>--> | ||||
| 
 | ||||
|                 <data android:pathPattern=".*\\.markdown" /> | ||||
|                 <data android:pathPattern=".*\\.mdown" /> | ||||
|                 <data android:pathPattern=".*\\.mkdn" /> | ||||
|  | ||||
| @ -26,6 +26,8 @@ import ru.noties.markwon.syntax.Prism4jTheme; | ||||
| import ru.noties.markwon.syntax.Prism4jThemeDarkula; | ||||
| import ru.noties.markwon.syntax.Prism4jThemeDefault; | ||||
| import ru.noties.markwon.syntax.SyntaxHighlightPlugin; | ||||
| import ru.noties.markwon.urlprocessor.UrlProcessor; | ||||
| import ru.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute; | ||||
| import ru.noties.prism4j.Prism4j; | ||||
| 
 | ||||
| @ActivityScope | ||||
|  | ||||
| @ -4,6 +4,9 @@ import android.net.Uri; | ||||
| import android.support.annotation.NonNull; | ||||
| import android.text.TextUtils; | ||||
| 
 | ||||
| import ru.noties.markwon.urlprocessor.UrlProcessor; | ||||
| import ru.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute; | ||||
| 
 | ||||
| class UrlProcessorInitialReadme implements UrlProcessor { | ||||
| 
 | ||||
|     private static final String GITHUB_BASE = "https://github.com/noties/Markwon/raw/master/"; | ||||
|  | ||||
| @ -7,8 +7,8 @@ import ru.noties.markwon.SpannableFactoryDef; | ||||
| import ru.noties.markwon.image.AsyncDrawableLoader; | ||||
| import ru.noties.markwon.image.ImageSize; | ||||
| import ru.noties.markwon.image.ImageSizeResolver; | ||||
| import ru.noties.markwon.spans.AsyncDrawableSpan; | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.core.spans.AsyncDrawableSpan; | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| 
 | ||||
| public class GifAwareSpannableFactory extends SpannableFactoryDef { | ||||
| 
 | ||||
|  | ||||
| @ -9,7 +9,7 @@ import android.view.View; | ||||
| import android.widget.TextView; | ||||
| 
 | ||||
| import pl.droidsonroids.gif.GifDrawable; | ||||
| import ru.noties.markwon.spans.AsyncDrawableSpan; | ||||
| import ru.noties.markwon.core.spans.AsyncDrawableSpan; | ||||
| 
 | ||||
| public abstract class GifProcessor { | ||||
| 
 | ||||
|  | ||||
| @ -7,7 +7,7 @@ import android.support.annotation.NonNull; | ||||
| import android.text.Layout; | ||||
| import android.text.style.LeadingMarginSpan; | ||||
| 
 | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| import ru.noties.markwon.utils.LeadingMarginUtils; | ||||
| 
 | ||||
| /** | ||||
|  | ||||
| @ -5,7 +5,6 @@ import android.support.annotation.Nullable; | ||||
| import android.text.SpannableStringBuilder; | ||||
| import android.text.TextUtils; | ||||
| 
 | ||||
| import ru.noties.markwon.SyntaxHighlight; | ||||
| import ru.noties.prism4j.Prism4j; | ||||
| 
 | ||||
| public class Prism4jSyntaxHighlight implements SyntaxHighlight { | ||||
|  | ||||
| @ -6,8 +6,8 @@ import android.support.annotation.Nullable; | ||||
| import android.text.SpannableStringBuilder; | ||||
| import android.text.Spanned; | ||||
| 
 | ||||
| import ru.noties.markwon.spans.EmphasisSpan; | ||||
| import ru.noties.markwon.spans.StrongEmphasisSpan; | ||||
| import ru.noties.markwon.core.spans.EmphasisSpan; | ||||
| import ru.noties.markwon.core.spans.StrongEmphasisSpan; | ||||
| 
 | ||||
| public class Prism4jThemeDarkula extends Prism4jThemeBase { | ||||
| 
 | ||||
|  | ||||
| @ -7,8 +7,8 @@ import android.text.SpannableStringBuilder; | ||||
| import android.text.Spanned; | ||||
| import android.text.style.BackgroundColorSpan; | ||||
| 
 | ||||
| import ru.noties.markwon.spans.EmphasisSpan; | ||||
| import ru.noties.markwon.spans.StrongEmphasisSpan; | ||||
| import ru.noties.markwon.core.spans.EmphasisSpan; | ||||
| import ru.noties.markwon.core.spans.StrongEmphasisSpan; | ||||
| 
 | ||||
| public class Prism4jThemeDefault extends Prism4jThemeBase { | ||||
| 
 | ||||
|  | ||||
| @ -5,7 +5,7 @@ import android.support.annotation.Nullable; | ||||
| 
 | ||||
| import ru.noties.markwon.AbstractMarkwonPlugin; | ||||
| import ru.noties.markwon.MarkwonConfiguration; | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| import ru.noties.prism4j.Prism4j; | ||||
| 
 | ||||
| public class SyntaxHighlightPlugin extends AbstractMarkwonPlugin { | ||||
|  | ||||
| @ -4,7 +4,7 @@ import android.content.Context; | ||||
| import android.support.annotation.NonNull; | ||||
| 
 | ||||
| import ru.noties.markwon.MarkwonConfiguration; | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| import ru.noties.markwon.view.IMarkwonView; | ||||
| 
 | ||||
| public class DebugConfigurationProvider implements IMarkwonView.ConfigurationProvider { | ||||
|  | ||||
| @ -60,7 +60,7 @@ public class MarkwonViewHelper implements IMarkwonView { | ||||
|         this.provider = provider; | ||||
|         this.configuration = provider.provide(textView.getContext()); | ||||
|         if (!TextUtils.isEmpty(markdown)) { | ||||
|             // invalidate rendered toMarkdown | ||||
|             // invalidate rendered markdown | ||||
|             setMarkdown(markdown); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -7,7 +7,7 @@ import org.commonmark.node.Node; | ||||
| import org.commonmark.parser.Parser; | ||||
| 
 | ||||
| import ru.noties.markwon.image.AsyncDrawableLoader; | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| 
 | ||||
| public abstract class AbstractMarkwonPlugin implements MarkwonPlugin { | ||||
|     @Override | ||||
|  | ||||
| @ -9,7 +9,7 @@ import android.support.annotation.NonNull; | ||||
| import android.util.Log; | ||||
| import android.view.View; | ||||
| 
 | ||||
| import ru.noties.markwon.spans.LinkSpan; | ||||
| import ru.noties.markwon.core.spans.LinkSpan; | ||||
| 
 | ||||
| public class LinkResolverDef implements LinkSpan.Resolver { | ||||
|     @Override | ||||
|  | ||||
| @ -11,7 +11,7 @@ import java.util.Collections; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import ru.noties.markwon.image.AsyncDrawableLoader; | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| 
 | ||||
| class MarkwonBuilderImpl implements Markwon.Builder { | ||||
| 
 | ||||
|  | ||||
| @ -3,11 +3,15 @@ package ru.noties.markwon; | ||||
| import android.content.Context; | ||||
| import android.support.annotation.NonNull; | ||||
| 
 | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| import ru.noties.markwon.core.spans.LinkSpan; | ||||
| import ru.noties.markwon.image.AsyncDrawableLoader; | ||||
| import ru.noties.markwon.image.ImageSizeResolver; | ||||
| import ru.noties.markwon.image.ImageSizeResolverDef; | ||||
| import ru.noties.markwon.spans.LinkSpan; | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.syntax.SyntaxHighlight; | ||||
| import ru.noties.markwon.syntax.SyntaxHighlightNoOp; | ||||
| import ru.noties.markwon.urlprocessor.UrlProcessor; | ||||
| import ru.noties.markwon.urlprocessor.UrlProcessorNoOp; | ||||
| 
 | ||||
| /** | ||||
|  * since 3.0.0 renamed `SpannableConfiguration` -> `MarkwonConfiguration` | ||||
| @ -27,7 +31,6 @@ public class MarkwonConfiguration { | ||||
|         return new Builder(context); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     private final MarkwonTheme theme; | ||||
|     private final AsyncDrawableLoader asyncDrawableLoader; | ||||
|     private final SyntaxHighlight syntaxHighlight; | ||||
| @ -46,14 +49,6 @@ public class MarkwonConfiguration { | ||||
|         this.factory = builder.factory; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns a new builder based on this configuration | ||||
|      */ | ||||
|     @NonNull | ||||
|     public Builder newBuilder(@NonNull Context context) { | ||||
|         return new Builder(context, this); | ||||
|     } | ||||
| 
 | ||||
|     @NonNull | ||||
|     public MarkwonTheme theme() { | ||||
|         return theme; | ||||
| @ -106,17 +101,6 @@ public class MarkwonConfiguration { | ||||
|             this.context = context; | ||||
|         } | ||||
| 
 | ||||
|         Builder(@NonNull Context context, @NonNull MarkwonConfiguration configuration) { | ||||
|             this(context); | ||||
|             this.theme = configuration.theme; | ||||
|             this.asyncDrawableLoader = configuration.asyncDrawableLoader; | ||||
|             this.syntaxHighlight = configuration.syntaxHighlight; | ||||
|             this.linkResolver = configuration.linkResolver; | ||||
|             this.urlProcessor = configuration.urlProcessor; | ||||
|             this.imageSizeResolver = configuration.imageSizeResolver; | ||||
|             this.factory = configuration.factory; | ||||
|         } | ||||
| 
 | ||||
|         @NonNull | ||||
|         public Builder syntaxHighlight(@NonNull SyntaxHighlight syntaxHighlight) { | ||||
|             this.syntaxHighlight = syntaxHighlight; | ||||
|  | ||||
| @ -7,7 +7,7 @@ import org.commonmark.node.Node; | ||||
| import org.commonmark.parser.Parser; | ||||
| 
 | ||||
| import ru.noties.markwon.image.AsyncDrawableLoader; | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| 
 | ||||
| public interface MarkwonPlugin { | ||||
| 
 | ||||
|  | ||||
| @ -6,7 +6,7 @@ import android.support.annotation.Nullable; | ||||
| import org.commonmark.node.Node; | ||||
| import org.commonmark.node.Visitor; | ||||
| 
 | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| 
 | ||||
| public interface MarkwonVisitor extends Visitor { | ||||
| 
 | ||||
|  | ||||
| @ -31,7 +31,7 @@ import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| 
 | ||||
| class MarkwonVisitorImpl implements MarkwonVisitor { | ||||
| 
 | ||||
| @ -43,7 +43,7 @@ class MarkwonVisitorImpl implements MarkwonVisitor { | ||||
| 
 | ||||
|     private final SpannableBuilder builder = new SpannableBuilder(); | ||||
| 
 | ||||
|     private MarkwonVisitorImpl( | ||||
|     MarkwonVisitorImpl( | ||||
|             @NonNull MarkwonConfiguration configuration, | ||||
|             @NonNull Map<Class<? extends Node>, NodeVisitor<? extends Node>> nodes) { | ||||
|         this.configuration = configuration; | ||||
|  | ||||
| @ -6,8 +6,8 @@ import android.support.annotation.Nullable; | ||||
| import ru.noties.markwon.image.AsyncDrawableLoader; | ||||
| import ru.noties.markwon.image.ImageSize; | ||||
| import ru.noties.markwon.image.ImageSizeResolver; | ||||
| import ru.noties.markwon.spans.LinkSpan; | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.core.spans.LinkSpan; | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| 
 | ||||
| /** | ||||
|  * Each method can return null or a Span object or an array of spans | ||||
|  | ||||
| @ -7,17 +7,17 @@ import ru.noties.markwon.image.AsyncDrawable; | ||||
| import ru.noties.markwon.image.AsyncDrawableLoader; | ||||
| import ru.noties.markwon.image.ImageSize; | ||||
| import ru.noties.markwon.image.ImageSizeResolver; | ||||
| import ru.noties.markwon.spans.AsyncDrawableSpan; | ||||
| import ru.noties.markwon.spans.BlockQuoteSpan; | ||||
| import ru.noties.markwon.spans.BulletListItemSpan; | ||||
| import ru.noties.markwon.spans.CodeSpan; | ||||
| import ru.noties.markwon.spans.EmphasisSpan; | ||||
| import ru.noties.markwon.spans.HeadingSpan; | ||||
| import ru.noties.markwon.spans.LinkSpan; | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.spans.OrderedListItemSpan; | ||||
| import ru.noties.markwon.spans.StrongEmphasisSpan; | ||||
| import ru.noties.markwon.spans.ThematicBreakSpan; | ||||
| import ru.noties.markwon.core.spans.AsyncDrawableSpan; | ||||
| import ru.noties.markwon.core.spans.BlockQuoteSpan; | ||||
| import ru.noties.markwon.core.spans.BulletListItemSpan; | ||||
| import ru.noties.markwon.core.spans.CodeSpan; | ||||
| import ru.noties.markwon.core.spans.EmphasisSpan; | ||||
| import ru.noties.markwon.core.spans.HeadingSpan; | ||||
| import ru.noties.markwon.core.spans.LinkSpan; | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| import ru.noties.markwon.core.spans.OrderedListItemSpan; | ||||
| import ru.noties.markwon.core.spans.StrongEmphasisSpan; | ||||
| import ru.noties.markwon.core.spans.ThematicBreakSpan; | ||||
| 
 | ||||
| /** | ||||
|  * @since 1.1.0 | ||||
|  | ||||
| @ -36,7 +36,7 @@ import ru.noties.markwon.core.visitor.SoftLineBreakNodeVisitor; | ||||
| import ru.noties.markwon.core.visitor.StrongEmphasisNodeVisitor; | ||||
| import ru.noties.markwon.core.visitor.TextNodeVisitor; | ||||
| import ru.noties.markwon.core.visitor.ThematicBreakNodeVisitor; | ||||
| import ru.noties.markwon.spans.OrderedListItemSpan; | ||||
| import ru.noties.markwon.core.spans.OrderedListItemSpan; | ||||
| 
 | ||||
| public class CorePlugin extends AbstractMarkwonPlugin { | ||||
| 
 | ||||
|  | ||||
| @ -1,9 +1,8 @@ | ||||
| package ru.noties.markwon.spans; | ||||
| package ru.noties.markwon.core; | ||||
| 
 | ||||
| import android.content.Context; | ||||
| import android.graphics.Paint; | ||||
| import android.graphics.Typeface; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.support.annotation.ColorInt; | ||||
| import android.support.annotation.FloatRange; | ||||
| import android.support.annotation.IntRange; | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.spans; | ||||
| package ru.noties.markwon.core.spans; | ||||
| 
 | ||||
| import android.graphics.Canvas; | ||||
| import android.graphics.Paint; | ||||
| @ -12,6 +12,7 @@ import android.text.style.ReplacementSpan; | ||||
| import java.lang.annotation.Retention; | ||||
| import java.lang.annotation.RetentionPolicy; | ||||
| 
 | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| import ru.noties.markwon.image.AsyncDrawable; | ||||
| 
 | ||||
| @SuppressWarnings("WeakerAccess") | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.spans; | ||||
| package ru.noties.markwon.core.spans; | ||||
| 
 | ||||
| import android.graphics.Canvas; | ||||
| import android.graphics.Paint; | ||||
| @ -7,6 +7,8 @@ import android.support.annotation.NonNull; | ||||
| import android.text.Layout; | ||||
| import android.text.style.LeadingMarginSpan; | ||||
| 
 | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| 
 | ||||
| public class BlockQuoteSpan implements LeadingMarginSpan { | ||||
| 
 | ||||
|     private final MarkwonTheme theme; | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.spans; | ||||
| package ru.noties.markwon.core.spans; | ||||
| 
 | ||||
| import android.graphics.Canvas; | ||||
| import android.graphics.Paint; | ||||
| @ -9,6 +9,7 @@ import android.support.annotation.NonNull; | ||||
| import android.text.Layout; | ||||
| import android.text.style.LeadingMarginSpan; | ||||
| 
 | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| import ru.noties.markwon.utils.LeadingMarginUtils; | ||||
| 
 | ||||
| public class BulletListItemSpan implements LeadingMarginSpan { | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.spans; | ||||
| package ru.noties.markwon.core.spans; | ||||
| 
 | ||||
| import android.graphics.Canvas; | ||||
| import android.graphics.Paint; | ||||
| @ -9,6 +9,8 @@ import android.text.TextPaint; | ||||
| import android.text.style.LeadingMarginSpan; | ||||
| import android.text.style.MetricAffectingSpan; | ||||
| 
 | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| 
 | ||||
| public class CodeSpan extends MetricAffectingSpan implements LeadingMarginSpan { | ||||
| 
 | ||||
|     private final MarkwonTheme theme; | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.spans; | ||||
| package ru.noties.markwon.core.spans; | ||||
| 
 | ||||
| import android.text.TextPaint; | ||||
| import android.text.style.MetricAffectingSpan; | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.spans; | ||||
| package ru.noties.markwon.core.spans; | ||||
| 
 | ||||
| import android.graphics.Canvas; | ||||
| import android.graphics.Paint; | ||||
| @ -10,6 +10,7 @@ import android.text.TextPaint; | ||||
| import android.text.style.LeadingMarginSpan; | ||||
| import android.text.style.MetricAffectingSpan; | ||||
| 
 | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| import ru.noties.markwon.utils.LeadingMarginUtils; | ||||
| 
 | ||||
| public class HeadingSpan extends MetricAffectingSpan implements LeadingMarginSpan { | ||||
| @ -1,10 +1,12 @@ | ||||
| package ru.noties.markwon.spans; | ||||
| package ru.noties.markwon.core.spans; | ||||
| 
 | ||||
| import android.support.annotation.NonNull; | ||||
| import android.text.TextPaint; | ||||
| import android.text.style.URLSpan; | ||||
| import android.view.View; | ||||
| 
 | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| 
 | ||||
| public class LinkSpan extends URLSpan { | ||||
| 
 | ||||
|     public interface Resolver { | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.spans; | ||||
| package ru.noties.markwon.core.spans; | ||||
| 
 | ||||
| import android.graphics.Paint; | ||||
| import android.graphics.Rect; | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.spans; | ||||
| package ru.noties.markwon.core.spans; | ||||
| 
 | ||||
| import android.graphics.Canvas; | ||||
| import android.graphics.Paint; | ||||
| @ -9,6 +9,7 @@ import android.text.TextPaint; | ||||
| import android.text.style.LeadingMarginSpan; | ||||
| import android.widget.TextView; | ||||
| 
 | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| import ru.noties.markwon.utils.LeadingMarginUtils; | ||||
| 
 | ||||
| public class OrderedListItemSpan implements LeadingMarginSpan { | ||||
| @ -20,8 +21,8 @@ public class OrderedListItemSpan implements LeadingMarginSpan { | ||||
|      * NB, this method must be called <em>before</em> setting text to a TextView (`TextView#setText` | ||||
|      * internally can trigger new Layout creation which will ask for leading margins right away) | ||||
|      * | ||||
|      * @param textView to which toMarkdown will be applied | ||||
|      * @param text     parsed toMarkdown to process | ||||
|      * @param textView to which markdown will be applied | ||||
|      * @param text     parsed markdown to process | ||||
|      * @since 2.0.1 | ||||
|      */ | ||||
|     public static void measure(@NonNull TextView textView, @NonNull CharSequence text) { | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.spans; | ||||
| package ru.noties.markwon.core.spans; | ||||
| 
 | ||||
| import android.text.TextPaint; | ||||
| import android.text.style.MetricAffectingSpan; | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.spans; | ||||
| package ru.noties.markwon.core.spans; | ||||
| 
 | ||||
| import android.graphics.Canvas; | ||||
| import android.graphics.Paint; | ||||
| @ -7,6 +7,8 @@ import android.support.annotation.NonNull; | ||||
| import android.text.Layout; | ||||
| import android.text.style.LeadingMarginSpan; | ||||
| 
 | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| 
 | ||||
| public class ThematicBreakSpan implements LeadingMarginSpan { | ||||
| 
 | ||||
|     private final MarkwonTheme theme; | ||||
| @ -15,7 +15,7 @@ import java.util.Collections; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import ru.noties.markwon.renderer.R; | ||||
| import ru.noties.markwon.spans.AsyncDrawableSpan; | ||||
| import ru.noties.markwon.core.spans.AsyncDrawableSpan; | ||||
| 
 | ||||
| public abstract class AsyncDrawableScheduler { | ||||
| 
 | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon; | ||||
| package ru.noties.markwon.syntax; | ||||
| 
 | ||||
| import android.support.annotation.NonNull; | ||||
| import android.support.annotation.Nullable; | ||||
| @ -1,9 +1,9 @@ | ||||
| package ru.noties.markwon; | ||||
| package ru.noties.markwon.syntax; | ||||
| 
 | ||||
| import android.support.annotation.NonNull; | ||||
| import android.support.annotation.Nullable; | ||||
| 
 | ||||
| class SyntaxHighlightNoOp implements SyntaxHighlight { | ||||
| public class SyntaxHighlightNoOp implements SyntaxHighlight { | ||||
|     @NonNull | ||||
|     @Override | ||||
|     public CharSequence highlight(@Nullable String info, @NonNull String code) { | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon; | ||||
| package ru.noties.markwon.urlprocessor; | ||||
| 
 | ||||
| import android.support.annotation.NonNull; | ||||
| 
 | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon; | ||||
| package ru.noties.markwon.urlprocessor; | ||||
| 
 | ||||
| import android.net.Uri; | ||||
| import android.support.annotation.NonNull; | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon; | ||||
| package ru.noties.markwon.urlprocessor; | ||||
| 
 | ||||
| import android.support.annotation.NonNull; | ||||
| 
 | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon; | ||||
| package ru.noties.markwon.urlprocessor; | ||||
| 
 | ||||
| import android.support.annotation.NonNull; | ||||
| import android.support.annotation.Nullable; | ||||
| @ -3,8 +3,6 @@ package ru.noties.markwon.utils; | ||||
| import android.content.Context; | ||||
| import android.support.annotation.NonNull; | ||||
| 
 | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| 
 | ||||
| public class Dip { | ||||
| 
 | ||||
|     @NonNull | ||||
|  | ||||
| @ -0,0 +1,16 @@ | ||||
| package ru.noties.markwon; | ||||
| 
 | ||||
| import android.support.annotation.NonNull; | ||||
| 
 | ||||
| import org.commonmark.node.Node; | ||||
| 
 | ||||
| import java.util.Map; | ||||
| 
 | ||||
| public class AbstractMarkwonVisitorImpl extends MarkwonVisitorImpl { | ||||
| 
 | ||||
|     public AbstractMarkwonVisitorImpl( | ||||
|             @NonNull MarkwonConfiguration configuration, | ||||
|             @NonNull Map<Class<? extends Node>, NodeVisitor<? extends Node>> nodes) { | ||||
|         super(configuration, nodes); | ||||
|     } | ||||
| } | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.spans; | ||||
| package ru.noties.markwon.image; | ||||
| 
 | ||||
| import android.graphics.Canvas; | ||||
| import android.graphics.ColorFilter; | ||||
| @ -13,10 +13,6 @@ import org.junit.runner.RunWith; | ||||
| import org.robolectric.RobolectricTestRunner; | ||||
| import org.robolectric.annotation.Config; | ||||
| 
 | ||||
| import ru.noties.markwon.renderer.ImageSize; | ||||
| import ru.noties.markwon.renderer.ImageSizeResolver; | ||||
| import ru.noties.markwon.renderer.ImageSizeResolverDef; | ||||
| 
 | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertFalse; | ||||
| import static org.junit.Assert.assertNotNull; | ||||
| @ -40,7 +36,7 @@ public class AsyncDrawableTest { | ||||
|         // when drawable have no known dimensions yet, it will await for them | ||||
| 
 | ||||
|         final AsyncDrawable drawable = new AsyncDrawable("", | ||||
|                 mock(AsyncDrawable.Loader.class), | ||||
|                 mock(AsyncDrawableLoader.class), | ||||
|                 imageSizeResolver, | ||||
|                 new ImageSize(new ImageSize.Dimension(100.F, "%"), null)); | ||||
| 
 | ||||
| @ -65,7 +61,7 @@ public class AsyncDrawableTest { | ||||
|         // when result is present it will be detached (setCallback(null)) | ||||
| 
 | ||||
|         final AsyncDrawable drawable = new AsyncDrawable("", | ||||
|                 mock(AsyncDrawable.Loader.class), | ||||
|                 mock(AsyncDrawableLoader.class), | ||||
|                 imageSizeResolver, | ||||
|                 null); | ||||
| 
 | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.renderer; | ||||
| package ru.noties.markwon.image; | ||||
| 
 | ||||
| import android.graphics.Rect; | ||||
| 
 | ||||
| @ -1,53 +0,0 @@ | ||||
| package ru.noties.markwon.renderer; | ||||
| 
 | ||||
| import org.junit.Test; | ||||
| 
 | ||||
| import ru.noties.markwon.MarkwonConfiguration; | ||||
| import ru.noties.markwon.SpannableFactory; | ||||
| import ru.noties.markwon.SyntaxHighlight; | ||||
| import ru.noties.markwon.UrlProcessor; | ||||
| import ru.noties.markwon.html.api.MarkwonHtmlParser; | ||||
| import ru.noties.markwon.html.MarkwonHtmlRenderer; | ||||
| import ru.noties.markwon.image.AsyncDrawable; | ||||
| import ru.noties.markwon.image.ImageSizeResolver; | ||||
| import ru.noties.markwon.spans.LinkSpan; | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| 
 | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.mockito.Mockito.mock; | ||||
| public class MarkwonConfigurationTest { | ||||
| 
 | ||||
|     @Test | ||||
|     public void testNewBuilder() { | ||||
|         final MarkwonConfiguration configuration = MarkwonConfiguration | ||||
|                 .builder(null) | ||||
|                 .theme(mock(MarkwonTheme.class)) | ||||
|                 .asyncDrawableLoader(mock(AsyncDrawable.Loader.class)) | ||||
|                 .syntaxHighlight(mock(SyntaxHighlight.class)) | ||||
|                 .linkResolver(mock(LinkSpan.Resolver.class)) | ||||
|                 .urlProcessor(mock(UrlProcessor.class)) | ||||
|                 .imageSizeResolver(mock(ImageSizeResolver.class)) | ||||
|                 .factory(mock(SpannableFactory.class)) | ||||
|                 .softBreakAddsNewLine(true) | ||||
|                 .htmlParser(mock(MarkwonHtmlParser.class)) | ||||
|                 .htmlRenderer(mock(MarkwonHtmlRenderer.class)) | ||||
|                 .htmlAllowNonClosedTags(true) | ||||
|                 .build(); | ||||
| 
 | ||||
|         final MarkwonConfiguration newConfiguration = configuration | ||||
|                 .newBuilder(null) | ||||
|                 .build(); | ||||
| 
 | ||||
|         assertEquals(configuration.theme(), newConfiguration.theme()); | ||||
|         assertEquals(configuration.asyncDrawableLoader(), newConfiguration.asyncDrawableLoader()); | ||||
|         assertEquals(configuration.syntaxHighlight(), newConfiguration.syntaxHighlight()); | ||||
|         assertEquals(configuration.linkResolver(), newConfiguration.linkResolver()); | ||||
|         assertEquals(configuration.urlProcessor(), newConfiguration.urlProcessor()); | ||||
|         assertEquals(configuration.imageSizeResolver(), newConfiguration.imageSizeResolver()); | ||||
|         assertEquals(configuration.factory(), newConfiguration.factory()); | ||||
|         assertEquals(configuration.softBreakAddsNewLine(), newConfiguration.softBreakAddsNewLine()); | ||||
|         assertEquals(configuration.htmlParser(), newConfiguration.htmlParser()); | ||||
|         assertEquals(configuration.htmlRenderer(), newConfiguration.htmlRenderer()); | ||||
|         assertEquals(configuration.htmlAllowNonClosedTags(), newConfiguration.htmlAllowNonClosedTags()); | ||||
|     } | ||||
| } | ||||
| @ -1,239 +0,0 @@ | ||||
| package ru.noties.markwon.renderer.html2; | ||||
| 
 | ||||
| import android.support.annotation.NonNull; | ||||
| 
 | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| import org.robolectric.RobolectricTestRunner; | ||||
| import org.robolectric.annotation.Config; | ||||
| 
 | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import ix.Ix; | ||||
| import ix.IxFunction; | ||||
| import ru.noties.markwon.test.TestUtils; | ||||
| 
 | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertNotNull; | ||||
| import static ru.noties.markwon.test.TestUtils.with; | ||||
| 
 | ||||
| @RunWith(RobolectricTestRunner.class) | ||||
| @Config(manifest = Config.NONE) | ||||
| public class CssInlineStyleParserTest { | ||||
| 
 | ||||
|     private CssInlineStyleParser.Impl impl; | ||||
| 
 | ||||
|     @Before | ||||
|     public void before() { | ||||
|         impl = new CssInlineStyleParser.Impl(); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void simple_single_pair() { | ||||
| 
 | ||||
|         final String input = "key: value;"; | ||||
| 
 | ||||
|         final List<CssProperty> list = listProperties(input); | ||||
| 
 | ||||
|         assertEquals(1, list.size()); | ||||
| 
 | ||||
|         with(list.get(0), new TestUtils.Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key", cssProperty.key()); | ||||
|                 assertEquals("value", cssProperty.value()); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void simple_two_pairs() { | ||||
| 
 | ||||
|         final String input = "key1: value1; key2: value2;"; | ||||
| 
 | ||||
|         final List<CssProperty> list = listProperties(input); | ||||
| 
 | ||||
|         assertEquals(2, list.size()); | ||||
| 
 | ||||
|         with(list.get(0), new TestUtils.Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key1", cssProperty.key()); | ||||
|                 assertEquals("value1", cssProperty.value()); | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         with(list.get(1), new TestUtils.Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key2", cssProperty.key()); | ||||
|                 assertEquals("value2", cssProperty.value()); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void one_pair_eof() { | ||||
| 
 | ||||
|         final String input = "key: value"; | ||||
|         final List<CssProperty> list = listProperties(input); | ||||
|         assertEquals(1, list.size()); | ||||
| 
 | ||||
|         with(list.get(0), new TestUtils.Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key", cssProperty.key()); | ||||
|                 assertEquals("value", cssProperty.value()); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void one_pair_eof_whitespaces() { | ||||
| 
 | ||||
|         final String input = "key: value         \n\n\t"; | ||||
|         final List<CssProperty> list = listProperties(input); | ||||
|         assertEquals(1, list.size()); | ||||
| 
 | ||||
|         with(list.get(0), new TestUtils.Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key", cssProperty.key()); | ||||
|                 assertEquals("value", cssProperty.value()); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void white_spaces() { | ||||
| 
 | ||||
|         final String input = "\n\n\n\t    \t key1 \n\n\n\t  : \n\n\n\n   \t value1    \n\n\n\n    ; \n key2\n : \n value2 \n ; "; | ||||
|         final List<CssProperty> list = listProperties(input); | ||||
|         assertEquals(2, list.size()); | ||||
| 
 | ||||
|         with(list.get(0), new TestUtils.Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key1", cssProperty.key()); | ||||
|                 assertEquals("value1", cssProperty.value()); | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         with(list.get(1), new TestUtils.Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key2", cssProperty.key()); | ||||
|                 assertEquals("value2", cssProperty.value()); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void list_of_keys() { | ||||
| 
 | ||||
|         final String input = "key1 key2 key3 key4"; | ||||
|         final List<CssProperty> list = listProperties(input); | ||||
| 
 | ||||
|         assertEquals(0, list.size()); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void list_of_keys_and_value() { | ||||
| 
 | ||||
|         final String input = "key1 key2 key3 key4: value4"; | ||||
|         final List<CssProperty> list = listProperties(input); | ||||
|         assertEquals(1, list.size()); | ||||
| 
 | ||||
|         with(list.get(0), new TestUtils.Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key4", cssProperty.key()); | ||||
|                 assertEquals("value4", cssProperty.value()); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void list_of_keys_separated_by_semi_colon() { | ||||
| 
 | ||||
|         final String input = "key1;key2;key3;key4;"; | ||||
|         final List<CssProperty> list = listProperties(input); | ||||
|         assertEquals(0, list.size()); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void key_value_with_invalid_between() { | ||||
| 
 | ||||
|         final String input = "key1: value1; key2 key3: value3;"; | ||||
|         final List<CssProperty> list = listProperties(input); | ||||
| 
 | ||||
|         assertEquals(2, list.size()); | ||||
| 
 | ||||
|         with(list.get(0), new TestUtils.Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key1", cssProperty.key()); | ||||
|                 assertEquals("value1", cssProperty.value()); | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         with(list.get(1), new TestUtils.Action<CssProperty>() { | ||||
|             @Override | ||||
|             public void apply(@NonNull CssProperty cssProperty) { | ||||
|                 assertEquals("key3", cssProperty.key()); | ||||
|                 assertEquals("value3", cssProperty.value()); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void css_functions() { | ||||
| 
 | ||||
|         final Map<String, String> map = new HashMap<String, String>() {{ | ||||
|             put("attr", "\" (\" attr(href) \")\""); | ||||
|             put("calc", "calc(100% - 100px)"); | ||||
|             put("cubic-bezier", "cubic-bezier(0.1, 0.7, 1.0, 0.1)"); | ||||
|             put("hsl", "hsl(120,100%,50%)"); | ||||
|             put("hsla", "hsla(120,100%,50%,0.3)"); | ||||
|             put("linear-gradient", "linear-gradient(red, yellow, blue)"); | ||||
|             put("radial-gradient", "radial-gradient(red, green, blue)"); | ||||
|             put("repeating-linear-gradient", "repeating-linear-gradient(red, yellow 10%, green 20%)"); | ||||
|             put("repeating-radial-gradient", "repeating-radial-gradient(red, yellow 10%, green 15%)"); | ||||
|             put("rgb", "rgb(255,0,0)"); | ||||
|             put("rgba", "rgba(255,0,0,0.3)"); | ||||
|             put("var", "var(--some-variable)"); | ||||
|             put("url", "url(\"url.gif\")"); | ||||
|         }}; | ||||
| 
 | ||||
|         final StringBuilder builder = new StringBuilder(); | ||||
|         for (Map.Entry<String, String> entry: map.entrySet()) { | ||||
|             builder.append(entry.getKey()) | ||||
|                     .append(':') | ||||
|                     .append(entry.getValue()) | ||||
|                     .append(';'); | ||||
|         } | ||||
| 
 | ||||
|         for (CssProperty cssProperty: impl.parse(builder.toString())) { | ||||
|             final String value = map.remove(cssProperty.key()); | ||||
|             assertNotNull(cssProperty.key(), value); | ||||
|             assertEquals(cssProperty.key(), value, cssProperty.value()); | ||||
|         } | ||||
| 
 | ||||
|         assertEquals(0, map.size()); | ||||
|     } | ||||
| 
 | ||||
|     @NonNull | ||||
|     private List<CssProperty> listProperties(@NonNull String input) { | ||||
|         return Ix.from(impl.parse(input)) | ||||
|                 .map(new IxFunction<CssProperty, CssProperty>() { | ||||
|                     @Override | ||||
|                     public CssProperty apply(CssProperty cssProperty) { | ||||
|                         return cssProperty.mutate(); | ||||
|                     } | ||||
|                 }) | ||||
|                 .toList(); | ||||
|     } | ||||
| } | ||||
| @ -1,186 +0,0 @@ | ||||
| package ru.noties.markwon.renderer.html2.tag; | ||||
| 
 | ||||
| import android.support.annotation.NonNull; | ||||
| import android.support.annotation.Nullable; | ||||
| 
 | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| import org.robolectric.RobolectricTestRunner; | ||||
| import org.robolectric.annotation.Config; | ||||
| 
 | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import ru.noties.markwon.image.ImageSize; | ||||
| import ru.noties.markwon.renderer.html2.CssInlineStyleParser; | ||||
| 
 | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertNotNull; | ||||
| import static org.junit.Assert.assertNull; | ||||
| 
 | ||||
| @RunWith(RobolectricTestRunner.class) | ||||
| @Config(manifest = Config.NONE) | ||||
| public class ImageSizeParserImplTest { | ||||
| 
 | ||||
|     private static final float DELTA = 1e-7F; | ||||
| 
 | ||||
|     private ImageSizeParserImpl impl; | ||||
| 
 | ||||
|     @Before | ||||
|     public void before() { | ||||
|         impl = new ImageSizeParserImpl(CssInlineStyleParser.create()); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void nothing() { | ||||
|         assertNull(impl.parse(Collections.<String, String>emptyMap())); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void width_height_from_style() { | ||||
| 
 | ||||
|         final String style = "width: 123; height: 321"; | ||||
| 
 | ||||
|         assertImageSize( | ||||
|                 new ImageSize(dimension(123, null), dimension(321, null)), | ||||
|                 impl.parse(Collections.singletonMap("style", style)) | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void style_has_higher_priority_width() { | ||||
| 
 | ||||
|         // if property is found in styles, do not lookup raw attribute | ||||
|         final Map<String, String> attributes = new HashMap<String, String>() {{ | ||||
|             put("style", "width: 43"); | ||||
|             put("width", "991"); | ||||
|         }}; | ||||
| 
 | ||||
|         assertImageSize( | ||||
|                 new ImageSize(dimension(43, null), null), | ||||
|                 impl.parse(attributes) | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void style_has_higher_priority_height() { | ||||
| 
 | ||||
|         // if property is found in styles, do not lookup raw attribute | ||||
|         final Map<String, String> attributes = new HashMap<String, String>() {{ | ||||
|             put("style", "height: 177"); | ||||
|             put("height", "8"); | ||||
|         }}; | ||||
| 
 | ||||
|         assertImageSize( | ||||
|                 new ImageSize(null, dimension(177, null)), | ||||
|                 impl.parse(attributes) | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void width_style_height_attributes() { | ||||
| 
 | ||||
|         final Map<String, String> attributes = new HashMap<String, String>() {{ | ||||
|             put("style", "width: 99"); | ||||
|             put("height", "7"); | ||||
|         }}; | ||||
| 
 | ||||
|         assertImageSize( | ||||
|                 new ImageSize(dimension(99, null), dimension(7, null)), | ||||
|                 impl.parse(attributes) | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void height_style_width_attributes() { | ||||
| 
 | ||||
|         final Map<String, String> attributes = new HashMap<String, String>() {{ | ||||
|             put("style", "height: 15"); | ||||
|             put("width", "88"); | ||||
|         }}; | ||||
| 
 | ||||
|         assertImageSize( | ||||
|                 new ImageSize(dimension(88, null), dimension(15, null)), | ||||
|                 impl.parse(attributes) | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void non_empty_styles_width_height_attributes() { | ||||
| 
 | ||||
|         final Map<String, String> attributes = new HashMap<String, String>() {{ | ||||
|             put("style", "key1: value1; width0: 123; height0: 99"); | ||||
|             put("width", "40"); | ||||
|             put("height", "77"); | ||||
|         }}; | ||||
| 
 | ||||
|         assertImageSize( | ||||
|                 new ImageSize(dimension(40, null), dimension(77, null)), | ||||
|                 impl.parse(attributes) | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void dimension_units() { | ||||
| 
 | ||||
|         final Map<String, ImageSize.Dimension> map = new HashMap<String, ImageSize.Dimension>() {{ | ||||
|             put("100", dimension(100, null)); | ||||
|             put("100%", dimension(100, "%")); | ||||
|             put("1%", dimension(1, "%")); | ||||
|             put("0.2em", dimension(0.2F, "em")); | ||||
|             put("155px", dimension(155, "px")); | ||||
|             put("67blah", dimension(67, "blah")); | ||||
|             put("-1", dimension(-1, null)); | ||||
|             put("-0.01pt", dimension(-0.01F, "pt")); | ||||
|         }}; | ||||
| 
 | ||||
|         for (Map.Entry<String, ImageSize.Dimension> entry : map.entrySet()) { | ||||
|             assertDimension(entry.getKey(), entry.getValue(), impl.dimension(entry.getKey())); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void bad_dimension() { | ||||
| 
 | ||||
|         final String[] dimensions = { | ||||
|                 "calc(5px + 10rem)", | ||||
|                 "whataver6", | ||||
|                 "165 165", | ||||
|                 "!@#$%^&*(%" | ||||
|         }; | ||||
| 
 | ||||
|         for (String dimension: dimensions) { | ||||
|             assertNull(dimension, impl.dimension(dimension)); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private static void assertImageSize(@Nullable ImageSize expected, @Nullable ImageSize actual) { | ||||
|         if (expected == null) { | ||||
|             assertNull(actual); | ||||
|         } else { | ||||
|             assertNotNull(actual); | ||||
|             assertDimension("width", expected.width, actual.width); | ||||
|             assertDimension("height", expected.height, actual.height); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private static void assertDimension( | ||||
|             @NonNull String name, | ||||
|             @Nullable ImageSize.Dimension expected, | ||||
|             @Nullable ImageSize.Dimension actual) { | ||||
|         if (expected == null) { | ||||
|             assertNull(name, actual); | ||||
|         } else { | ||||
|             assertNotNull(name, actual); | ||||
|             assertEquals(name, expected.value, actual.value, DELTA); | ||||
|             assertEquals(name, expected.unit, actual.unit); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @NonNull | ||||
|     private static ImageSize.Dimension dimension(float value, @Nullable String unit) { | ||||
|         return new ImageSize.Dimension(value, unit); | ||||
|     } | ||||
| } | ||||
| @ -1,25 +1,23 @@ | ||||
| package ru.noties.markwon.renderer.visitor; | ||||
| 
 | ||||
| import android.content.Context; | ||||
| import android.support.annotation.NonNull; | ||||
| import android.text.SpannableStringBuilder; | ||||
| 
 | ||||
| import org.commonmark.node.Node; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| import org.robolectric.ParameterizedRobolectricTestRunner; | ||||
| import org.robolectric.RuntimeEnvironment; | ||||
| import org.robolectric.annotation.Config; | ||||
| 
 | ||||
| import java.util.Arrays; | ||||
| import java.util.Collection; | ||||
| 
 | ||||
| import ru.noties.markwon.LinkResolverDef; | ||||
| import ru.noties.markwon.AbstractMarkwonPlugin; | ||||
| import ru.noties.markwon.Markwon; | ||||
| import ru.noties.markwon.MarkwonConfiguration; | ||||
| import ru.noties.markwon.SpannableBuilder; | ||||
| import ru.noties.markwon.SpannableFactory; | ||||
| import ru.noties.markwon.html.api.MarkwonHtmlParser; | ||||
| import ru.noties.markwon.renderer.SpannableMarkdownVisitor; | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.core.CorePlugin; | ||||
| import ru.noties.markwon.image.ImagesPlugin; | ||||
| 
 | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.mockito.Mockito.mock; | ||||
| @ -44,13 +42,10 @@ public class SpannableMarkdownVisitorTest { | ||||
| 
 | ||||
|         final TestData data = TestDataReader.readTest(file); | ||||
|          | ||||
|         final MarkwonConfiguration configuration = configuration(data.config()); | ||||
|         final SpannableBuilder builder = new SpannableBuilder(); | ||||
|         final SpannableMarkdownVisitor visitor = new SpannableMarkdownVisitor(configuration, builder); | ||||
|         final Node node = Markwon.createParser().parse(data.input()); | ||||
|         node.accept(visitor); | ||||
|         final Markwon markwon = markwon(data.config()); | ||||
| 
 | ||||
|         final SpannableStringBuilder stringBuilder = builder.spannableStringBuilder(); | ||||
|         // okay we must thing about it... casting? | ||||
|         final SpannableStringBuilder stringBuilder = (SpannableStringBuilder) markwon.toMarkdown(data.input()); | ||||
| 
 | ||||
|         final TestValidator validator = TestValidator.create(file); | ||||
| 
 | ||||
| @ -71,25 +66,18 @@ public class SpannableMarkdownVisitorTest { | ||||
|         assertEquals(Arrays.toString(spans), validator.processedSpanNodesCount(), length); | ||||
|     } | ||||
| 
 | ||||
|     @SuppressWarnings("ConstantConditions") | ||||
| 
 | ||||
|     @NonNull | ||||
|     private MarkwonConfiguration configuration(@NonNull TestConfig config) { | ||||
| 
 | ||||
|         final SpannableFactory factory = new TestFactory(config.hasOption(TestConfig.USE_PARAGRAPHS)); | ||||
|         final MarkwonHtmlParser htmlParser = config.hasOption(TestConfig.USE_HTML) | ||||
|                 ? null | ||||
|                 : MarkwonHtmlParser.noOp(); | ||||
| 
 | ||||
|         final boolean softBreakAddsNewLine = config.hasOption(TestConfig.SOFT_BREAK_ADDS_NEW_LINE); | ||||
|         final boolean htmlAllowNonClosedTags = config.hasOption(TestConfig.HTML_ALLOW_NON_CLOSED_TAGS); | ||||
| 
 | ||||
|         return MarkwonConfiguration.builder(null) | ||||
|                 .theme(mock(MarkwonTheme.class)) | ||||
|                 .linkResolver(mock(LinkResolverDef.class)) | ||||
|                 .htmlParser(htmlParser) | ||||
|                 .factory(factory) | ||||
|                 .softBreakAddsNewLine(softBreakAddsNewLine) | ||||
|                 .htmlAllowNonClosedTags(htmlAllowNonClosedTags) | ||||
|     private Markwon markwon(@NonNull final TestConfig config) { | ||||
|         return Markwon.builder(RuntimeEnvironment.application) | ||||
|                 .use(CorePlugin.create(config.hasOption(TestConfig.SOFT_BREAK_ADDS_NEW_LINE))) | ||||
|                 .use(ImagesPlugin.create(mock(Context.class))) | ||||
|                 .use(new AbstractMarkwonPlugin() { | ||||
|                     @Override | ||||
|                     public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) { | ||||
|                         builder.factory(new TestFactory(config.hasOption(TestConfig.USE_PARAGRAPHS))); | ||||
|                     } | ||||
|                 }) | ||||
|                 .build(); | ||||
|     } | ||||
| } | ||||
| @ -7,9 +7,9 @@ import java.util.Map; | ||||
| class TestConfig { | ||||
| 
 | ||||
|     static final String USE_PARAGRAPHS = "use-paragraphs"; | ||||
|     static final String USE_HTML = "use-html"; | ||||
| //    static final String USE_HTML = "use-html"; | ||||
|     static final String SOFT_BREAK_ADDS_NEW_LINE = "soft-break-adds-new-line"; | ||||
|     static final String HTML_ALLOW_NON_CLOSED_TAGS = "html-allow-non-closed-tags"; | ||||
| //    static final String HTML_ALLOW_NON_CLOSED_TAGS = "html-allow-non-closed-tags"; | ||||
| 
 | ||||
|     private final Map<String, Boolean> map; | ||||
| 
 | ||||
|  | ||||
| @ -30,7 +30,6 @@ import java.util.Set; | ||||
| import ix.Ix; | ||||
| import ix.IxFunction; | ||||
| import ix.IxPredicate; | ||||
| import ru.noties.markwon.table.TableRowSpan; | ||||
| 
 | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.BLOCK_QUOTE; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.BULLET_LIST; | ||||
| @ -42,14 +41,8 @@ import static ru.noties.markwon.renderer.visitor.TestSpan.IMAGE; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.LINK; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.ORDERED_LIST; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.PARAGRAPH; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.STRIKE_THROUGH; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.STRONG_EMPHASIS; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.SUB_SCRIPT; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.SUPER_SCRIPT; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.TABLE_ROW; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.TASK_LIST; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.THEMATIC_BREAK; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.UNDERLINE; | ||||
| 
 | ||||
| abstract class TestDataReader { | ||||
| 
 | ||||
| @ -103,7 +96,7 @@ abstract class TestDataReader { | ||||
|     static class Reader { | ||||
| 
 | ||||
|         private static final String TEXT = "text"; | ||||
|         private static final String CELLS = "cells"; | ||||
| //        private static final String CELLS = "cells"; | ||||
| 
 | ||||
|         private static final Set<String> TAGS; | ||||
| 
 | ||||
| @ -118,15 +111,9 @@ abstract class TestDataReader { | ||||
|                     BULLET_LIST, | ||||
|                     THEMATIC_BREAK, | ||||
|                     HEADING, | ||||
|                     STRIKE_THROUGH, | ||||
|                     TASK_LIST, | ||||
|                     TABLE_ROW, | ||||
|                     PARAGRAPH, | ||||
|                     IMAGE, | ||||
|                     LINK, | ||||
|                     SUPER_SCRIPT, | ||||
|                     SUB_SCRIPT, | ||||
|                     UNDERLINE, | ||||
|                     HEADING + "1", | ||||
|                     HEADING + "2", | ||||
|                     HEADING + "3", | ||||
| @ -250,25 +237,28 @@ abstract class TestDataReader { | ||||
|                         final JsonElement valueElement = object.get(key); | ||||
|                         if (valueElement.isJsonNull()) { | ||||
|                             value = null; | ||||
|                         } else { | ||||
|                             // another special case: table cell | ||||
|                             // this is not so good | ||||
|                             if (CELLS.equals(key)) { | ||||
|                                 final JsonArray cells = valueElement.getAsJsonArray(); | ||||
|                                 final int length = cells.size(); | ||||
|                                 final List<TableRowSpan.Cell> list = new ArrayList<>(length); | ||||
|                                 for (int k = 0; k < length; k++) { | ||||
|                                     final JsonObject cell = cells.get(k).getAsJsonObject(); | ||||
|                                     list.add(new TableRowSpan.Cell( | ||||
|                                             cell.get("alignment").getAsInt(), | ||||
|                                             cell.get("text").getAsString() | ||||
|                                     )); | ||||
|                                 } | ||||
|                                 value = list.toString(); | ||||
|                         } else { | ||||
|                             value = valueElement.getAsString(); | ||||
|                         } | ||||
|                         } | ||||
| //                        else { | ||||
| //                            // another special case: table cell | ||||
| //                            // this is not so good | ||||
| //                            if (CELLS.equals(key)) { | ||||
| //                                final JsonArray cells = valueElement.getAsJsonArray(); | ||||
| //                                final int length = cells.size(); | ||||
| //                                final List<TableRowSpan.Cell> list = new ArrayList<>(length); | ||||
| //                                for (int k = 0; k < length; k++) { | ||||
| //                                    final JsonObject cell = cells.get(k).getAsJsonObject(); | ||||
| //                                    list.add(new TableRowSpan.Cell( | ||||
| //                                            cell.get("alignment").getAsInt(), | ||||
| //                                            cell.get("text").getAsString() | ||||
| //                                    )); | ||||
| //                                } | ||||
| //                                value = list.toString(); | ||||
| //                            } else { | ||||
| //                                value = valueElement.getAsString(); | ||||
| //                            } | ||||
| //                        } | ||||
|                         attributes.put(key, value); | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
| @ -5,16 +5,14 @@ import android.support.annotation.Nullable; | ||||
| 
 | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import ru.noties.markwon.SpannableFactory; | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| import ru.noties.markwon.core.spans.LinkSpan; | ||||
| import ru.noties.markwon.image.AsyncDrawableLoader; | ||||
| import ru.noties.markwon.image.ImageSize; | ||||
| import ru.noties.markwon.image.ImageSizeResolver; | ||||
| import ru.noties.markwon.image.AsyncDrawable; | ||||
| import ru.noties.markwon.spans.LinkSpan; | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.table.TableRowSpan; | ||||
| 
 | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.BLOCK_QUOTE; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.BULLET_LIST; | ||||
| @ -26,14 +24,8 @@ import static ru.noties.markwon.renderer.visitor.TestSpan.IMAGE; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.LINK; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.ORDERED_LIST; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.PARAGRAPH; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.STRIKE_THROUGH; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.STRONG_EMPHASIS; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.SUB_SCRIPT; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.SUPER_SCRIPT; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.TABLE_ROW; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.TASK_LIST; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.THEMATIC_BREAK; | ||||
| import static ru.noties.markwon.renderer.visitor.TestSpan.UNDERLINE; | ||||
| 
 | ||||
| class TestFactory implements SpannableFactory { | ||||
| 
 | ||||
| @ -94,31 +86,6 @@ class TestFactory implements SpannableFactory { | ||||
|         return new TestSpan(HEADING + level); | ||||
|     } | ||||
| 
 | ||||
|     @Nullable | ||||
|     @Override | ||||
|     public Object strikethrough() { | ||||
|         return new TestSpan(STRIKE_THROUGH); | ||||
|     } | ||||
| 
 | ||||
|     @Nullable | ||||
|     @Override | ||||
|     public Object taskListItem(@NonNull MarkwonTheme theme, int blockIndent, boolean isDone) { | ||||
|         return new TestSpan(TASK_LIST, map( | ||||
|                 Pair.of("blockIdent", blockIndent), | ||||
|                 Pair.of("done", isDone) | ||||
|         )); | ||||
|     } | ||||
| 
 | ||||
|     @Nullable | ||||
|     @Override | ||||
|     public Object tableRow(@NonNull MarkwonTheme theme, @NonNull List<TableRowSpan.Cell> cells, boolean isHeader, boolean isOdd) { | ||||
|         return new TestSpan(TABLE_ROW, map( | ||||
|                 Pair.of("cells", cells), | ||||
|                 Pair.of("header", isHeader), | ||||
|                 Pair.of("odd", isOdd) | ||||
|         )); | ||||
|     } | ||||
| 
 | ||||
|     @Nullable | ||||
|     @Override | ||||
|     public Object paragraph(boolean inTightList) { | ||||
| @ -129,7 +96,7 @@ class TestFactory implements SpannableFactory { | ||||
| 
 | ||||
|     @Nullable | ||||
|     @Override | ||||
|     public Object image(@NonNull MarkwonTheme theme, @NonNull String destination, @NonNull AsyncDrawable.Loader loader, @NonNull ImageSizeResolver imageSizeResolver, @Nullable ImageSize imageSize, boolean replacementTextIsLink) { | ||||
|     public Object image(@NonNull MarkwonTheme theme, @NonNull String destination, @NonNull AsyncDrawableLoader loader, @NonNull ImageSizeResolver imageSizeResolver, @Nullable ImageSize imageSize, boolean replacementTextIsLink) { | ||||
|         return new TestSpan(IMAGE, map( | ||||
|                 Pair.of("src", destination), | ||||
|                 Pair.of("imageSize", imageSize), | ||||
| @ -143,24 +110,6 @@ class TestFactory implements SpannableFactory { | ||||
|         return new TestSpan(LINK, map("href", destination)); | ||||
|     } | ||||
| 
 | ||||
|     @Nullable | ||||
|     @Override | ||||
|     public Object superScript(@NonNull MarkwonTheme theme) { | ||||
|         return new TestSpan(SUPER_SCRIPT); | ||||
|     } | ||||
| 
 | ||||
|     @Nullable | ||||
|     @Override | ||||
|     public Object subScript(@NonNull MarkwonTheme theme) { | ||||
|         return new TestSpan(SUB_SCRIPT); | ||||
|     } | ||||
| 
 | ||||
|     @Nullable | ||||
|     @Override | ||||
|     public Object underline() { | ||||
|         return new TestSpan(UNDERLINE); | ||||
|     } | ||||
| 
 | ||||
|     @NonNull | ||||
|     private static Map<String, String> map(@NonNull String key, @Nullable Object value) { | ||||
|         return Collections.singletonMap(key, String.valueOf(value)); | ||||
|  | ||||
| @ -16,15 +16,15 @@ class TestSpan { | ||||
|     static final String BULLET_LIST = "ul"; | ||||
|     static final String THEMATIC_BREAK = "hr"; | ||||
|     static final String HEADING = "h"; | ||||
|     static final String STRIKE_THROUGH = "s"; | ||||
|     static final String TASK_LIST = "task-list"; | ||||
|     static final String TABLE_ROW = "tr"; | ||||
| //    static final String STRIKE_THROUGH = "s"; | ||||
| //    static final String TASK_LIST = "task-list"; | ||||
| //    static final String TABLE_ROW = "tr"; | ||||
|     static final String PARAGRAPH = "p"; | ||||
|     static final String IMAGE = "img"; | ||||
|     static final String LINK = "a"; | ||||
|     static final String SUPER_SCRIPT = "sup"; | ||||
|     static final String SUB_SCRIPT = "sub"; | ||||
|     static final String UNDERLINE = "u"; | ||||
| //    static final String SUPER_SCRIPT = "sup"; | ||||
| //    static final String SUB_SCRIPT = "sub"; | ||||
| //    static final String UNDERLINE = "u"; | ||||
| 
 | ||||
| 
 | ||||
|     private final String name; | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon.renderer; | ||||
| package ru.noties.markwon.syntax; | ||||
| 
 | ||||
| import android.content.Context; | ||||
| import android.os.Build; | ||||
| @ -8,16 +8,23 @@ import android.text.SpannableStringBuilder; | ||||
| import android.text.Spanned; | ||||
| 
 | ||||
| import org.commonmark.node.FencedCodeBlock; | ||||
| import org.commonmark.node.Node; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| import org.robolectric.RobolectricTestRunner; | ||||
| import org.robolectric.annotation.Config; | ||||
| 
 | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import ru.noties.markwon.AbstractMarkwonVisitorImpl; | ||||
| import ru.noties.markwon.MarkwonConfiguration; | ||||
| import ru.noties.markwon.MarkwonVisitor; | ||||
| import ru.noties.markwon.SpannableBuilder; | ||||
| import ru.noties.markwon.SpannableFactory; | ||||
| import ru.noties.markwon.SyntaxHighlight; | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| import ru.noties.markwon.core.visitor.CodeBlockNodeVisitor; | ||||
| import ru.noties.markwon.image.AsyncDrawableLoader; | ||||
| 
 | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertTrue; | ||||
| @ -32,6 +39,8 @@ import static org.mockito.Mockito.when; | ||||
|         Build.VERSION_CODES.M, | ||||
|         Build.VERSION_CODES.O | ||||
| }) | ||||
| // although it is called SyntaxHighlightTest all it does is check that spans are in the correct order | ||||
| // and syntax highlight is the primary user of this functionality | ||||
| public class SyntaxHighlightTest { | ||||
| 
 | ||||
|     // codeSpan must be before actual highlight spans (true reverse of builder) | ||||
| @ -68,10 +77,16 @@ public class SyntaxHighlightTest { | ||||
|         final MarkwonConfiguration configuration = MarkwonConfiguration.builder(mock(Context.class)) | ||||
|                 .syntaxHighlight(highlight) | ||||
|                 .factory(factory) | ||||
|                 .theme(mock(MarkwonTheme.class)) | ||||
|                 .build(); | ||||
|                 .build(mock(MarkwonTheme.class), mock(AsyncDrawableLoader.class)); | ||||
| 
 | ||||
|         final SpannableBuilder builder = new SpannableBuilder(); | ||||
|         final Map<Class<? extends Node>, MarkwonVisitor.NodeVisitor<? extends Node>> visitorMap = new HashMap<>(1); | ||||
|         visitorMap.put(FencedCodeBlock.class, new CodeBlockNodeVisitor.Fenced()); | ||||
| 
 | ||||
|         final MarkwonVisitor visitor = new AbstractMarkwonVisitorImpl( | ||||
|                 configuration, | ||||
|                 visitorMap); | ||||
| 
 | ||||
|         final SpannableBuilder builder = visitor.builder(); | ||||
| 
 | ||||
|         append(builder, "# Header 1\n", new Object()); | ||||
|         append(builder, "## Header 2\n", new Object()); | ||||
| @ -79,11 +94,15 @@ public class SyntaxHighlightTest { | ||||
| 
 | ||||
|         final int start = builder.length(); | ||||
| 
 | ||||
|         final SpannableMarkdownVisitor visitor = new SpannableMarkdownVisitor(configuration, builder); | ||||
|         final FencedCodeBlock fencedCodeBlock = new FencedCodeBlock(); | ||||
|         fencedCodeBlock.setLiteral("{code}"); | ||||
| 
 | ||||
|         visitor.visit(fencedCodeBlock); | ||||
|         CodeBlockNodeVisitor.visitCodeBlock( | ||||
|                 visitor, | ||||
|                 null, | ||||
|                 "{code}", | ||||
|                 fencedCodeBlock | ||||
|         ); | ||||
| 
 | ||||
|         final int end = builder.length(); | ||||
| 
 | ||||
| @ -1,4 +1,4 @@ | ||||
| package ru.noties.markwon; | ||||
| package ru.noties.markwon.urlprocessor; | ||||
| 
 | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| @ -6,8 +6,10 @@ import org.junit.runner.RunWith; | ||||
| import org.robolectric.RobolectricTestRunner; | ||||
| import org.robolectric.annotation.Config; | ||||
| 
 | ||||
| import ru.noties.markwon.urlprocessor.UrlProcessorAndroidAssets; | ||||
| 
 | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static ru.noties.markwon.UrlProcessorAndroidAssets.BASE; | ||||
| import static ru.noties.markwon.urlprocessor.UrlProcessorAndroidAssets.BASE; | ||||
| 
 | ||||
| @RunWith(RobolectricTestRunner.class) | ||||
| @Config(manifest = Config.NONE) | ||||
| @ -1,10 +1,12 @@ | ||||
| package ru.noties.markwon; | ||||
| package ru.noties.markwon.urlprocessor; | ||||
| 
 | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| import org.robolectric.RobolectricTestRunner; | ||||
| import org.robolectric.annotation.Config; | ||||
| 
 | ||||
| import ru.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute; | ||||
| 
 | ||||
| import static org.junit.Assert.*; | ||||
| 
 | ||||
| @RunWith(RobolectricTestRunner.class) | ||||
| @ -1,15 +1,12 @@ | ||||
| input: |- | ||||
|   **bold *bold italic ~~bold italic strike `bold italic strike code` bold italic strike~~ bold italic* bold** normal | ||||
|   **bold *bold italic `bold italic code` bold italic* bold** normal | ||||
| 
 | ||||
| output: | ||||
|   - b: | ||||
|     - "bold " | ||||
|     - i: | ||||
|       - "bold italic " | ||||
|       - s: | ||||
|         - "bold italic strike " | ||||
|         - code: "bold italic strike code" | ||||
|         - " bold italic strike" | ||||
|       - code: "bold italic code" | ||||
|       - " bold italic" | ||||
|     - " bold" | ||||
|   - " normal" | ||||
| @ -1,18 +0,0 @@ | ||||
| input: |- | ||||
|   <i>italic | ||||
|   <b>bold italic | ||||
|   <u>underline bold italic | ||||
|   <s>strike underline bold italic | ||||
| 
 | ||||
| config: | ||||
|   use-html: true | ||||
|   html-allow-non-closed-tags: true | ||||
| 
 | ||||
| output: | ||||
|   - i: | ||||
|     - "italic " | ||||
|     - b: | ||||
|       - "bold italic " | ||||
|       - u: | ||||
|         - "underline bold italic " | ||||
|         - s: "strike underline bold italic" | ||||
| @ -1,12 +0,0 @@ | ||||
| input: |- | ||||
|   <i>no italic here | ||||
|   <b>bold yeah</b> | ||||
|   <u>no underline | ||||
| 
 | ||||
| config: | ||||
|   use-html: true | ||||
| 
 | ||||
| output: | ||||
|   - "no italic here " | ||||
|   - b: "bold yeah" | ||||
|   - " no underline" | ||||
| @ -1,105 +0,0 @@ | ||||
| input: |- | ||||
|   <h1>html</h1> | ||||
|   <h2>emphasis</h2> | ||||
|   <i>i</i><em>em</em><cite>cite</cite><dfn>dfn</dfn> | ||||
|   <h2>strong-emphasis</h2> | ||||
|   <b>b</b><strong>strong</strong> | ||||
|   <h2>super-script</h2> | ||||
|   <sup>sup</sup> | ||||
|   <h2>sub-script</h2> | ||||
|   <sub>sub</sub> | ||||
|   <h2>underline</h2> | ||||
|   <u>u</u><ins>ins</ins> | ||||
|   <h2>strike</h2> | ||||
|   <s>s</s><del>del</del> | ||||
|   <h2>link</h2> | ||||
|   <a href="a://href">a</a> | ||||
|   <h2>unordered-list</h2> | ||||
|   <ul><li>ul1<li>ul2</ul> | ||||
|   <h2>ordered-list</h2> | ||||
|   <ol><li>ol1<li>ol2</ol> | ||||
|   <h2>image</h2> | ||||
|   <img src="img://src" alt="img"> | ||||
|   <h2>blockquote</h2> | ||||
|   <blockquote>blockquote</blockquote> | ||||
|   <h3>3</h3> | ||||
|   <h4>4</h4> | ||||
|   <h5>5</h5> | ||||
|   <h6>6</h6> | ||||
| 
 | ||||
| config: | ||||
|   use-html: true | ||||
| 
 | ||||
| output: | ||||
|   - h1: "html" | ||||
|   - "\n" | ||||
|   - h2: "emphasis" | ||||
|   - "\n" | ||||
|   - i: "i" | ||||
|   - i: "em" | ||||
|   - i: "cite" | ||||
|   - i: "dfn" | ||||
|   - "\n" | ||||
|   - h2: "strong-emphasis" | ||||
|   - "\n" | ||||
|   - b: "b" | ||||
|   - b: "strong" | ||||
|   - "\n" | ||||
|   - h2: "super-script" | ||||
|   - "\n" | ||||
|   - sup: "sup" | ||||
|   - "\n" | ||||
|   - h2: "sub-script" | ||||
|   - "\n" | ||||
|   - sub: "sub" | ||||
|   - "\n" | ||||
|   - h2: "underline" | ||||
|   - "\n" | ||||
|   - u: "u" | ||||
|   - u: "ins" | ||||
|   - "\n" | ||||
|   - h2: "strike" | ||||
|   - "\n" | ||||
|   - s: "s" | ||||
|   - s: "del" | ||||
|   - "\n" | ||||
|   - h2: "link" | ||||
|   - "\n" | ||||
|   - a: "a" | ||||
|     href: "a://href" | ||||
|   - "\n" | ||||
|   - h2: "unordered-list" | ||||
|   - "\n" | ||||
|   - ul: "ul1" | ||||
|     level: 0 | ||||
|   - "\n" | ||||
|   - ul: "ul2" | ||||
|     level: 0 | ||||
|   - "\n" | ||||
|   - h2: "ordered-list" | ||||
|   - "\n" | ||||
|   - ol: "ol1" | ||||
|     start: 1 | ||||
|   - "\n" | ||||
|   - ol: "ol2" | ||||
|     start: 2 | ||||
|   - "\n" | ||||
|   - h2: "image" | ||||
|   - "\n" | ||||
|   - img: "img" | ||||
|     src: "img://src" | ||||
|     imageSize: null | ||||
|     replacementTextIsLink: false | ||||
|   - "\n" | ||||
|   - h2: "blockquote" | ||||
|   - "\n" | ||||
|   - blockquote: "blockquote" | ||||
|   - "\n" | ||||
|   - h3: "3" | ||||
|   - "\n" | ||||
|   - h4: "4" | ||||
|   - "\n" | ||||
|   - h5: "5" | ||||
|   - "\n" | ||||
|   - h6: "6" | ||||
| 
 | ||||
| @ -1,6 +1,5 @@ | ||||
| input: |- | ||||
|   First **line** is *always* | ||||
|   ~~strike~~ down | ||||
| 
 | ||||
|   > Some quote here! | ||||
| 
 | ||||
| @ -18,9 +17,7 @@ output: | ||||
|   - b: "line" | ||||
|   - text: " is " | ||||
|   - i: "always" | ||||
|   - text: " " | ||||
|   - s: "strike" | ||||
|   - text: " down\n\n" | ||||
|   - text: "\n\n" | ||||
|   - blockquote: "Some quote here!" | ||||
|   - text: "\n\n" | ||||
|   - h1: "Header 1" | ||||
|  | ||||
| @ -1,4 +0,0 @@ | ||||
| input: "~~strike~~" | ||||
| 
 | ||||
| output: | ||||
|   - s: "strike" | ||||
| @ -1,7 +0,0 @@ | ||||
| input: "<sub>sub</sub>" | ||||
| 
 | ||||
| config: | ||||
|   use-html: true | ||||
| 
 | ||||
| output: | ||||
|   - sub: "sub" | ||||
| @ -1,7 +0,0 @@ | ||||
| input: "<sup>sup</sup>" | ||||
| 
 | ||||
| config: | ||||
|   use-html: true | ||||
| 
 | ||||
| output: | ||||
|   - sup: "sup" | ||||
| @ -1,6 +0,0 @@ | ||||
| input: "- [ ] task-list" | ||||
| 
 | ||||
| output: | ||||
|   - task-list: "task-list" | ||||
|     blockIdent: 1 | ||||
|     done: false | ||||
| @ -1,13 +0,0 @@ | ||||
| input: "col1|col2|col3\n---|---|---|" | ||||
| 
 | ||||
| output: | ||||
|   - tr: "\u00a0" | ||||
|     header: true | ||||
|     odd: false | ||||
|     cells: | ||||
|       - alignment: 0 | ||||
|         text: "col1" | ||||
|       - alignment: 0 | ||||
|         text: "col2" | ||||
|       - alignment: 0 | ||||
|         text: "col3" | ||||
| @ -1,7 +0,0 @@ | ||||
| input: "<u>underline</u>" | ||||
| 
 | ||||
| config: | ||||
|   use-html: true | ||||
| 
 | ||||
| output: | ||||
|   - u: "underline" | ||||
| @ -1,51 +0,0 @@ | ||||
| input: |- | ||||
|   head1|head2|head3 | ||||
|   ---|:---:|---: | ||||
|   row1-col1|row1-col2|row1-col3 | ||||
|   row2-col1|row2-col2|row2-col3 | ||||
|   row3-col1|row3-col2|row3-col3 | ||||
| 
 | ||||
| output: | ||||
|   - tr: "\u00a0" | ||||
|     header: true | ||||
|     odd: false | ||||
|     cells: | ||||
|       - alignment: 0 | ||||
|         text: "head1" | ||||
|       - alignment: 1 | ||||
|         text: "head2" | ||||
|       - alignment: 2 | ||||
|         text: "head3" | ||||
|   - text: "\n" | ||||
|   - tr: "\u00a0" | ||||
|     header: false | ||||
|     odd: false | ||||
|     cells: | ||||
|       - alignment: 0 | ||||
|         text: "row1-col1" | ||||
|       - alignment: 1 | ||||
|         text: "row1-col2" | ||||
|       - alignment: 2 | ||||
|         text: "row1-col3" | ||||
|   - text: "\n" | ||||
|   - tr: "\u00a0" | ||||
|     header: false | ||||
|     odd: true | ||||
|     cells: | ||||
|       - alignment: 0 | ||||
|         text: "row2-col1" | ||||
|       - alignment: 1 | ||||
|         text: "row2-col2" | ||||
|       - alignment: 2 | ||||
|         text: "row2-col3" | ||||
|   - text: "\n" | ||||
|   - tr: "\u00a0" | ||||
|     header: false | ||||
|     odd: false | ||||
|     cells: | ||||
|       - alignment: 0 | ||||
|         text: "row3-col1" | ||||
|       - alignment: 1 | ||||
|         text: "row3-col2" | ||||
|       - alignment: 2 | ||||
|         text: "row3-col3" | ||||
| @ -8,7 +8,7 @@ import android.widget.TextView; | ||||
| 
 | ||||
| import ru.noties.markwon.AbstractMarkwonPlugin; | ||||
| import ru.noties.markwon.Markwon; | ||||
| import ru.noties.markwon.spans.MarkwonTheme; | ||||
| import ru.noties.markwon.core.MarkwonTheme; | ||||
| 
 | ||||
| public class MainActivity extends Activity { | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Dimitry Ivanov
						Dimitry Ivanov