From 428ee36f5cdcd8769a048d292df9becd7b65ef35 Mon Sep 17 00:00:00 2001 From: Oleg Baskakov Date: Mon, 25 Mar 2024 22:57:08 -0700 Subject: [PATCH] Use value classes for all markdown nodes --- markdown/core/api/core.api | 296 +- .../jetbrains/jewel/markdown/MarkdownBlock.kt | 133 +- .../jewel/markdown/WithInlineMarkdown.kt | 5 + .../markdown/processing/MarkdownProcessor.kt | 102 +- .../rendering/DefaultMarkdownBlockRenderer.kt | 43 +- .../rendering/MarkdownBlockRenderer.kt | 2 +- ...rkdownProcessorDocumentParsingExtraTest.kt | 76 - .../MarkdownProcessorDocumentParsingTest.kt | 12536 ---------------- .../org/jetbrains/jewel/markdown/TestUtils.kt | 245 - .../extension/gfm-alerts/api/gfm-alerts.api | 68 +- .../extensions/github/alerts/Alert.kt | 18 - .../extensions/github/alerts/AlertBlock.kt | 12 + .../github/alerts/GitHubAlertBlockRenderer.kt | 28 +- .../alerts/GitHubAlertProcessorExtension.kt | 66 +- .../alerts/GitHubAlertBlockExtensionTest.kt | 63 +- .../view/markdown/MarkdownCatalog.kt | 4 +- 16 files changed, 407 insertions(+), 13290 deletions(-) create mode 100644 markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/WithInlineMarkdown.kt delete mode 100644 markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/MarkdownProcessorDocumentParsingExtraTest.kt delete mode 100644 markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/MarkdownProcessorDocumentParsingTest.kt delete mode 100644 markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/TestUtils.kt delete mode 100644 markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/Alert.kt create mode 100644 markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/AlertBlock.kt diff --git a/markdown/core/api/core.api b/markdown/core/api/core.api index 46ce7aac8..d61f1e00b 100644 --- a/markdown/core/api/core.api +++ b/markdown/core/api/core.api @@ -2,6 +2,10 @@ public abstract interface class org/jetbrains/jewel/markdown/BlockWithInlineMark public abstract fun getInlineContent ()Ljava/util/List; } +public final class org/jetbrains/jewel/markdown/BlockWithInlineMarkdown$DefaultImpls { + public static fun getInlineContent (Lorg/jetbrains/jewel/markdown/BlockWithInlineMarkdown;)Ljava/util/List; +} + public abstract interface class org/jetbrains/jewel/markdown/InlineMarkdown { public abstract fun getChildren ()Ljava/util/Iterator; public abstract fun getValue ()Lorg/commonmark/node/Node; @@ -203,145 +207,236 @@ public final class org/jetbrains/jewel/markdown/InlineMarkdownKt { } public abstract interface class org/jetbrains/jewel/markdown/MarkdownBlock { + public abstract fun getChildren ()Ljava/util/Iterator; + public abstract fun getValue ()Lorg/commonmark/node/Block; } public final class org/jetbrains/jewel/markdown/MarkdownBlock$BlockQuote : org/jetbrains/jewel/markdown/MarkdownBlock { - public static final field $stable I - public fun (Ljava/util/List;)V - public final fun component1 ()Ljava/util/List; - public final fun copy (Ljava/util/List;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$BlockQuote; - public static synthetic fun copy$default (Lorg/jetbrains/jewel/markdown/MarkdownBlock$BlockQuote;Ljava/util/List;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$BlockQuote; + public static final synthetic fun box-impl (Lorg/commonmark/node/BlockQuote;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$BlockQuote; + public static fun constructor-impl (Lorg/commonmark/node/BlockQuote;)Lorg/commonmark/node/BlockQuote; public fun equals (Ljava/lang/Object;)Z - public final fun getContent ()Ljava/util/List; + public static fun equals-impl (Lorg/commonmark/node/BlockQuote;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lorg/commonmark/node/BlockQuote;Lorg/commonmark/node/BlockQuote;)Z + public fun getChildren ()Ljava/util/Iterator; + public static fun getChildren-impl (Lorg/commonmark/node/BlockQuote;)Ljava/util/Iterator; + public synthetic fun getValue ()Lorg/commonmark/node/Block; + public fun getValue ()Lorg/commonmark/node/BlockQuote; public fun hashCode ()I + public static fun hashCode-impl (Lorg/commonmark/node/BlockQuote;)I public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lorg/commonmark/node/BlockQuote;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lorg/commonmark/node/BlockQuote; } public abstract interface class org/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock : org/jetbrains/jewel/markdown/MarkdownBlock { - public abstract fun getContent ()Ljava/lang/String; +} + +public final class org/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$DefaultImpls { + public static fun getChildren (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock;)Ljava/util/Iterator; } public final class org/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$FencedCodeBlock : org/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock { - public static final field $stable I - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun component1 ()Ljava/lang/String; - public final fun component2-EIRQHX8 ()Ljava/lang/String; - public final fun copy-k5OzbWQ (Ljava/lang/String;Ljava/lang/String;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$FencedCodeBlock; - public static synthetic fun copy-k5OzbWQ$default (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$FencedCodeBlock;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$FencedCodeBlock; + public static final synthetic fun box-impl (Lorg/commonmark/node/FencedCodeBlock;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$FencedCodeBlock; + public static fun constructor-impl (Lorg/commonmark/node/FencedCodeBlock;)Lorg/commonmark/node/FencedCodeBlock; public fun equals (Ljava/lang/Object;)Z - public fun getContent ()Ljava/lang/String; - public final fun getMimeType-EIRQHX8 ()Ljava/lang/String; + public static fun equals-impl (Lorg/commonmark/node/FencedCodeBlock;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lorg/commonmark/node/FencedCodeBlock;Lorg/commonmark/node/FencedCodeBlock;)Z + public fun getChildren ()Ljava/util/Iterator; + public static fun getChildren-impl (Lorg/commonmark/node/FencedCodeBlock;)Ljava/util/Iterator; + public synthetic fun getValue ()Lorg/commonmark/node/Block; + public fun getValue ()Lorg/commonmark/node/FencedCodeBlock; public fun hashCode ()I + public static fun hashCode-impl (Lorg/commonmark/node/FencedCodeBlock;)I public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lorg/commonmark/node/FencedCodeBlock;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lorg/commonmark/node/FencedCodeBlock; } public final class org/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$IndentedCodeBlock : org/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock { - public static final field $stable I - public fun (Ljava/lang/String;)V - public final fun component1 ()Ljava/lang/String; - public final fun copy (Ljava/lang/String;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$IndentedCodeBlock; - public static synthetic fun copy$default (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$IndentedCodeBlock;Ljava/lang/String;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$IndentedCodeBlock; + public static final synthetic fun box-impl (Lorg/commonmark/node/IndentedCodeBlock;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$IndentedCodeBlock; + public static fun constructor-impl (Lorg/commonmark/node/IndentedCodeBlock;)Lorg/commonmark/node/IndentedCodeBlock; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Lorg/commonmark/node/IndentedCodeBlock;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lorg/commonmark/node/IndentedCodeBlock;Lorg/commonmark/node/IndentedCodeBlock;)Z + public fun getChildren ()Ljava/util/Iterator; + public static fun getChildren-impl (Lorg/commonmark/node/IndentedCodeBlock;)Ljava/util/Iterator; + public synthetic fun getValue ()Lorg/commonmark/node/Block; + public fun getValue ()Lorg/commonmark/node/IndentedCodeBlock; + public fun hashCode ()I + public static fun hashCode-impl (Lorg/commonmark/node/IndentedCodeBlock;)I + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lorg/commonmark/node/IndentedCodeBlock;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lorg/commonmark/node/IndentedCodeBlock; +} + +public final class org/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock : org/jetbrains/jewel/markdown/MarkdownBlock { + public static final synthetic fun box-impl (Lorg/commonmark/node/CustomBlock;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock; + public static fun constructor-impl (Lorg/commonmark/node/CustomBlock;)Lorg/commonmark/node/CustomBlock; public fun equals (Ljava/lang/Object;)Z - public fun getContent ()Ljava/lang/String; + public static fun equals-impl (Lorg/commonmark/node/CustomBlock;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lorg/commonmark/node/CustomBlock;Lorg/commonmark/node/CustomBlock;)Z + public fun getChildren ()Ljava/util/Iterator; + public static fun getChildren-impl (Lorg/commonmark/node/CustomBlock;)Ljava/util/Iterator; + public synthetic fun getValue ()Lorg/commonmark/node/Block; + public fun getValue ()Lorg/commonmark/node/CustomBlock; public fun hashCode ()I + public static fun hashCode-impl (Lorg/commonmark/node/CustomBlock;)I public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lorg/commonmark/node/CustomBlock;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lorg/commonmark/node/CustomBlock; } -public abstract interface class org/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock : org/jetbrains/jewel/markdown/MarkdownBlock { +public final class org/jetbrains/jewel/markdown/MarkdownBlock$DefaultImpls { + public static fun getChildren (Lorg/jetbrains/jewel/markdown/MarkdownBlock;)Ljava/util/Iterator; } public final class org/jetbrains/jewel/markdown/MarkdownBlock$Heading : org/jetbrains/jewel/markdown/BlockWithInlineMarkdown, org/jetbrains/jewel/markdown/MarkdownBlock { - public static final field $stable I - public fun (Ljava/util/List;I)V - public final fun component1 ()Ljava/util/List; - public final fun component2 ()I - public final fun copy (Ljava/util/List;I)Lorg/jetbrains/jewel/markdown/MarkdownBlock$Heading; - public static synthetic fun copy$default (Lorg/jetbrains/jewel/markdown/MarkdownBlock$Heading;Ljava/util/List;IILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$Heading; + public static final synthetic fun box-impl (Lorg/commonmark/node/Heading;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$Heading; + public static fun constructor-impl (Lorg/commonmark/node/Heading;)Lorg/commonmark/node/Heading; public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Lorg/commonmark/node/Heading;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lorg/commonmark/node/Heading;Lorg/commonmark/node/Heading;)Z + public fun getChildren ()Ljava/util/Iterator; + public static fun getChildren-impl (Lorg/commonmark/node/Heading;)Ljava/util/Iterator; public fun getInlineContent ()Ljava/util/List; - public final fun getLevel ()I + public static fun getInlineContent-impl (Lorg/commonmark/node/Heading;)Ljava/util/List; + public static final fun getLevel-impl (Lorg/commonmark/node/Heading;)I + public synthetic fun getValue ()Lorg/commonmark/node/Block; + public fun getValue ()Lorg/commonmark/node/Heading; public fun hashCode ()I + public static fun hashCode-impl (Lorg/commonmark/node/Heading;)I public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lorg/commonmark/node/Heading;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lorg/commonmark/node/Heading; } public final class org/jetbrains/jewel/markdown/MarkdownBlock$HtmlBlock : org/jetbrains/jewel/markdown/MarkdownBlock { + public static final synthetic fun box-impl (Lorg/commonmark/node/HtmlBlock;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$HtmlBlock; + public static fun constructor-impl (Lorg/commonmark/node/HtmlBlock;)Lorg/commonmark/node/HtmlBlock; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Lorg/commonmark/node/HtmlBlock;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lorg/commonmark/node/HtmlBlock;Lorg/commonmark/node/HtmlBlock;)Z + public fun getChildren ()Ljava/util/Iterator; + public static fun getChildren-impl (Lorg/commonmark/node/HtmlBlock;)Ljava/util/Iterator; + public synthetic fun getValue ()Lorg/commonmark/node/Block; + public fun getValue ()Lorg/commonmark/node/HtmlBlock; + public fun hashCode ()I + public static fun hashCode-impl (Lorg/commonmark/node/HtmlBlock;)I + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lorg/commonmark/node/HtmlBlock;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lorg/commonmark/node/HtmlBlock; +} + +public final class org/jetbrains/jewel/markdown/MarkdownBlock$LinkReferenceDefinition : org/jetbrains/jewel/markdown/MarkdownBlock { public static final field $stable I - public fun (Ljava/lang/String;)V - public final fun component1 ()Ljava/lang/String; - public final fun copy (Ljava/lang/String;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$HtmlBlock; - public static synthetic fun copy$default (Lorg/jetbrains/jewel/markdown/MarkdownBlock$HtmlBlock;Ljava/lang/String;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$HtmlBlock; + public fun (Lorg/commonmark/node/Node;)V + public final fun component1 ()Lorg/commonmark/node/Node; + public final fun copy (Lorg/commonmark/node/Node;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$LinkReferenceDefinition; + public static synthetic fun copy$default (Lorg/jetbrains/jewel/markdown/MarkdownBlock$LinkReferenceDefinition;Lorg/commonmark/node/Node;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$LinkReferenceDefinition; public fun equals (Ljava/lang/Object;)Z - public final fun getContent ()Ljava/lang/String; + public fun getChildren ()Ljava/util/Iterator; + public final fun getPayload ()Lorg/commonmark/node/Node; + public fun getValue ()Lorg/commonmark/node/Block; public fun hashCode ()I public fun toString ()Ljava/lang/String; } public abstract interface class org/jetbrains/jewel/markdown/MarkdownBlock$ListBlock : org/jetbrains/jewel/markdown/MarkdownBlock { - public abstract fun getItems ()Ljava/util/List; - public abstract fun isTight ()Z } -public final class org/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$BulletList : org/jetbrains/jewel/markdown/MarkdownBlock$ListBlock { - public static final field $stable I - public fun (Ljava/util/List;ZC)V - public final fun component1 ()Ljava/util/List; - public final fun component2 ()Z - public final fun component3 ()C - public final fun copy (Ljava/util/List;ZC)Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$BulletList; - public static synthetic fun copy$default (Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$BulletList;Ljava/util/List;ZCILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$BulletList; +public final class org/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$BulletList : org/jetbrains/jewel/markdown/MarkdownBlock { + public static final synthetic fun box-impl (Lorg/commonmark/node/BulletList;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$BulletList; + public static fun constructor-impl (Lorg/commonmark/node/BulletList;)Lorg/commonmark/node/BulletList; public fun equals (Ljava/lang/Object;)Z - public final fun getBulletMarker ()C - public fun getItems ()Ljava/util/List; + public static fun equals-impl (Lorg/commonmark/node/BulletList;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lorg/commonmark/node/BulletList;Lorg/commonmark/node/BulletList;)Z + public fun getChildren ()Ljava/util/Iterator; + public static fun getChildren-impl (Lorg/commonmark/node/BulletList;)Ljava/util/Iterator; + public synthetic fun getValue ()Lorg/commonmark/node/Block; + public fun getValue ()Lorg/commonmark/node/BulletList; public fun hashCode ()I - public fun isTight ()Z + public static fun hashCode-impl (Lorg/commonmark/node/BulletList;)I public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lorg/commonmark/node/BulletList;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lorg/commonmark/node/BulletList; } -public final class org/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$OrderedList : org/jetbrains/jewel/markdown/MarkdownBlock$ListBlock { - public static final field $stable I - public fun (Ljava/util/List;ZIC)V - public final fun component1 ()Ljava/util/List; - public final fun component2 ()Z - public final fun component3 ()I - public final fun component4 ()C - public final fun copy (Ljava/util/List;ZIC)Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$OrderedList; - public static synthetic fun copy$default (Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$OrderedList;Ljava/util/List;ZICILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$OrderedList; +public final class org/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$DefaultImpls { + public static fun getChildren (Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListBlock;)Ljava/util/Iterator; +} + +public final class org/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$OrderedList : org/jetbrains/jewel/markdown/MarkdownBlock { + public static final synthetic fun box-impl (Lorg/commonmark/node/OrderedList;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$OrderedList; + public static fun constructor-impl (Lorg/commonmark/node/OrderedList;)Lorg/commonmark/node/OrderedList; public fun equals (Ljava/lang/Object;)Z - public final fun getDelimiter ()C - public fun getItems ()Ljava/util/List; - public final fun getStartFrom ()I + public static fun equals-impl (Lorg/commonmark/node/OrderedList;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lorg/commonmark/node/OrderedList;Lorg/commonmark/node/OrderedList;)Z + public fun getChildren ()Ljava/util/Iterator; + public static fun getChildren-impl (Lorg/commonmark/node/OrderedList;)Ljava/util/Iterator; + public synthetic fun getValue ()Lorg/commonmark/node/Block; + public fun getValue ()Lorg/commonmark/node/OrderedList; public fun hashCode ()I - public fun isTight ()Z + public static fun hashCode-impl (Lorg/commonmark/node/OrderedList;)I public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lorg/commonmark/node/OrderedList;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lorg/commonmark/node/OrderedList; } public final class org/jetbrains/jewel/markdown/MarkdownBlock$ListItem : org/jetbrains/jewel/markdown/MarkdownBlock { - public static final field $stable I - public fun (Ljava/util/List;)V - public final fun component1 ()Ljava/util/List; - public final fun copy (Ljava/util/List;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListItem; - public static synthetic fun copy$default (Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListItem;Ljava/util/List;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListItem; + public static final synthetic fun box-impl (Lorg/commonmark/node/ListItem;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListItem; + public static fun constructor-impl (Lorg/commonmark/node/ListItem;)Lorg/commonmark/node/ListItem; public fun equals (Ljava/lang/Object;)Z - public final fun getContent ()Ljava/util/List; + public static fun equals-impl (Lorg/commonmark/node/ListItem;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lorg/commonmark/node/ListItem;Lorg/commonmark/node/ListItem;)Z + public fun getChildren ()Ljava/util/Iterator; + public static fun getChildren-impl (Lorg/commonmark/node/ListItem;)Ljava/util/Iterator; + public synthetic fun getValue ()Lorg/commonmark/node/Block; + public fun getValue ()Lorg/commonmark/node/ListItem; public fun hashCode ()I + public static fun hashCode-impl (Lorg/commonmark/node/ListItem;)I public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lorg/commonmark/node/ListItem;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lorg/commonmark/node/ListItem; } public final class org/jetbrains/jewel/markdown/MarkdownBlock$Paragraph : org/jetbrains/jewel/markdown/BlockWithInlineMarkdown, org/jetbrains/jewel/markdown/MarkdownBlock { - public static final field $stable I - public fun (Ljava/util/List;)V - public final fun component1 ()Ljava/util/List; - public final fun copy (Ljava/util/List;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$Paragraph; - public static synthetic fun copy$default (Lorg/jetbrains/jewel/markdown/MarkdownBlock$Paragraph;Ljava/util/List;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$Paragraph; + public static final synthetic fun box-impl (Lorg/commonmark/node/Paragraph;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$Paragraph; + public static fun constructor-impl (Lorg/commonmark/node/Paragraph;)Lorg/commonmark/node/Paragraph; public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Lorg/commonmark/node/Paragraph;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lorg/commonmark/node/Paragraph;Lorg/commonmark/node/Paragraph;)Z + public fun getChildren ()Ljava/util/Iterator; + public static fun getChildren-impl (Lorg/commonmark/node/Paragraph;)Ljava/util/Iterator; public fun getInlineContent ()Ljava/util/List; + public static fun getInlineContent-impl (Lorg/commonmark/node/Paragraph;)Ljava/util/List; + public synthetic fun getValue ()Lorg/commonmark/node/Block; + public fun getValue ()Lorg/commonmark/node/Paragraph; public fun hashCode ()I + public static fun hashCode-impl (Lorg/commonmark/node/Paragraph;)I public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lorg/commonmark/node/Paragraph;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lorg/commonmark/node/Paragraph; } public final class org/jetbrains/jewel/markdown/MarkdownBlock$ThematicBreak : org/jetbrains/jewel/markdown/MarkdownBlock { - public static final field $stable I - public static final field INSTANCE Lorg/jetbrains/jewel/markdown/MarkdownBlock$ThematicBreak; + public static final synthetic fun box-impl (Lorg/commonmark/node/ThematicBreak;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$ThematicBreak; + public static fun constructor-impl (Lorg/commonmark/node/ThematicBreak;)Lorg/commonmark/node/ThematicBreak; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Lorg/commonmark/node/ThematicBreak;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lorg/commonmark/node/ThematicBreak;Lorg/commonmark/node/ThematicBreak;)Z + public fun getChildren ()Ljava/util/Iterator; + public static fun getChildren-impl (Lorg/commonmark/node/ThematicBreak;)Ljava/util/Iterator; + public synthetic fun getValue ()Lorg/commonmark/node/Block; + public fun getValue ()Lorg/commonmark/node/ThematicBreak; + public fun hashCode ()I + public static fun hashCode-impl (Lorg/commonmark/node/ThematicBreak;)I + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lorg/commonmark/node/ThematicBreak;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lorg/commonmark/node/ThematicBreak; +} + +public final class org/jetbrains/jewel/markdown/MarkdownBlockKt { + public static final fun toMarkdownBlock (Lorg/commonmark/node/Node;)Lorg/jetbrains/jewel/markdown/MarkdownBlock; } public final class org/jetbrains/jewel/markdown/MimeType { @@ -413,14 +508,18 @@ public final class org/jetbrains/jewel/markdown/MimeTypeKt { public static final fun isXml-K9GpHcc (Ljava/lang/String;)Z } +public abstract interface class org/jetbrains/jewel/markdown/WithInlineMarkdown { + public abstract fun getInlineContent ()Lorg/jetbrains/jewel/markdown/InlineMarkdown; +} + public abstract interface class org/jetbrains/jewel/markdown/extensions/MarkdownBlockProcessorExtension { public abstract fun canProcess (Lorg/commonmark/node/CustomBlock;)Z - public abstract fun processMarkdownBlock (Lorg/commonmark/node/CustomBlock;Lorg/jetbrains/jewel/markdown/processing/MarkdownProcessor;)Lorg/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock; + public abstract fun processMarkdownBlock-VRpIRco (Lorg/commonmark/node/CustomBlock;Lorg/jetbrains/jewel/markdown/processing/MarkdownProcessor;)Lorg/commonmark/node/CustomBlock; } public abstract interface class org/jetbrains/jewel/markdown/extensions/MarkdownBlockRendererExtension { - public abstract fun canRender (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock;)Z - public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Landroidx/compose/runtime/Composer;I)V + public abstract fun canRender-oaZXzmo (Lorg/commonmark/node/CustomBlock;)Z + public abstract fun render-WESUQbY (Lorg/commonmark/node/CustomBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Landroidx/compose/runtime/Composer;I)V } public abstract interface class org/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension { @@ -439,7 +538,6 @@ public final class org/jetbrains/jewel/markdown/processing/MarkdownProcessor { public fun (Ljava/util/List;)V public synthetic fun (Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun ([Lorg/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension;)V - public final fun processChildren (Lorg/commonmark/node/Node;)Ljava/util/List; public final fun processMarkdownDocument (Ljava/lang/String;)Ljava/util/List; } @@ -457,20 +555,20 @@ public final class org/jetbrains/jewel/markdown/rendering/DefaultInlineMarkdownR public class org/jetbrains/jewel/markdown/rendering/DefaultMarkdownBlockRenderer : org/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer { public static final field $stable I public fun (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;Ljava/util/List;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Lkotlin/jvm/functions/Function1;)V - public fun render (Ljava/util/List;Landroidx/compose/runtime/Composer;I)V - public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$BlockQuote;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$BlockQuote;Landroidx/compose/runtime/Composer;I)V - public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$FencedCodeBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Fenced;Landroidx/compose/runtime/Composer;I)V - public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$IndentedCodeBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Indented;Landroidx/compose/runtime/Composer;I)V + public fun render (Ljava/util/Iterator;Landroidx/compose/runtime/Composer;I)V public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code;Landroidx/compose/runtime/Composer;I)V - public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$Heading;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$HN;Landroidx/compose/runtime/Composer;I)V - public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$Heading;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading;Landroidx/compose/runtime/Composer;I)V - public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$HtmlBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$HtmlBlock;Landroidx/compose/runtime/Composer;I)V - public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$BulletList;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Unordered;Landroidx/compose/runtime/Composer;I)V - public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$OrderedList;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Ordered;Landroidx/compose/runtime/Composer;I)V public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List;Landroidx/compose/runtime/Composer;I)V - public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListItem;Landroidx/compose/runtime/Composer;I)V - public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$Paragraph;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Paragraph;Landroidx/compose/runtime/Composer;I)V public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock;Landroidx/compose/runtime/Composer;I)V + public fun render-5HOoXTM (Lorg/commonmark/node/BulletList;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Unordered;Landroidx/compose/runtime/Composer;I)V + public fun render-HPyJd70 (Lorg/commonmark/node/BlockQuote;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$BlockQuote;Landroidx/compose/runtime/Composer;I)V + public fun render-_eEnrww (Lorg/commonmark/node/ListItem;Landroidx/compose/runtime/Composer;I)V + public fun render-moAeIiw (Lorg/commonmark/node/HtmlBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$HtmlBlock;Landroidx/compose/runtime/Composer;I)V + public fun render-mpq8F88 (Lorg/commonmark/node/Heading;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$HN;Landroidx/compose/runtime/Composer;I)V + public fun render-mpq8F88 (Lorg/commonmark/node/Heading;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading;Landroidx/compose/runtime/Composer;I)V + public fun render-t5uat5s (Lorg/commonmark/node/OrderedList;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Ordered;Landroidx/compose/runtime/Composer;I)V + public fun render-v-rYBYU (Lorg/commonmark/node/FencedCodeBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Fenced;Landroidx/compose/runtime/Composer;I)V + public fun render-wlAWB_Q (Lorg/commonmark/node/Paragraph;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Paragraph;Landroidx/compose/runtime/Composer;I)V + public fun render-y8B4ikE (Lorg/commonmark/node/IndentedCodeBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Indented;Landroidx/compose/runtime/Composer;I)V public fun renderThematicBreak (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$ThematicBreak;Landroidx/compose/runtime/Composer;I)V } @@ -505,20 +603,20 @@ public final class org/jetbrains/jewel/markdown/rendering/InlinesStyling$Compani public abstract interface class org/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer { public static final field Companion Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer$Companion; - public abstract fun render (Ljava/util/List;Landroidx/compose/runtime/Composer;I)V - public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$BlockQuote;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$BlockQuote;Landroidx/compose/runtime/Composer;I)V - public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$FencedCodeBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Fenced;Landroidx/compose/runtime/Composer;I)V - public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock$IndentedCodeBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Indented;Landroidx/compose/runtime/Composer;I)V + public abstract fun render (Ljava/util/Iterator;Landroidx/compose/runtime/Composer;I)V public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CodeBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code;Landroidx/compose/runtime/Composer;I)V - public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$Heading;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$HN;Landroidx/compose/runtime/Composer;I)V - public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$Heading;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading;Landroidx/compose/runtime/Composer;I)V - public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$HtmlBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$HtmlBlock;Landroidx/compose/runtime/Composer;I)V - public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$BulletList;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Unordered;Landroidx/compose/runtime/Composer;I)V - public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListBlock$OrderedList;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Ordered;Landroidx/compose/runtime/Composer;I)V public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List;Landroidx/compose/runtime/Composer;I)V - public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$ListItem;Landroidx/compose/runtime/Composer;I)V - public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$Paragraph;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Paragraph;Landroidx/compose/runtime/Composer;I)V public abstract fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock;Landroidx/compose/runtime/Composer;I)V + public abstract fun render-5HOoXTM (Lorg/commonmark/node/BulletList;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Unordered;Landroidx/compose/runtime/Composer;I)V + public abstract fun render-HPyJd70 (Lorg/commonmark/node/BlockQuote;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$BlockQuote;Landroidx/compose/runtime/Composer;I)V + public abstract fun render-_eEnrww (Lorg/commonmark/node/ListItem;Landroidx/compose/runtime/Composer;I)V + public abstract fun render-moAeIiw (Lorg/commonmark/node/HtmlBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$HtmlBlock;Landroidx/compose/runtime/Composer;I)V + public abstract fun render-mpq8F88 (Lorg/commonmark/node/Heading;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading$HN;Landroidx/compose/runtime/Composer;I)V + public abstract fun render-mpq8F88 (Lorg/commonmark/node/Heading;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Heading;Landroidx/compose/runtime/Composer;I)V + public abstract fun render-t5uat5s (Lorg/commonmark/node/OrderedList;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$List$Ordered;Landroidx/compose/runtime/Composer;I)V + public abstract fun render-v-rYBYU (Lorg/commonmark/node/FencedCodeBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Fenced;Landroidx/compose/runtime/Composer;I)V + public abstract fun render-wlAWB_Q (Lorg/commonmark/node/Paragraph;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Paragraph;Landroidx/compose/runtime/Composer;I)V + public abstract fun render-y8B4ikE (Lorg/commonmark/node/IndentedCodeBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$Code$Indented;Landroidx/compose/runtime/Composer;I)V public abstract fun renderThematicBreak (Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling$ThematicBreak;Landroidx/compose/runtime/Composer;I)V } diff --git a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/MarkdownBlock.kt b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/MarkdownBlock.kt index e5c443cd7..eccd1cb01 100644 --- a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/MarkdownBlock.kt +++ b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/MarkdownBlock.kt @@ -1,62 +1,121 @@ package org.jetbrains.jewel.markdown +import org.commonmark.node.Node +import org.jetbrains.jewel.markdown.MarkdownBlock.BlockQuote +import org.jetbrains.jewel.markdown.MarkdownBlock.CodeBlock +import org.jetbrains.jewel.markdown.MarkdownBlock.CustomBlock +import org.jetbrains.jewel.markdown.MarkdownBlock.Heading +import org.jetbrains.jewel.markdown.MarkdownBlock.HtmlBlock +import org.jetbrains.jewel.markdown.MarkdownBlock.LinkReferenceDefinition +import org.jetbrains.jewel.markdown.MarkdownBlock.ListBlock +import org.jetbrains.jewel.markdown.MarkdownBlock.ListItem +import org.jetbrains.jewel.markdown.MarkdownBlock.Paragraph +import org.jetbrains.jewel.markdown.MarkdownBlock.ThematicBreak +import org.commonmark.node.Block as CMBlock +import org.commonmark.node.BlockQuote as CMBlockQuote +import org.commonmark.node.BulletList as CMBulletList +import org.commonmark.node.CustomBlock as CMCustomBlock +import org.commonmark.node.FencedCodeBlock as CMFencedCodeBlock +import org.commonmark.node.Heading as CMHeading +import org.commonmark.node.HtmlBlock as CMHtmlBlock +import org.commonmark.node.IndentedCodeBlock as CMIndentedCodeBlock +import org.commonmark.node.LinkReferenceDefinition as CMLinkReferenceDefinition +import org.commonmark.node.ListItem as CMListItem +import org.commonmark.node.OrderedList as CMOrderedList +import org.commonmark.node.Paragraph as CMParagraph +import org.commonmark.node.ThematicBreak as CMThematicBreak + public sealed interface MarkdownBlock { - public data class BlockQuote(val content: List) : MarkdownBlock + public val value: CMBlock - public interface CustomBlock : MarkdownBlock + @JvmInline + public value class BlockQuote(override val value: CMBlockQuote) : MarkdownBlock public sealed interface CodeBlock : MarkdownBlock { + @JvmInline + public value class FencedCodeBlock(override val value: CMFencedCodeBlock) : CodeBlock - public val content: String + @JvmInline + public value class IndentedCodeBlock(override val value: CMIndentedCodeBlock) : CodeBlock + } - public data class IndentedCodeBlock( - override val content: String, - ) : CodeBlock + @JvmInline + public value class CustomBlock(override val value: CMCustomBlock) : MarkdownBlock - public data class FencedCodeBlock( - override val content: String, - val mimeType: MimeType?, - ) : CodeBlock - } + @JvmInline + public value class Heading(override val value: CMHeading) : MarkdownBlock, BlockWithInlineMarkdown { - public data class Heading( - override val inlineContent: List, - val level: Int, - ) : MarkdownBlock, BlockWithInlineMarkdown + public val level: Int + get() = value.level + } - public data class HtmlBlock(val content: String) : MarkdownBlock + @JvmInline + public value class HtmlBlock(override val value: CMHtmlBlock) : MarkdownBlock public sealed interface ListBlock : MarkdownBlock { + @JvmInline + public value class BulletList(override val value: CMBulletList) : MarkdownBlock - public val items: List - public val isTight: Boolean - - public data class BulletList( - override val items: List, - override val isTight: Boolean, - val bulletMarker: Char, - ) : ListBlock - - public data class OrderedList( - override val items: List, - override val isTight: Boolean, - val startFrom: Int, - val delimiter: Char, - ) : ListBlock + @JvmInline + public value class OrderedList(override val value: CMOrderedList) : MarkdownBlock } - public data class ListItem( - val content: List, - ) : MarkdownBlock + @JvmInline + public value class ListItem(override val value: CMListItem) : MarkdownBlock + + public data class LinkReferenceDefinition(val payload: Node) : MarkdownBlock { + override val value: CMBlock = object : CMCustomBlock() {} + } - public object ThematicBreak : MarkdownBlock + @JvmInline + public value class ThematicBreak(override val value: CMThematicBreak) : MarkdownBlock - public data class Paragraph(override val inlineContent: List) : - MarkdownBlock, BlockWithInlineMarkdown + @JvmInline + public value class Paragraph(override val value: CMParagraph) : MarkdownBlock, BlockWithInlineMarkdown + + public val children: Iterator + get() = object : Iterator { + var current = this@MarkdownBlock.value.firstChild + + override fun hasNext(): Boolean = current != null + + override fun next(): MarkdownBlock = + if (hasNext()) { + current.toMarkdownBlock().also { + current = current.next + } + } else { + throw NoSuchElementException() + } + } } public interface BlockWithInlineMarkdown { public val inlineContent: List + get() = buildList { + var child = (this@BlockWithInlineMarkdown as MarkdownBlock).value.firstChild + + while (child != null) { + add(child.toInlineNode()) + child = child.next + } + } +} + +public fun Node.toMarkdownBlock(): MarkdownBlock = when (this) { + is CMParagraph -> Paragraph(this) + is CMHeading -> Heading(this) + is CMHtmlBlock -> HtmlBlock(this) + is CMBlockQuote -> BlockQuote(this) + is CMFencedCodeBlock -> CodeBlock.FencedCodeBlock(this) + is CMIndentedCodeBlock -> CodeBlock.IndentedCodeBlock(this) + is CMBulletList -> ListBlock.BulletList(this) + is CMOrderedList -> ListBlock.OrderedList(this) + is CMListItem -> ListItem(this) + is CMThematicBreak -> ThematicBreak(this) + is CMCustomBlock -> CustomBlock(this) + is CMLinkReferenceDefinition -> LinkReferenceDefinition(this) + else -> error("Unexpected block $this") } diff --git a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/WithInlineMarkdown.kt b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/WithInlineMarkdown.kt new file mode 100644 index 000000000..b0f6dc053 --- /dev/null +++ b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/WithInlineMarkdown.kt @@ -0,0 +1,5 @@ +package org.jetbrains.jewel.markdown + +public interface WithInlineMarkdown { + public val inlineContent: InlineMarkdown +} diff --git a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/processing/MarkdownProcessor.kt b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/processing/MarkdownProcessor.kt index ac779e8ab..8e57ad890 100644 --- a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/processing/MarkdownProcessor.kt +++ b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/processing/MarkdownProcessor.kt @@ -1,39 +1,25 @@ package org.jetbrains.jewel.markdown.processing -import org.commonmark.node.BlockQuote -import org.commonmark.node.BulletList import org.commonmark.node.Code -import org.commonmark.node.CustomBlock import org.commonmark.node.Document import org.commonmark.node.Emphasis -import org.commonmark.node.FencedCodeBlock import org.commonmark.node.HardLineBreak -import org.commonmark.node.Heading -import org.commonmark.node.HtmlBlock import org.commonmark.node.HtmlInline import org.commonmark.node.Image -import org.commonmark.node.IndentedCodeBlock import org.commonmark.node.Link -import org.commonmark.node.ListBlock -import org.commonmark.node.ListItem import org.commonmark.node.Node -import org.commonmark.node.OrderedList -import org.commonmark.node.Paragraph import org.commonmark.node.SoftLineBreak import org.commonmark.node.StrongEmphasis import org.commonmark.node.Text -import org.commonmark.node.ThematicBreak import org.commonmark.parser.Parser import org.commonmark.renderer.text.TextContentRenderer import org.intellij.lang.annotations.Language import org.jetbrains.jewel.foundation.ExperimentalJewelApi import org.jetbrains.jewel.markdown.InlineMarkdown import org.jetbrains.jewel.markdown.MarkdownBlock -import org.jetbrains.jewel.markdown.MarkdownBlock.CodeBlock -import org.jetbrains.jewel.markdown.MimeType import org.jetbrains.jewel.markdown.extensions.MarkdownProcessorExtension import org.jetbrains.jewel.markdown.rendering.DefaultInlineMarkdownRenderer -import org.jetbrains.jewel.markdown.toInlineNode +import org.jetbrains.jewel.markdown.toMarkdownBlock @ExperimentalJewelApi public class MarkdownProcessor(private val extensions: List = emptyList()) { @@ -80,78 +66,9 @@ public class MarkdownProcessor(private val extensions: List toMarkdownBlockQuote() - is Heading -> toMarkdownHeadingOrNull() - is Paragraph -> toMarkdownParagraphOrNull() - is FencedCodeBlock -> toMarkdownCodeBlockOrNull() - is IndentedCodeBlock -> toMarkdownCodeBlockOrNull() - is BulletList -> toMarkdownListOrNull() - is OrderedList -> toMarkdownListOrNull() - is ThematicBreak -> MarkdownBlock.ThematicBreak - is HtmlBlock -> toMarkdownHtmlBlockOrNull() - is CustomBlock -> { - extensions.find { it.processorExtension.canProcess(this) } - ?.processorExtension?.processMarkdownBlock(this, this@MarkdownProcessor) - } - // TODO: add support for LinkReferenceDefinition - else -> null - } - - private fun BlockQuote.toMarkdownBlockQuote(): MarkdownBlock.BlockQuote = - MarkdownBlock.BlockQuote(processChildren(this)) - - private fun Heading.toMarkdownHeadingOrNull(): MarkdownBlock.Heading = - MarkdownBlock.Heading(contentsAsInlineMarkdown(), level) - - private fun Paragraph.toMarkdownParagraphOrNull(): MarkdownBlock.Paragraph { - val inlineMarkdown = contentsAsInlineMarkdown() - -// if (inlineMarkdown.isEmpty()) return null - return MarkdownBlock.Paragraph(inlineMarkdown) - } - - private fun FencedCodeBlock.toMarkdownCodeBlockOrNull(): CodeBlock.FencedCodeBlock = - CodeBlock.FencedCodeBlock( - literal.trimEnd('\n'), - MimeType.Known.fromMarkdownLanguageName(info), - ) - - private fun IndentedCodeBlock.toMarkdownCodeBlockOrNull(): CodeBlock.IndentedCodeBlock = - CodeBlock.IndentedCodeBlock(literal.trimEnd('\n')) - - private fun BulletList.toMarkdownListOrNull(): MarkdownBlock.ListBlock.BulletList? { - val children = processListItems() - if (children.isEmpty()) return null - - return org.jetbrains.jewel.markdown.MarkdownBlock.ListBlock.BulletList(children, isTight, bulletMarker) - } - - private fun OrderedList.toMarkdownListOrNull(): MarkdownBlock.ListBlock.OrderedList? { - val children = processListItems() - if (children.isEmpty()) return null - - return MarkdownBlock.ListBlock.OrderedList(children, isTight, startNumber, delimiter) - } - - private fun ListBlock.processListItems() = buildList { - forEachChild { child -> - if (child !is ListItem) return@forEachChild - add(MarkdownBlock.ListItem(processChildren(child))) - } - } - - public fun processChildren(node: Node): List = buildList { - node.forEachChild { child -> - val parsedBlock = child.tryProcessMarkdownBlock() - if (parsedBlock != null) { - this.add(parsedBlock) + return buildList { + document.forEachChild { child -> + add(child.toMarkdownBlock()) } } } @@ -165,17 +82,6 @@ public class MarkdownProcessor(private val extensions: List) { + override fun render(blocks: Iterator) { Column(verticalArrangement = Arrangement.spacedBy(rootStyling.blockVerticalSpacing)) { for (block in blocks) { render(block) @@ -104,13 +106,16 @@ public open class DefaultMarkdownBlockRenderer( is HtmlBlock -> render(block, rootStyling.htmlBlock) is OrderedList -> render(block, rootStyling.list.ordered) is BulletList -> render(block, rootStyling.list.unordered) + is ListBlock -> render(block, rootStyling.list) is ListItem -> render(block) is Paragraph -> render(block, rootStyling.paragraph) - ThematicBreak -> renderThematicBreak(rootStyling.thematicBreak) + is ThematicBreak -> renderThematicBreak(rootStyling.thematicBreak) is CustomBlock -> { rendererExtensions.find { it.blockRenderer.canRender(block) } ?.blockRenderer?.render(block, this, inlineRenderer) } + + is LinkReferenceDefinition -> {} } } @@ -188,23 +193,20 @@ public open class DefaultMarkdownBlockRenderer( verticalArrangement = Arrangement.spacedBy(rootStyling.blockVerticalSpacing), ) { CompositionLocalProvider(LocalContentColor provides styling.textColor) { - render(block.content) + render(block.children) } } } @Composable override fun render(block: ListBlock, styling: MarkdownStyling.List) { - when (block) { - is OrderedList -> render(block, styling.ordered) - is BulletList -> render(block, styling.unordered) - } + error("this function shouldn't be used in CommonMark core spec") } @Composable override fun render(block: OrderedList, styling: MarkdownStyling.List.Ordered) { val itemSpacing = - if (block.isTight) { + if (block.value.isTight) { styling.itemVerticalSpacingTight } else { styling.itemVerticalSpacing @@ -214,11 +216,11 @@ public open class DefaultMarkdownBlockRenderer( modifier = Modifier.padding(styling.padding), verticalArrangement = Arrangement.spacedBy(itemSpacing), ) { - for ((index, item) in block.items.withIndex()) { + for ((index, item) in block.children.withIndex()) { Row { - val number = block.startFrom + index + val number = block.value.markerStartNumber + index Text( - text = "$number${block.delimiter}", + text = "$number${block.value.markerDelimiter}", style = styling.numberStyle, modifier = Modifier.widthIn(min = styling.numberMinWidth) .pointerHoverIcon(PointerIcon.Default, overrideDescendants = true), @@ -236,7 +238,7 @@ public open class DefaultMarkdownBlockRenderer( @Composable override fun render(block: BulletList, styling: MarkdownStyling.List.Unordered) { val itemSpacing = - if (block.isTight) { + if (block.value.isTight) { styling.itemVerticalSpacingTight } else { styling.itemVerticalSpacing @@ -246,7 +248,7 @@ public open class DefaultMarkdownBlockRenderer( modifier = Modifier.padding(styling.padding), verticalArrangement = Arrangement.spacedBy(itemSpacing), ) { - for (item in block.items) { + for (item in block.children) { Row { Text( text = styling.bullet.toString(), @@ -265,7 +267,7 @@ public open class DefaultMarkdownBlockRenderer( @Composable override fun render(block: ListItem) { Column(verticalArrangement = Arrangement.spacedBy(rootStyling.blockVerticalSpacing)) { - render(block.content) + render(block.children) } } @@ -286,7 +288,7 @@ public open class DefaultMarkdownBlockRenderer( .then(if (styling.fillWidth) Modifier.fillMaxWidth() else Modifier), ) { Text( - text = block.content, + text = block.value.literal, style = styling.textStyle, modifier = Modifier.padding(styling.padding) .pointerHoverIcon(PointerIcon.Default, overrideDescendants = true), @@ -303,9 +305,10 @@ public open class DefaultMarkdownBlockRenderer( .then(if (styling.fillWidth) Modifier.fillMaxWidth() else Modifier), ) { Column(Modifier.padding(styling.padding)) { - if (block.mimeType != null && styling.infoPosition.verticalAlignment == Alignment.Top) { + val mimeType = remember { MimeType.Known.fromMarkdownLanguageName(block.value.info) } + if (mimeType != null && styling.infoPosition.verticalAlignment == Alignment.Top) { FencedBlockInfo( - block.mimeType.displayName(), + mimeType.displayName(), styling.infoPosition.horizontalAlignment ?: error("No horizontal alignment for position ${styling.infoPosition.name}"), styling.infoTextStyle, @@ -314,14 +317,14 @@ public open class DefaultMarkdownBlockRenderer( } Text( - text = block.content, + text = block.value.literal, style = styling.textStyle, modifier = Modifier.pointerHoverIcon(PointerIcon.Default, overrideDescendants = true), ) - if (block.mimeType != null && styling.infoPosition.verticalAlignment == Alignment.Bottom) { + if (mimeType != null && styling.infoPosition.verticalAlignment == Alignment.Bottom) { FencedBlockInfo( - block.mimeType.displayName(), + mimeType.displayName(), styling.infoPosition.horizontalAlignment ?: error("No horizontal alignment for position ${styling.infoPosition.name}"), styling.infoTextStyle, diff --git a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer.kt b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer.kt index 03d8e94a4..79d23715d 100644 --- a/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer.kt +++ b/markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer.kt @@ -17,7 +17,7 @@ import org.jetbrains.jewel.markdown.MarkdownBlock.ListItem public interface MarkdownBlockRenderer { @Composable - public fun render(blocks: List) + public fun render(blocks: Iterator) @Composable public fun render(block: MarkdownBlock) diff --git a/markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/MarkdownProcessorDocumentParsingExtraTest.kt b/markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/MarkdownProcessorDocumentParsingExtraTest.kt deleted file mode 100644 index a6dfb97d2..000000000 --- a/markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/MarkdownProcessorDocumentParsingExtraTest.kt +++ /dev/null @@ -1,76 +0,0 @@ -package org.jetbrains.jewel.markdown - -import org.jetbrains.jewel.markdown.processing.MarkdownProcessor -import org.junit.Test - -class MarkdownProcessorDocumentParsingExtraTest { - - private val processor = MarkdownProcessor() - - @org.junit.Ignore - @Test - fun `should parse spec sample 22b correctly (Backslash escapes)`() { - val parsed = processor.processMarkdownDocument("[](/bar\\* \"ti\\*tle\")") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[/bar*](/bar* \"ti*tle\")")) - } - - @Test - fun `should parse spec sample 461b correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*_foo *bar*_*") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("*_foo *bar*_*")) - } - - @Test - fun `should parse spec sample 461c correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo *bar***") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("**foo *bar***")) - } - - @Test - fun `should parse spec sample 461d correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*_foo *bar* a_*") - - /* - * Expected HTML: - *

foo bar a

- */ - parsed.assertEquals(paragraph("*_foo *bar* a_*")) - } - - @Test - fun `should parse spec sample 461e correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo *bar* a**") - - /* - * Expected HTML: - *

foo bar a

- */ - parsed.assertEquals(paragraph("**foo *bar* a**")) - } - - @Test - fun `should parse spec sample 461f correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*_*foo *bar* a*_*") - - /* - * Expected HTML: - *

foo bar a

- */ - parsed.assertEquals(paragraph("*_*foo *bar* a*_*")) - } -} diff --git a/markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/MarkdownProcessorDocumentParsingTest.kt b/markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/MarkdownProcessorDocumentParsingTest.kt deleted file mode 100644 index 4786776d8..000000000 --- a/markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/MarkdownProcessorDocumentParsingTest.kt +++ /dev/null @@ -1,12536 +0,0 @@ -package org.jetbrains.jewel.markdown - -import org.jetbrains.jewel.markdown.MarkdownBlock.ThematicBreak -import org.jetbrains.jewel.markdown.processing.MarkdownProcessor -import org.junit.Ignore -import org.junit.Test - -/** - * This class tests that all the snippets in the CommonMark 0.31.2 specs are - * rendered correctly into MarkdownBlocks, matching what the CommonMark - * 0.20 HTML renderer tests also validate. - * - * - * Note that the reference HTML output is only there as information; our - * parsing logic performs various transformations that CommonMark wouldn't. - * For more info, refer to [MarkdownProcessor.processMarkdownDocument]. - */ -@Suppress( - "HtmlDeprecatedAttribute", - "HtmlRequiredAltAttribute", - "HtmlUnknownAttribute", - "HtmlUnknownTarget", - "MarkdownLinkDestinationWithSpaces", - "MarkdownUnresolvedFileReference", - "MarkdownUnresolvedLinkLabel", - "MarkdownUnresolvedHeaderReference", - "LargeClass", // Detekt hates huge test suites I guess -) // All used in purposefully odd Markdown -class MarkdownProcessorDocumentParsingTest { - - private val processor = MarkdownProcessor() - - @Test - fun `should parse spec sample 1 correctly (Tabs)`() { - val parsed = processor.processMarkdownDocument("\tfoo\tbaz\t\tbim") - - /* - * Expected HTML: - *
foo→baz→→bim
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("foo\tbaz\t\tbim")) - } - - @Test - fun `should parse spec sample 2 correctly (Tabs)`() { - val parsed = processor.processMarkdownDocument(" \tfoo\tbaz\t\tbim") - - /* - * Expected HTML: - *
foo→baz→\tbim
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("foo\tbaz\t\tbim")) - } - - @Test - fun `should parse spec sample 3 correctly (Tabs)`() { - val parsed = processor.processMarkdownDocument(" a\ta\n ὐ\ta") - - /* - * Expected HTML: - *
a→a
-         * ὐ→a
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("a\ta\nὐ\ta")) - } - - @Test - fun `should parse spec sample 4 correctly (Tabs)`() { - val parsed = processor.processMarkdownDocument(" - foo\n\n\tbar") - - /* - * Expected HTML: - *
    - *
  • - *

    foo

    - *

    bar

    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem( - paragraph("foo"), - paragraph("bar"), - ), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 5 correctly (Tabs)`() { - val parsed = processor.processMarkdownDocument("- foo\n\n\t\tbar") - - /* - * Expected HTML: - *
    - *
  • - *

    foo

    - *
      bar
    -         * 
    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem( - paragraph("foo"), - indentedCodeBlock(" bar"), - ), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 6 correctly (Tabs)`() { - val parsed = processor.processMarkdownDocument(">\t\tfoo") - - /* - * Expected HTML: - *
- *
  foo
-         * 
- *
- */ - parsed.assertEquals(blockQuote(indentedCodeBlock(" foo"))) - } - - @Test - fun `should parse spec sample 7 correctly (Tabs)`() { - val parsed = processor.processMarkdownDocument("-\t\tfoo") - - /* - * Expected HTML: - *
    - *
  • - *
      foo
    -         * 
    - *
  • - *
- */ - parsed.assertEquals(unorderedList(listItem(indentedCodeBlock(" foo")))) - } - - @Test - fun `should parse spec sample 8 correctly (Tabs)`() { - val parsed = processor.processMarkdownDocument(" foo\n\tbar") - - /* - * Expected HTML: - *
foo
-         * bar
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("foo\nbar")) - } - - @Test - fun `should parse spec sample 9 correctly (Tabs)`() { - val parsed = processor.processMarkdownDocument(" - foo\n - bar\n\t - baz") - - /* - * Expected HTML: - *
    - *
  • foo - *
      - *
    • bar - *
        - *
      • baz
      • - *
      - *
    • - *
    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem( - paragraph("foo"), - unorderedList( - listItem( - paragraph("bar"), - unorderedList(listItem(paragraph("baz"))), - ), - ), - ), - ), - ) - } - - @Test - fun `should parse spec sample 10 correctly (Tabs)`() { - val parsed = processor.processMarkdownDocument("#\tFoo") - - /* - * Expected HTML: - *

Foo

- */ - parsed.assertEquals(heading(level = 1, "Foo")) - } - - @Test - fun `should parse spec sample 11 correctly (Tabs)`() { - val parsed = processor.processMarkdownDocument("*\t*\t*\t") - - /* - * Expected HTML: - *
- */ - parsed.assertEquals(ThematicBreak) - } - - @Test - fun `should parse spec sample 12 correctly (Backslash escapes)`() { - val parsed = - processor.processMarkdownDocument( - "\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\`\\{\\|\\}\\~\n", - ) - - /* - * Expected HTML: - *

!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~

- */ - parsed.assertEquals(paragraph("\\!\"#\$%&'\\(\\)\\*+,-./:;\\<=\\>?@\\[\\\\\\]^\\_\\`{|}\\~")) - } - - @Test - fun `should parse spec sample 13 correctly (Backslash escapes)`() { - val parsed = processor.processMarkdownDocument("\\\t\\A\\a\\ \\3\\φ\\«") - - /* - * Expected HTML: - *

\→\A\a\ \3\φ\«

- */ - parsed.assertEquals(paragraph("\\\t\\A\\a\\ \\3\\φ\\«")) - } - - @Test - fun `should parse spec sample 14 correctly (Backslash escapes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |\*not emphasized* - |\
not a tag - |\[not a link](/foo) - |\`not code` - |1\. not a list - |\* not a list - |\# not a heading - |\[foo]: /url "not a reference" - |\ö not a character entity - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

*not emphasized* - * <br/> not a tag - * [not a link](/foo) - * `not code` - * 1. not a list - * * not a list - * # not a heading - * [foo]: /url "not a reference" - * &ouml; not a character entity

- */ - parsed.assertEquals( - paragraph( - "\\*not emphasized\\* " + - "\\
not a tag " + - "\\[not a link\\]\\(/foo\\) " + - "\\`not code\\` " + - "1. not a list " + - "\\* not a list " + - "# not a heading " + - "\\[foo\\]: /url \"not a reference\" " + - "\\ö not a character entity", - ), - ) - } - - @Test - fun `should parse spec sample 15 correctly (Backslash escapes)`() { - val parsed = processor.processMarkdownDocument("\\\\*emphasis*") - - /* - * Expected HTML: - *

\emphasis

- */ - parsed.assertEquals(paragraph("\\\\*emphasis*")) - } - - @Ignore - @Test - fun `should parse spec sample 16 correctly (Backslash escapes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |foo\ - |bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo
- * bar

- */ - parsed.assertEquals(paragraph("foo\nbar")) - } - - @Ignore - @Test - fun `should parse spec sample 17 correctly (Backslash escapes)`() { - val parsed = processor.processMarkdownDocument("`` \\[\\` ``") - - /* - * Expected HTML: - *

\[\`

- */ - parsed.assertEquals(paragraph("``\\[\\```")) - } - - @Test - fun `should parse spec sample 18 correctly (Backslash escapes)`() { - val parsed = processor.processMarkdownDocument(" \\[\\]") - - /* - * Expected HTML: - *
\[\]
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("\\[\\]")) - } - - @Test - fun `should parse spec sample 19 correctly (Backslash escapes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |~~~ - |\[\] - |~~~ - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
\[\]
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("\\[\\]")) - } - - @Ignore - @Test - fun `should parse spec sample 20 correctly (Backslash escapes)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

https://example.com?find=\*

- */ - parsed.assertEquals(paragraph("[https://example.com?find=\\*](https://example.com?find=\\*)")) - } - - @Test - fun `should parse spec sample 21 correctly (Backslash escapes)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - * - */ - parsed.assertEquals(htmlBlock("")) - } - - @Test - fun `should parse spec sample 22 correctly (Backslash escapes)`() { - val parsed = processor.processMarkdownDocument("[foo](/bar\\* \"ti\\*tle\")") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](/bar* \"ti*tle\")")) - } - - @Test - fun `should parse spec sample 23 correctly (Backslash escapes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo] - | - |[foo]: /bar\* "ti\*tle" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](/bar* \"ti*tle\")")) - } - - @Test - fun `should parse spec sample 24 correctly (Backslash escapes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |``` foo\+bar - |foo - |``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
foo
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("foo", MimeType.Known.fromMarkdownLanguageName("foo\\+bar"))) - } - - @Test - fun `should parse spec sample 25 correctly (Entity and numeric character references)`() { - @Suppress("CheckDtdRefs") // Malformed on purpose - val parsed = - processor.processMarkdownDocument( - """ - |  & © Æ Ď - |¾ ℋ ⅆ - |∲ ≧̸ - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

  & © Æ Ď - * ¾ ℋ ⅆ - * ∲ ≧̸

- */ - parsed.assertEquals(paragraph("  & © Æ Ď ¾ ℋ ⅆ ∲ ≧̸")) - } - - @Ignore("leading # is not supported yet") - @Test - fun `should parse spec sample 26 correctly (Entity and numeric character references)`() { - val parsed = processor.processMarkdownDocument("# Ӓ Ϡ �") - - /* - * Expected HTML: - *

# Ӓ Ϡ �

- */ - parsed.assertEquals(paragraph("# Ӓ Ϡ �")) - } - - @Test - fun `should parse spec sample 27 correctly (Entity and numeric character references)`() { - val parsed = processor.processMarkdownDocument("" ആ ಫ") - - /* - * Expected HTML: - *

" ആ ಫ

- */ - parsed.assertEquals(paragraph("\" ആ ಫ")) - } - - @Suppress("CheckDtdRefs") - @Test - fun `should parse spec sample 28 correctly (Entity and numeric character references)`() { - val parsed = - processor.processMarkdownDocument( - """ - |  &x; &#; &#x; - |� - |&#abcdef0; - |&ThisIsNotDefined; &hi?; - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

&nbsp &x; &#; &#x; - * &#87654321; - * &#abcdef0; - * &ThisIsNotDefined; &hi?;

- */ - parsed.assertEquals( - paragraph("  &x; &#; &#x; � &#abcdef0; &ThisIsNotDefined; &hi?;"), - ) - } - - @Test - fun `should parse spec sample 29 correctly (Entity and numeric character references)`() { - val parsed = processor.processMarkdownDocument("©") - - /* - * Expected HTML: - *

&copy

- */ - parsed.assertEquals(paragraph("©")) - } - - @Suppress("CheckDtdRefs") // Malformed on purpose - @Test - fun `should parse spec sample 30 correctly (Entity and numeric character references)`() { - val parsed = processor.processMarkdownDocument("&MadeUpEntity;") - - /* - * Expected HTML: - *

&MadeUpEntity;

- */ - parsed.assertEquals(paragraph("&MadeUpEntity;")) - } - - @Test - fun `should parse spec sample 31 correctly (Entity and numeric character references)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - * - */ - parsed.assertEquals(htmlBlock("")) - } - - @Test - fun `should parse spec sample 32 correctly (Entity and numeric character references)`() { - val parsed = processor.processMarkdownDocument("[foo](/föö \"föö\")") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](/föö \"föö\")")) - } - - @Test - fun `should parse spec sample 33 correctly (Entity and numeric character references)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo] - | - |[foo]: /föö "föö" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - - parsed.assertEquals(paragraph("[foo](/föö \"föö\")")) - } - - @Test - fun `should parse spec sample 34 correctly (Entity and numeric character references)`() { - val parsed = - processor.processMarkdownDocument( - """ - |``` föö - |foo - |``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
foo
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("foo", mimeType = MimeType.Known.fromMarkdownLanguageName("föö"))) - } - - @Test - fun `should parse spec sample 35 correctly (Entity and numeric character references)`() { - val parsed = processor.processMarkdownDocument("`föö`") - - /* - * Expected HTML: - *

f&ouml;&ouml;

- */ - parsed.assertEquals(paragraph("`föö`")) - } - - @Test - fun `should parse spec sample 36 correctly (Entity and numeric character references)`() { - val parsed = processor.processMarkdownDocument(" föfö") - - /* - * Expected HTML: - *
f&ouml;f&ouml;
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("föfö")) - } - - @Test - fun `should parse spec sample 37 correctly (Entity and numeric character references)`() { - val parsed = processor.processMarkdownDocument("*foo*\n*foo*") - - /* - * Expected HTML: - *

*foo* - * foo

- */ - parsed.assertEquals(paragraph("\\*foo\\* *foo*")) - } - - @Test - fun `should parse spec sample 38 correctly (Entity and numeric character references)`() { - val parsed = - processor.processMarkdownDocument( - """ - |* foo - | - |* foo - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

* foo

- *
    - *
  • foo
  • - *
- */ - parsed.assertEquals( - paragraph("\\* foo"), - unorderedList(listItem(paragraph("foo")), bulletMarker = '*'), - ) - } - - @Ignore - @Test - fun `should parse spec sample 39 correctly (Entity and numeric character references)`() { - val parsed = processor.processMarkdownDocument("foo bar") - - /* - * Expected HTML: - *

foo - * - * bar

- */ - parsed.assertEquals(paragraph("foo\n\nbar")) - } - - @Ignore - @Test - fun `should parse spec sample 40 correctly (Entity and numeric character references)`() { - val parsed = processor.processMarkdownDocument(" foo") - - /* - * Expected HTML: - *

\tfoo

- */ - parsed.assertEquals(paragraph("\tfoo")) - } - - @Test - fun `should parse spec sample 41 correctly (Entity and numeric character references)`() { - val parsed = processor.processMarkdownDocument("[a](url "tit")") - - /* - * Expected HTML: - *

[a](url "tit")

- */ - parsed.assertEquals(paragraph("\\[a\\]\\(url \"tit\"\\)")) - } - - @Test - fun `should parse spec sample 42 correctly (Precedence)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- `one - |- two` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • `one
  • - *
  • two`
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("\\`one")), - listItem(paragraph("two\\`")), - ), - ) - } - - @Test - fun `should parse spec sample 43 correctly (Thematic breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |*** - |--- - |___ - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
- *
- */ - parsed.assertEquals( - ThematicBreak, - ThematicBreak, - ThematicBreak, - ) - } - - @Test - fun `should parse spec sample 44 correctly (Thematic breaks)`() { - val parsed = processor.processMarkdownDocument("+++") - - /* - * Expected HTML: - *

+++

- */ - parsed.assertEquals(paragraph("+++")) - } - - @Test - fun `should parse spec sample 45 correctly (Thematic breaks)`() { - val parsed = processor.processMarkdownDocument("===") - - /* - * Expected HTML: - *

===

- */ - parsed.assertEquals(paragraph("===")) - } - - @Test - fun `should parse spec sample 46 correctly (Thematic breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |-- - |** - |__ - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

-- - * ** - * __

- */ - parsed.assertEquals(paragraph("-- \\*\\* \\_\\_")) - } - - @Test - fun `should parse spec sample 47 correctly (Thematic breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | *** - | *** - | *** - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
- *
- */ - parsed.assertEquals( - ThematicBreak, - ThematicBreak, - ThematicBreak, - ) - } - - @Test - fun `should parse spec sample 48 correctly (Thematic breaks)`() { - val parsed = processor.processMarkdownDocument(" ***") - - /* - * Expected HTML: - *
***
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("***")) - } - - @Test - fun `should parse spec sample 49 correctly (Thematic breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - | *** - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo - * ***

- */ - parsed.assertEquals(paragraph("Foo \\*\\*\\*")) - } - - @Test - fun `should parse spec sample 50 correctly (Thematic breaks)`() { - val parsed = processor.processMarkdownDocument("_____________________________________") - - /* - * Expected HTML: - *
- */ - parsed.assertEquals(ThematicBreak) - } - - @Test - fun `should parse spec sample 51 correctly (Thematic breaks)`() { - val parsed = processor.processMarkdownDocument(" - - -") - - /* - * Expected HTML: - *
- */ - parsed.assertEquals(ThematicBreak) - } - - @Test - fun `should parse spec sample 52 correctly (Thematic breaks)`() { - val parsed = processor.processMarkdownDocument(" ** * ** * ** * **") - - /* - * Expected HTML: - *
- */ - parsed.assertEquals(ThematicBreak) - } - - @Test - fun `should parse spec sample 53 correctly (Thematic breaks)`() { - val parsed = processor.processMarkdownDocument("- - - -") - - /* - * Expected HTML: - *
- */ - parsed.assertEquals(ThematicBreak) - } - - @Test - fun `should parse spec sample 54 correctly (Thematic breaks)`() { - val parsed = processor.processMarkdownDocument("- - - - ") - - /* - * Expected HTML: - *
- */ - parsed.assertEquals(ThematicBreak) - } - - @Test - fun `should parse spec sample 55 correctly (Thematic breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |_ _ _ _ a - | - |a------ - | - |---a--- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

_ _ _ _ a

- *

a------

- *

---a---

- */ - parsed.assertEquals( - paragraph("\\_ \\_ \\_ \\_ a"), - paragraph("a------"), - paragraph("---a---"), - ) - } - - @Test - fun `should parse spec sample 56 correctly (Thematic breaks)`() { - val parsed = processor.processMarkdownDocument(" *-*") - - /* - * Expected HTML: - *

-

- */ - parsed.assertEquals(paragraph("*-*")) - } - - @Test - fun `should parse spec sample 57 correctly (Thematic breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- foo - |*** - |- bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • foo
  • - *
- *
- *
    - *
  • bar
  • - *
- */ - parsed.assertEquals( - unorderedList(listItem(paragraph("foo"))), - ThematicBreak, - unorderedList(listItem(paragraph("bar"))), - ) - } - - @Test - fun `should parse spec sample 58 correctly (Thematic breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - |*** - |bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo

- *
- *

bar

- */ - parsed.assertEquals( - paragraph("Foo"), - ThematicBreak, - paragraph("bar"), - ) - } - - @Test - fun `should parse spec sample 59 correctly (Thematic breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - |--- - |bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo

- *

bar

- */ - parsed.assertEquals( - heading(2, "Foo"), - paragraph("bar"), - ) - } - - @Test - fun `should parse spec sample 60 correctly (Thematic breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |* Foo - |* * * - |* Bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • Foo
  • - *
- *
- *
    - *
  • Bar
  • - *
- */ - parsed.assertEquals( - unorderedList(listItem(paragraph("Foo")), bulletMarker = '*'), - ThematicBreak, - unorderedList(listItem(paragraph("Bar")), bulletMarker = '*'), - ) - } - - @Test - fun `should parse spec sample 61 correctly (Thematic breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- Foo - |- * * * - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • Foo
  • - *
  • - *
    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("Foo")), - listItem(ThematicBreak), - ), - ) - } - - @Test - fun `should parse spec sample 62 correctly (ATX headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |# foo - |## foo - |### foo - |#### foo - |##### foo - |###### foo - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- *

foo

- *

foo

- *

foo

- *
foo
- *
foo
- */ - parsed.assertEquals( - heading(1, "foo"), - heading(2, "foo"), - heading(3, "foo"), - heading(4, "foo"), - heading(5, "foo"), - heading(6, "foo"), - ) - } - - @Test - fun `should parse spec sample 63 correctly (ATX headings)`() { - val parsed = processor.processMarkdownDocument("####### foo") - - /* - * Expected HTML: - *

####### foo

- */ - parsed.assertEquals(paragraph("####### foo")) - } - - @Test - fun `should parse spec sample 64 correctly (ATX headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |#5 bolt - | - |#hashtag - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

#5 bolt

- *

#hashtag

- */ - parsed.assertEquals( - paragraph("#5 bolt"), - paragraph("#hashtag"), - ) - } - - @Test - fun `should parse spec sample 65 correctly (ATX headings)`() { - val parsed = processor.processMarkdownDocument("\\## foo") - - /* - * Expected HTML: - *

## foo

- */ - parsed.assertEquals(paragraph("\\## foo")) - } - - @Test - fun `should parse spec sample 66 correctly (ATX headings)`() { - val parsed = processor.processMarkdownDocument("# foo *bar* \\*baz\\*") - - /* - * Expected HTML: - *

foo bar *baz*

- */ - parsed.assertEquals( - heading(level = 1, "foo *bar* \\*baz\\*"), - ) - } - - @Test - fun `should parse spec sample 67 correctly (ATX headings)`() { - val parsed = processor.processMarkdownDocument("# foo ") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(heading(level = 1, "foo")) - } - - @Test - fun `should parse spec sample 68 correctly (ATX headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - | ### foo - | ## foo - | # foo - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- *

foo

- *

foo

- */ - parsed.assertEquals( - heading(level = 3, "foo"), - heading(level = 2, "foo"), - heading(level = 1, "foo"), - ) - } - - @Test - fun `should parse spec sample 69 correctly (ATX headings)`() { - val parsed = processor.processMarkdownDocument(" # foo") - - /* - * Expected HTML: - *
# foo
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("# foo")) - } - - @Test - fun `should parse spec sample 70 correctly (ATX headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |foo - | # bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo - * # bar

- */ - parsed.assertEquals(paragraph("foo # bar")) - } - - @Test - fun `should parse spec sample 71 correctly (ATX headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |## foo ## - | ### bar ### - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- *

bar

- */ - parsed.assertEquals( - heading(level = 2, "foo"), - heading(level = 3, "bar"), - ) - } - - @Test - fun `should parse spec sample 72 correctly (ATX headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |# foo ################################## - |##### foo ## - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- *
foo
- */ - parsed.assertEquals( - heading(level = 1, "foo"), - heading(level = 5, "foo"), - ) - } - - @Test - fun `should parse spec sample 73 correctly (ATX headings)`() { - val parsed = processor.processMarkdownDocument("### foo ### ") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(heading(level = 3, "foo")) - } - - @Test - fun `should parse spec sample 74 correctly (ATX headings)`() { - val parsed = processor.processMarkdownDocument("### foo ### b") - - /* - * Expected HTML: - *

foo ### b

- */ - parsed.assertEquals(heading(level = 3, "foo ### b")) - } - - @Test - fun `should parse spec sample 75 correctly (ATX headings)`() { - val parsed = processor.processMarkdownDocument("# foo#") - - /* - * Expected HTML: - *

foo#

- */ - parsed.assertEquals(heading(level = 1, "foo#")) - } - - @Test - fun `should parse spec sample 76 correctly (ATX headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |### foo \### - |## foo #\## - |# foo \# - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo ###

- *

foo ###

- *

foo #

- */ - parsed.assertEquals( - heading(level = 3, "foo ###"), - heading(level = 2, "foo ###"), - heading(level = 1, "foo #"), - ) - } - - @Test - fun `should parse spec sample 77 correctly (ATX headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |**** - |## foo - |**** - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

foo

- *
- */ - parsed.assertEquals( - ThematicBreak, - heading(level = 2, "foo"), - ThematicBreak, - ) - } - - @Test - fun `should parse spec sample 78 correctly (ATX headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo bar - |# baz - |Bar foo - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo bar

- *

baz

- *

Bar foo

- */ - parsed.assertEquals( - paragraph("Foo bar"), - heading(level = 1, "baz"), - paragraph("Bar foo"), - ) - } - - @Test - fun `should parse spec sample 79 correctly (ATX headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |## - |# - |### ### - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

- *

- *

- */ - parsed.assertEquals( - heading(level = 2, ""), - heading(level = 1, ""), - heading(level = 3, ""), - ) - } - - @Test - fun `should parse spec sample 80 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo *bar* - |========= - | - |Foo *bar* - |--------- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo bar

- *

Foo bar

- */ - - parsed.assertEquals( - heading(level = 1, "Foo *bar*"), - heading(level = 2, "Foo *bar*"), - ) - } - - @Test - fun `should parse spec sample 81 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo *bar - |baz* - |==== - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo bar - * baz

- */ - parsed.assertEquals(heading(level = 1, "Foo *bar baz*")) - } - - @Test - fun `should parse spec sample 82 correctly (Setext headings)`() { - val parsed = processor.processMarkdownDocument(" Foo *bar\nbaz*\t\n====") - - /* - * Expected HTML: - *

Foo bar - * baz

- */ - parsed.assertEquals(heading(level = 1, "Foo *bar\nbaz*")) - } - - @Test - fun `should parse spec sample 83 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - |------------------------- - | - |Foo - |= - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo

- *

Foo

- */ - parsed.assertEquals( - heading(level = 2, "Foo"), - heading(level = 1, "Foo"), - ) - } - - @Test - fun `should parse spec sample 84 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - | Foo - |--- - | - | Foo - |----- - | - | Foo - | === - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo

- *

Foo

- *

Foo

- */ - parsed.assertEquals( - heading(level = 2, "Foo"), - heading(level = 2, "Foo"), - heading(level = 1, "Foo"), - ) - } - - @Test - fun `should parse spec sample 85 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - | Foo - | --- - | - | Foo - |--- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
Foo
-         * ---
-         *
-         * Foo
-         * 
- *
- */ - parsed.assertEquals( - indentedCodeBlock("Foo\n---\n\nFoo"), - ThematicBreak, - ) - } - - @Test - fun `should parse spec sample 86 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - | ---- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo

- */ - parsed.assertEquals(heading(level = 2, "Foo")) - } - - @Test - fun `should parse spec sample 87 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - | --- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo - * ---

- */ - parsed.assertEquals(paragraph("Foo ---")) - } - - @Test - fun `should parse spec sample 88 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - |= = - | - |Foo - |--- - - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo - * = =

- *

Foo

- *
- */ - parsed.assertEquals( - paragraph("Foo = ="), - paragraph("Foo"), - ThematicBreak, - ) - } - - @Test - fun `should parse spec sample 89 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - |----- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo

- */ - parsed.assertEquals(heading(level = 2, "Foo")) - } - - @Test - fun `should parse spec sample 90 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo\ - |---- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo\

- */ - parsed.assertEquals(heading(level = 2, "Foo\\")) - } - - @Test - fun `should parse spec sample 91 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |`Foo - |---- - |` - | - | - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

`Foo

- *

`

- *

<a title="a lot

- *

of dashes"/>

- */ - parsed.assertEquals( - heading(level = 2, "\\`Foo"), - paragraph("\\`"), - heading(level = 2, "\\
"), - ) - } - - @Test - fun `should parse spec sample 92 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> Foo - |--- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

Foo

- *
- *
- */ - parsed.assertEquals( - blockQuote(paragraph("Foo")), - ThematicBreak, - ) - } - - @Test - fun `should parse spec sample 93 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> foo - |bar - |=== - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

foo - * bar - * ===

- *
- */ - parsed.assertEquals(blockQuote(paragraph("foo bar ==="))) - } - - @Test - fun `should parse spec sample 94 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- Foo - |--- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • Foo
  • - *
- *
- */ - parsed.assertEquals( - unorderedList(listItem(paragraph("Foo"))), - ThematicBreak, - ) - } - - @Test - fun `should parse spec sample 95 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - |Bar - |--- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo - * Bar

- */ - parsed.assertEquals(heading(level = 2, "Foo Bar")) - } - - @Test - fun `should parse spec sample 96 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |--- - |Foo - |--- - |Bar - |--- - |Baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

Foo

- *

Bar

- *

Baz

- */ - parsed.assertEquals( - ThematicBreak, - heading(level = 2, "Foo"), - heading(level = 2, "Bar"), - paragraph("Baz"), - ) - } - - @Test - fun `should parse spec sample 97 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - |==== - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

====

- */ - parsed.assertEquals(paragraph("====")) - } - - @Test - fun `should parse spec sample 98 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |--- - |--- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
- */ - parsed.assertEquals( - ThematicBreak, - ThematicBreak, - ) - } - - @Test - fun `should parse spec sample 99 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- foo - |----- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • foo
  • - *
- *
- */ - parsed.assertEquals( - unorderedList(listItem(paragraph("foo"))), - ThematicBreak, - ) - } - - @Test - fun `should parse spec sample 100 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - | foo - |--- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
foo
-         * 
- *
- */ - parsed.assertEquals( - indentedCodeBlock("foo"), - ThematicBreak, - ) - } - - @Test - fun `should parse spec sample 101 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> foo - |----- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

foo

- *
- *
- */ - parsed.assertEquals( - blockQuote(paragraph("foo")), - ThematicBreak, - ) - } - - @Test - fun `should parse spec sample 102 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |\> foo - |------ - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

> foo

- */ - parsed.assertEquals(heading(level = 2, "\\> foo")) - } - - @Test - fun `should parse spec sample 103 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - | - |bar - |--- - |baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo

- *

bar

- *

baz

- */ - parsed.assertEquals( - paragraph("Foo"), - heading(level = 2, "bar"), - paragraph("baz"), - ) - } - - @Test - fun `should parse spec sample 104 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - |bar - | - |--- - | - |baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo - * bar

- *
- *

baz

- */ - parsed.assertEquals( - paragraph("Foo bar"), - ThematicBreak, - paragraph("baz"), - ) - } - - @Test - fun `should parse spec sample 105 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - |bar - |* * * - |baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo - * bar

- *
- *

baz

- */ - parsed.assertEquals( - paragraph("Foo bar"), - ThematicBreak, - paragraph("baz"), - ) - } - - @Test - fun `should parse spec sample 106 correctly (Setext headings)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - |bar - |\--- - |baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo - * bar - * --- - * baz

- */ - parsed.assertEquals(paragraph("Foo bar --- baz")) - } - - @Test - fun `should parse spec sample 107 correctly (Indented code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | a simple - | indented code block - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
a simple
-         *   indented code block
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("a simple\n indented code block")) - } - - @Test - fun `should parse spec sample 108 correctly (Indented code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - foo - | - | bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    foo

    - *

    bar

    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("foo"), paragraph("bar")), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 109 correctly (Indented code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |1. foo - | - | - bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. - *

    foo

    - *
      - *
    • bar
    • - *
    - *
  2. - *
- */ - parsed.assertEquals( - orderedList( - listItem( - paragraph("foo"), - unorderedList(listItem(paragraph("bar"))), - ), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 110 correctly (Indented code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |
- | *hi* - | - | - one - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
<a/>
-         * *hi*
-         *
-         * - one
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("
\n*hi*\n\n- one")) - } - - @Test - fun `should parse spec sample 111 correctly (Indented code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | chunk1 - | - | chunk2 - | - | - | - | chunk3 - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
chunk1
-         *
-         * chunk2
-         *
-         *
-         *
-         * chunk3
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("chunk1\n\nchunk2\n\n\n\nchunk3")) - } - - @Test - fun `should parse spec sample 112 correctly (Indented code blocks)`() { - val parsed = processor.processMarkdownDocument(" chunk1\n \n chunk2") - - /* - * Expected HTML: - *
chunk1
-         * ••
-         *   chunk2
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("chunk1\n \n chunk2")) - } - - @Test - fun `should parse spec sample 113 correctly (Indented code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - | bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo - * bar

- */ - parsed.assertEquals(paragraph("Foo bar")) - } - - @Test - fun `should parse spec sample 114 correctly (Indented code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | foo - |bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
foo
-         * 
- *

bar

- */ - parsed.assertEquals( - indentedCodeBlock("foo"), - paragraph("bar"), - ) - } - - @Test - fun `should parse spec sample 115 correctly (Indented code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |# Heading - | foo - |Heading - |------ - | foo - |---- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Heading

- *
foo
-         * 
- *

Heading

- *
foo
-         * 
- *
- */ - parsed.assertEquals( - heading(level = 1, "Heading"), - indentedCodeBlock("foo"), - heading(level = 2, "Heading"), - indentedCodeBlock("foo"), - ThematicBreak, - ) - } - - @Test - fun `should parse spec sample 116 correctly (Indented code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | foo - | bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    foo
-         * bar
-         * 
- */ - parsed.assertEquals(indentedCodeBlock(" foo\nbar")) - } - - @Test - fun `should parse spec sample 117 correctly (Indented code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - | - | foo - | - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
foo
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("foo")) - } - - @Test - fun `should parse spec sample 118 correctly (Indented code blocks)`() { - val parsed = processor.processMarkdownDocument(" foo ") - - /* - * Expected HTML: - *
foo••
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("foo ")) - } - - @Test - fun `should parse spec sample 119 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |``` - |< - | > - |``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
<
-         *  >
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("<\n >")) - } - - @Test - fun `should parse spec sample 120 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |~~~ - |< - | > - |~~~ - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
<
-         *  >
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("<\n >")) - } - - @Test - fun `should parse spec sample 121 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |`` - |foo - |`` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("`foo`")) - } - - @Test - fun `should parse spec sample 122 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |``` - |aaa - |~~~ - |``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
aaa
-         * ~~~
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("aaa\n~~~")) - } - - @Test - fun `should parse spec sample 123 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |~~~ - |aaa - |``` - |~~~ - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
aaa
-         * ```
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("aaa\n```")) - } - - @Test - fun `should parse spec sample 124 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |```` - |aaa - |``` - |`````` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
aaa
-         * ```
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("aaa\n```")) - } - - @Test - fun `should parse spec sample 125 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |~~~~ - |aaa - |~~~ - |~~~~ - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
aaa
-         * ~~~
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("aaa\n~~~")) - } - - @Test - fun `should parse spec sample 126 correctly (Fenced code blocks)`() { - val parsed = processor.processMarkdownDocument("```") - - /* - * Expected HTML: - *
- */ - parsed.assertEquals(fencedCodeBlock("")) - } - - @Test - fun `should parse spec sample 127 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |````` - | - |``` - |aaa - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

-         * ```
-         * aaa
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("\n```\naaa")) - } - - @Test - fun `should parse spec sample 128 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> ``` - |> aaa - | - |bbb - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
aaa
-         * 
- *
- *

bbb

- */ - parsed.assertEquals( - blockQuote(fencedCodeBlock("aaa")), - paragraph("bbb"), - ) - } - - @Test - fun `should parse spec sample 129 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |``` - | - | - |``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

-         * ••
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("\n ")) - } - - @Test - fun `should parse spec sample 130 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |``` - |``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- */ - parsed.assertEquals(fencedCodeBlock("")) - } - - @Test - fun `should parse spec sample 131 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | ``` - | aaa - |aaa - |``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
aaa
-         * aaa
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("aaa\naaa")) - } - - @Test - fun `should parse spec sample 132 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | ``` - |aaa - | aaa - |aaa - | ``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
aaa
-         * aaa
-         * aaa
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("aaa\naaa\naaa")) - } - - @Test - fun `should parse spec sample 133 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | ``` - | aaa - | aaa - | aaa - | ``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
aaa
-         *  aaa
-         * aaa
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("aaa\n aaa\naaa")) - } - - @Test - fun `should parse spec sample 134 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | ``` - | aaa - | ``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
```
-         * aaa
-         * ```
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("```\naaa\n```")) - } - - @Test - fun `should parse spec sample 135 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |``` - |aaa - | ``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
aaa
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("aaa")) - } - - @Test - fun `should parse spec sample 136 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | ``` - |aaa - | ``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
aaa
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("aaa")) - } - - @Test - fun `should parse spec sample 137 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |``` - |aaa - | ``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
aaa
-         *     ```
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("aaa\n ```")) - } - - @Test - fun `should parse spec sample 138 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |``` ``` - |aaa - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

- * aaa

- */ - parsed.assertEquals(paragraph("` ` aaa")) - } - - @Test - fun `should parse spec sample 139 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |~~~~~~ - |aaa - |~~~ ~~ - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
aaa
-         * ~~~ ~~
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("aaa\n~~~ ~~")) - } - - @Test - fun `should parse spec sample 140 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |foo - |``` - |bar - |``` - |baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- *
bar
-         * 
- *

baz

- */ - parsed.assertEquals( - paragraph("foo"), - fencedCodeBlock("bar"), - paragraph("baz"), - ) - } - - @Test - fun `should parse spec sample 141 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |foo - |--- - |~~~ - |bar - |~~~ - |# baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- *
bar
-         * 
- *

baz

- */ - parsed.assertEquals( - heading(level = 2, "foo"), - fencedCodeBlock("bar"), - heading(level = 1, "baz"), - ) - } - - @Test - fun `should parse spec sample 142 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |```ruby - |def foo(x) - | return 3 - |end - |``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
def foo(x)
-         *   return 3
-         * end
-         * 
- */ - parsed.assertEquals( - fencedCodeBlock( - "def foo(x)\n return 3\nend", - mimeType = MimeType.Known.fromMarkdownLanguageName("ruby"), - ), - ) - } - - @Test - fun `should parse spec sample 143 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |~~~~ ruby startline=3 $%@#$ - |def foo(x) - | return 3 - |end - |~~~~~~~ - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
def foo(x)
-         *   return 3
-         * end
-         * 
- */ - parsed.assertEquals( - fencedCodeBlock( - "def foo(x)\n return 3\nend", - mimeType = MimeType.Known.fromMarkdownLanguageName("ruby"), - ), - ) - } - - @Test - fun `should parse spec sample 144 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |````; - |```` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- */ - parsed.assertEquals( - fencedCodeBlock( - "", - mimeType = MimeType.Known.fromMarkdownLanguageName(";"), - ), - ) - } - - @Test - fun `should parse spec sample 145 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |``` aa ``` - |foo - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

aa - * foo

- */ - parsed.assertEquals(paragraph("`aa` foo")) - } - - @Test - fun `should parse spec sample 146 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |~~~ aa ``` ~~~ - |foo - |~~~ - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
foo
-         * 
- */ - parsed.assertEquals( - fencedCodeBlock( - "foo", - mimeType = MimeType.Known.fromMarkdownLanguageName("aa"), - ), - ) - } - - @Test - fun `should parse spec sample 147 correctly (Fenced code blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |``` - |``` aaa - |``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
``` aaa
-         * 
- */ - parsed.assertEquals(fencedCodeBlock("``` aaa")) - } - - @Test - fun `should parse spec sample 148 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |
- |
-            |**Hello**,
-            |
-            |_world_.
-            |
- |
- """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
-         * **Hello**,
-         * 

world. - *

- *
- */ - parsed.assertEquals( - htmlBlock("
\n
\n**Hello**,"),
-            paragraph("_world_. 
"), - htmlBlock("
"), - ) - } - - @Test - fun `should parse spec sample 149 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - | - | - | - |
- | hi - |
- | - |okay. - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - * - * - * - *
- * hi - *
- *

okay.

- */ - parsed.assertEquals( - htmlBlock( - """ - | - | - | - | - |
- | hi - |
- """ - .trimMargin(), - ), - paragraph("okay."), - ) - } - - @Test - fun `should parse spec sample 150 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |
\n*foo*")) - } - - @Test - fun `should parse spec sample 152 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |
- | - |*Markdown* - | - |
- """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

Markdown

- *
- */ - parsed.assertEquals( - htmlBlock("
"), - paragraph("*Markdown*"), - htmlBlock("
"), - ) - } - - @Test - fun `should parse spec sample 153 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |
- |
- """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
- */ - parsed.assertEquals( - htmlBlock( - """ - |
- |
- """ - .trimMargin(), - ), - ) - } - - @Test - fun `should parse spec sample 154 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |
- |
- """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
- */ - parsed.assertEquals( - htmlBlock( - """ - |
- |
- """ - .trimMargin(), - ), - ) - } - - @Test - fun `should parse spec sample 155 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |
- |*foo* - | - |*bar* - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- * *foo* - *

bar

- */ - parsed.assertEquals( - htmlBlock("
\n*foo*"), - paragraph("*bar*"), - ) - } - - @Test - fun `should parse spec sample 156 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |") - - /* - * Expected HTML: - * - */ - parsed.assertEquals(htmlBlock("")) - } - - @Test - fun `should parse spec sample 160 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |
- |foo - |
- """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- * foo - *
- */ - parsed.assertEquals( - htmlBlock( - """ - |
- |foo - |
- """ - .trimMargin(), - ), - ) - } - - @Test - fun `should parse spec sample 161 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |
- |``` c - |int x = 33; - |``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- * ``` c - * int x = 33; - * ``` - */ - parsed.assertEquals( - htmlBlock( - """ - |
- |``` c - |int x = 33; - |``` - """ - .trimMargin(), - ), - ) - } - - @Test - fun `should parse spec sample 162 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - |*bar* - | - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - * *bar* - * - */ - parsed.assertEquals( - htmlBlock( - """ - | - |*bar* - | - """ - .trimMargin(), - ), - ) - } - - @Test - fun `should parse spec sample 163 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - |*bar* - | - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - * *bar* - * - */ - parsed.assertEquals( - htmlBlock( - """ - | - |*bar* - | - """ - .trimMargin(), - ), - ) - } - - @Test - fun `should parse spec sample 164 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - |*bar* - | - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - * *bar* - * - */ - parsed.assertEquals( - htmlBlock( - """ - | - |*bar* - | - """ - .trimMargin(), - ), - ) - } - - @Test - fun `should parse spec sample 165 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - |*bar* - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - * *bar* - */ - parsed.assertEquals( - htmlBlock( - """ - | - |*bar* - """ - .trimMargin(), - ), - ) - } - - @Test - fun `should parse spec sample 166 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - |*foo* - | - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - * *foo* - * - */ - parsed.assertEquals( - htmlBlock( - """ - | - |*foo* - | - """ - .trimMargin(), - ), - ) - } - - @Test - fun `should parse spec sample 167 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - | - |*foo* - | - | - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - *

foo

- *
- */ - parsed.assertEquals( - htmlBlock(""), - paragraph("*foo*"), - htmlBlock(""), - ) - } - - @Test - fun `should parse spec sample 168 correctly (HTML blocks)`() { - val parsed = processor.processMarkdownDocument("*foo*") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("*foo*")) - } - - @Test - fun `should parse spec sample 169 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |

-            |import Text.HTML.TagSoup
-            |
-            |main :: IO ()
-            |main = print $ parseTags tags
-            |
- |okay - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

-         * import Text.HTML.TagSoup
-         *
-         * main :: IO ()
-         * main = print $ parseTags tags
-         * 
- *

okay

- */ - parsed.assertEquals( - htmlBlock( - """ - |

-            |import Text.HTML.TagSoup
-            |
-            |main :: IO ()
-            |main = print $ parseTags tags
-            |
- """ - .trimMargin(), - ), - paragraph("okay"), - ) - } - - @Test - fun `should parse spec sample 170 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - |okay - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - *

okay

- */ - parsed.assertEquals( - htmlBlock( - """ - | - """ - .trimMargin(), - ), - paragraph("okay"), - ) - } - - @Test - fun `should parse spec sample 171 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - */ - parsed.assertEquals( - htmlBlock( - """ - | - """ - .trimMargin(), - ), - ) - } - - @Test - fun `should parse spec sample 172 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - |okay - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - *

okay

- */ - parsed.assertEquals( - htmlBlock( - """ - | - """ - .trimMargin(), - ), - paragraph("okay"), - ) - } - - @Test - fun `should parse spec sample 173 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - |*foo* - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - *

foo

- */ - parsed.assertEquals( - htmlBlock(""), - paragraph("*foo*"), - ) - } - - @Test - fun `should parse spec sample 177 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |*bar* - |*baz* - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * *bar* - *

baz

- */ - parsed.assertEquals( - htmlBlock("*bar*"), - paragraph("*baz*"), - ) - } - - @Test - fun `should parse spec sample 178 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |1. *bar* - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * 1. *bar* - */ - parsed.assertEquals( - htmlBlock( - """ - |1. *bar* - """ - .trimMargin(), - ), - ) - } - - @Test - fun `should parse spec sample 179 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - |okay - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - *

okay

- */ - parsed.assertEquals( - htmlBlock( - """ - | - """ - .trimMargin(), - ), - paragraph("okay"), - ) - } - - @Test - fun `should parse spec sample 180 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |'; - | - |?> - |okay - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * '; - * - * ?> - *

okay

- */ - parsed.assertEquals( - htmlBlock( - """ - |'; - | - |?> - """ - .trimMargin(), - ), - paragraph("okay"), - ) - } - - @Test - fun `should parse spec sample 181 correctly (HTML blocks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - * - */ - parsed.assertEquals(htmlBlock("")) - } - - @Test - fun `should parse spec sample 182 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - |okay - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - *

okay

- */ - parsed.assertEquals( - htmlBlock( - """ - | - """ - .trimMargin(), - ), - paragraph("okay"), - ) - } - - @Test - fun `should parse spec sample 183 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - | - | - """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - *
<!-- foo -->
-         * 
- */ - parsed.assertEquals( - htmlBlock(" "), - indentedCodeBlock(""), - ) - } - - @Test - fun `should parse spec sample 184 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |
- | - |
- """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
<div>
-         * 
- */ - parsed.assertEquals( - htmlBlock("
"), - indentedCodeBlock("
"), - ) - } - - @Test - fun `should parse spec sample 185 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - |
- |bar - |
- """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo

- *
- * bar - *
- */ - parsed.assertEquals( - paragraph("Foo"), - htmlBlock( - """ - |
- |bar - |
- """ - .trimMargin(), - ), - ) - } - - @Test - fun `should parse spec sample 186 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |
- |bar - |
- |*foo* - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- * bar - *
- * *foo* - */ - parsed.assertEquals( - htmlBlock( - """ - |
- |bar - |
- |*foo* - """ - .trimMargin(), - ), - ) - } - - @Test - fun `should parse spec sample 187 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - | - |baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo - * - * baz

- */ - parsed.assertEquals(paragraph("Foo baz")) - } - - @Test - fun `should parse spec sample 188 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |
- | - |*Emphasized* text. - | - |
- """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

Emphasized text.

- *
- */ - parsed.assertEquals( - htmlBlock("
"), - paragraph("*Emphasized* text."), - htmlBlock("
"), - ) - } - - @Test - fun `should parse spec sample 189 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |
- |*Emphasized* text. - |
- """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- * *Emphasized* text. - *
- */ - parsed.assertEquals( - htmlBlock( - """ - |
- |*Emphasized* text. - |
- """ - .trimMargin(), - ), - ) - } - - @Test - fun `should parse spec sample 190 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - | - | - | - | - | - | - | - |
- |Hi - |
- """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - * - * - * - *
- * Hi - *
- */ - parsed.assertEquals( - htmlBlock(""), - htmlBlock(""), - htmlBlock(""), - htmlBlock(""), - htmlBlock("
\nHi\n
"), - ) - } - - @Test - fun `should parse spec sample 191 correctly (HTML blocks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - | - | - | - | - | - | - | - |
- | Hi - |
- """ - .trimMargin(), - ) - - /* - * Expected HTML: - * - * - *
<td>
-         *   Hi
-         * </td>
-         * 
- * - *
- */ - parsed.assertEquals( - htmlBlock(""), - htmlBlock(" "), - indentedCodeBlock(""), - htmlBlock(" "), - htmlBlock("
\n Hi\n
"), - ) - } - - @Test - fun `should parse spec sample 192 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo]: /url "title" - | - |[foo] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](/url \"title\")")) - } - - @Test - fun `should parse spec sample 193 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - | [foo]: - | /url - | 'the title' - | - |[foo] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](/url \"the title\")")) - } - - @Test - fun `should parse spec sample 194 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[Foo*bar\]]:my_(url) 'title (with parens)' - | - |[Foo*bar\]] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo*bar]

- */ - parsed.assertEquals(paragraph("[Foo\\*bar\\]](my_\\(url\\) \"title (with parens)\")")) - } - - @Test - fun `should parse spec sample 195 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[Foo bar]: - | - |'title' - | - |[Foo bar] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo bar

- */ - parsed.assertEquals(paragraph("[Foo bar]( \"title\")")) - } - - @Test - fun `should parse spec sample 196 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo]: /url ' - |title - |line1 - |line2 - |' - | - |[foo] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](/url \" title\nline1\nline2 \")")) - } - - @Test - fun `should parse spec sample 197 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo]: /url 'title - | - |with blank line' - | - |[foo] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foo]: /url 'title

- *

with blank line'

- *

[foo]

- */ - parsed.assertEquals( - paragraph("\\[foo\\]: /url 'title"), - paragraph("with blank line'"), - paragraph("\\[foo\\]"), - ) - } - - @Test - fun `should parse spec sample 198 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo]: - |/url - | - |[foo] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](/url)")) - } - - @Test - fun `should parse spec sample 199 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo]: - | - |[foo] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foo]:

- *

[foo]

- */ - parsed.assertEquals( - paragraph("\\[foo\\]:"), - paragraph("\\[foo\\]"), - ) - } - - @Test - fun `should parse spec sample 200 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo]: <> - | - |[foo] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo]()")) - } - - @Test - fun `should parse spec sample 201 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo]: (baz) - | - |[foo] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foo]: (baz)

- *

[foo]

- */ - parsed.assertEquals( - paragraph("\\[foo\\]: \\(baz\\)"), - paragraph("\\[foo\\]"), - ) - } - - @Test - fun `should parse spec sample 202 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo]: /url\bar\*baz "foo\"bar\baz" - | - |[foo] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](/url\\bar*baz \"foo\\\"bar\\baz\")")) - } - - @Test - fun `should parse spec sample 203 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo] - | - |[foo]: url - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](url)")) - } - - @Test - fun `should parse spec sample 204 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo] - | - |[foo]: first - |[foo]: second - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](first)")) - } - - @Test - fun `should parse spec sample 205 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[FOO]: /url - | - |[Foo] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo

- */ - parsed.assertEquals(paragraph("[Foo](/url)")) - } - - @Test - fun `should parse spec sample 206 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[ΑΓΩ]: /φου - | - |[αγω] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

αγω

- */ - parsed.assertEquals(paragraph("[αγω](/φου)")) - } - - @Test - fun `should parse spec sample 207 correctly (Link reference definitions)`() { - val parsed = processor.processMarkdownDocument("[foo]: /url") - - /* - * Expected HTML: - * [intentionally blank] - */ - parsed.assertEquals() - } - - @Test - fun `should parse spec sample 208 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[ - |foo - |]: /url - |bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

bar

- */ - parsed.assertEquals(paragraph("bar")) - } - - @Test - fun `should parse spec sample 209 correctly (Link reference definitions)`() { - val parsed = processor.processMarkdownDocument("[foo]: /url \"title\" ok") - - /* - * Expected HTML: - *

[foo]: /url "title" ok

- */ - parsed.assertEquals(paragraph("\\[foo\\]: /url \"title\" ok")) - } - - @Test - fun `should parse spec sample 210 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo]: /url - |"title" ok - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

"title" ok

- */ - parsed.assertEquals(paragraph("\"title\" ok")) - } - - @Test - fun `should parse spec sample 211 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - | [foo]: /url "title" - | - |[foo] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
[foo]: /url "title"
-         * 
- *

[foo]

- */ - parsed.assertEquals( - indentedCodeBlock("[foo]: /url \"title\""), - paragraph("\\[foo\\]"), - ) - } - - @Test - fun `should parse spec sample 212 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |``` - |[foo]: /url - |``` - | - |[foo] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
[foo]: /url
-         * 
- *

[foo]

- */ - parsed.assertEquals( - fencedCodeBlock("[foo]: /url"), - paragraph("\\[foo\\]"), - ) - } - - @Test - fun `should parse spec sample 213 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - |[bar]: /baz - | - |[bar] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo - * [bar]: /baz

- *

[bar]

- */ - parsed.assertEquals( - paragraph("Foo \\[bar\\]: /baz"), - paragraph("\\[bar\\]"), - ) - } - - @Test - fun `should parse spec sample 214 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |# [Foo] - |[foo]: /url - |> bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo

- *
- *

bar

- *
- */ - parsed.assertEquals( - heading(level = 1, "[Foo](/url)"), - blockQuote(paragraph("bar")), - ) - } - - @Test - fun `should parse spec sample 215 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo]: /url - |bar - |=== - |[foo] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

bar

- *

foo

- */ - parsed.assertEquals( - heading(level = 1, "bar"), - paragraph("[foo](/url)"), - ) - } - - @Test - fun `should parse spec sample 216 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo]: /url - |=== - |[foo] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

=== - * foo

- */ - parsed.assertEquals(paragraph("=== [foo](/url)")) - } - - @Test - fun `should parse spec sample 217 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo]: /foo-url "foo" - |[bar]: /bar-url - | "bar" - |[baz]: /baz-url - | - |[foo], - |[bar], - |[baz] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo, - * bar, - * baz

- */ - parsed.assertEquals( - paragraph("[foo](/foo-url \"foo\"), [bar](/bar-url \"bar\"), [baz](/baz-url)"), - ) - } - - @Test - fun `should parse spec sample 218 correctly (Link reference definitions)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo] - | - |> [foo]: /url - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- *
- *
- */ - parsed.assertEquals( - paragraph("[foo](/url)"), - blockQuote(), - ) - } - - @Test - fun `should parse spec sample 219 correctly (Paragraphs)`() { - val parsed = - processor.processMarkdownDocument( - """ - |aaa - | - |bbb - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

aaa

- *

bbb

- */ - parsed.assertEquals( - paragraph("aaa"), - paragraph("bbb"), - ) - } - - @Test - fun `should parse spec sample 220 correctly (Paragraphs)`() { - val parsed = - processor.processMarkdownDocument( - """ - |aaa - |bbb - | - |ccc - |ddd - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

aaa - * bbb

- *

ccc - * ddd

- */ - parsed.assertEquals( - paragraph("aaa bbb"), - paragraph("ccc ddd"), - ) - } - - @Test - fun `should parse spec sample 221 correctly (Paragraphs)`() { - val parsed = - processor.processMarkdownDocument( - """ - |aaa - | - | - |bbb - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

aaa

- *

bbb

- */ - parsed.assertEquals( - paragraph("aaa"), - paragraph("bbb"), - ) - } - - @Test - fun `should parse spec sample 222 correctly (Paragraphs)`() { - val parsed = - processor.processMarkdownDocument( - """ - | aaa - | bbb - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

aaa - * bbb

- */ - parsed.assertEquals(paragraph("aaa bbb")) - } - - @Test - fun `should parse spec sample 223 correctly (Paragraphs)`() { - val parsed = - processor.processMarkdownDocument( - """ - |aaa - | bbb - | ccc - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

aaa - * bbb - * ccc

- */ - parsed.assertEquals(paragraph("aaa bbb ccc")) - } - - @Test - fun `should parse spec sample 224 correctly (Paragraphs)`() { - val parsed = - processor.processMarkdownDocument( - """ - | aaa - |bbb - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

aaa - * bbb

- */ - parsed.assertEquals(paragraph("aaa bbb")) - } - - @Test - fun `should parse spec sample 225 correctly (Paragraphs)`() { - val parsed = - processor.processMarkdownDocument( - """ - | aaa - |bbb - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
aaa
-         * 
- *

bbb

- */ - parsed.assertEquals( - indentedCodeBlock("aaa"), - paragraph("bbb"), - ) - } - - @Test - fun `should parse spec sample 226 correctly (Paragraphs)`() { - val parsed = - processor.processMarkdownDocument( - """ - |aaa - |bbb - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

aaa
- * bbb

- */ - parsed.assertEquals(paragraph("aaa
bbb")) - } - - @Test - fun `should parse spec sample 227 correctly (Blank lines)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - | - |aaa - | - | - |# aaa - | - | - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

aaa

- *

aaa

- */ - parsed.assertEquals( - paragraph("aaa"), - heading(level = 1, "aaa"), - ) - } - - @Test - fun `should parse spec sample 228 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> # Foo - |> bar - |> baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

Foo

- *

bar - * baz

- *
- */ - parsed.assertEquals( - blockQuote( - heading(level = 1, "Foo"), - paragraph("bar baz"), - ), - ) - } - - @Test - fun `should parse spec sample 229 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |># Foo - |>bar - |> baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

Foo

- *

bar - * baz

- *
- */ - parsed.assertEquals( - blockQuote( - heading(level = 1, "Foo"), - paragraph("bar baz"), - ), - ) - } - - @Test - fun `should parse spec sample 230 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - | > # Foo - | > bar - | > baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

Foo

- *

bar - * baz

- *
- */ - parsed.assertEquals( - blockQuote( - heading(level = 1, "Foo"), - paragraph("bar baz"), - ), - ) - } - - @Test - fun `should parse spec sample 231 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - | > # Foo - | > bar - | > baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
> # Foo
-         * > bar
-         * > baz
-         * 
- */ - parsed.assertEquals(indentedCodeBlock("> # Foo\n> bar\n> baz")) - } - - @Test - fun `should parse spec sample 232 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> # Foo - |> bar - |baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

Foo

- *

bar - * baz

- *
- */ - parsed.assertEquals( - blockQuote( - heading(level = 1, "Foo"), - paragraph("bar baz"), - ), - ) - } - - @Test - fun `should parse spec sample 233 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> bar - |baz - |> foo - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

bar - * baz - * foo

- *
- */ - parsed.assertEquals(blockQuote(paragraph("bar baz foo"))) - } - - @Test - fun `should parse spec sample 234 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> foo - |--- - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

foo

- *
- *
- */ - parsed.assertEquals( - blockQuote(paragraph("foo")), - ThematicBreak, - ) - } - - @Test - fun `should parse spec sample 235 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> - foo - |- bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
    - *
  • foo
  • - *
- *
- *
    - *
  • bar
  • - *
- */ - parsed.assertEquals( - blockQuote(unorderedList(listItem(paragraph("foo")))), - unorderedList(listItem(paragraph("bar"))), - ) - } - - @Test - fun `should parse spec sample 236 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> foo - | bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
foo
-         * 
- *
- *
bar
-         * 
- */ - parsed.assertEquals( - blockQuote(indentedCodeBlock("foo")), - indentedCodeBlock("bar"), - ) - } - - @Test - fun `should parse spec sample 237 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> ``` - |foo - |``` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
- *
- *

foo

- *
- */ - parsed.assertEquals( - blockQuote(fencedCodeBlock("")), - paragraph("foo"), - fencedCodeBlock(""), - ) - } - - @Test - fun `should parse spec sample 238 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> foo - | - bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

foo - * - bar

- *
- */ - parsed.assertEquals(blockQuote(paragraph("foo - bar"))) - } - - @Test - fun `should parse spec sample 239 correctly (Block quotes)`() { - val parsed = processor.processMarkdownDocument(">") - - /* - * Expected HTML: - *
- *
- */ - parsed.assertEquals(blockQuote()) - } - - @Test - fun `should parse spec sample 240 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> - |> - |> - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
- */ - parsed.assertEquals(blockQuote()) - } - - @Test - fun `should parse spec sample 241 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> - |> foo - |> - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

foo

- *
- */ - parsed.assertEquals(blockQuote(paragraph("foo"))) - } - - @Test - fun `should parse spec sample 242 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> foo - | - |> bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

foo

- *
- *
- *

bar

- *
- */ - parsed.assertEquals( - blockQuote(paragraph("foo")), - blockQuote(paragraph("bar")), - ) - } - - @Test - fun `should parse spec sample 243 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> foo - |> bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

foo - * bar

- *
- */ - parsed.assertEquals(blockQuote(paragraph("foo bar"))) - } - - @Test - fun `should parse spec sample 244 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> foo - |> - |> bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

foo

- *

bar

- *
- */ - parsed.assertEquals( - blockQuote( - paragraph("foo"), - paragraph("bar"), - ), - ) - } - - @Test - fun `should parse spec sample 245 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |foo - |> bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- *
- *

bar

- *
- */ - parsed.assertEquals( - paragraph("foo"), - blockQuote(paragraph("bar")), - ) - } - - @Test - fun `should parse spec sample 246 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> aaa - |*** - |> bbb - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

aaa

- *
- *
- *
- *

bbb

- *
- */ - parsed.assertEquals( - blockQuote(paragraph("aaa")), - ThematicBreak, - blockQuote(paragraph("bbb")), - ) - } - - @Test - fun `should parse spec sample 247 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> bar - |baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

bar - * baz

- *
- */ - parsed.assertEquals(blockQuote(paragraph("bar baz"))) - } - - @Test - fun `should parse spec sample 248 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> bar - | - |baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

bar

- *
- *

baz

- */ - parsed.assertEquals( - blockQuote(paragraph("bar")), - paragraph("baz"), - ) - } - - @Test - fun `should parse spec sample 249 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> bar - |> - |baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *

bar

- *
- *

baz

- */ - parsed.assertEquals( - blockQuote(paragraph("bar")), - paragraph("baz"), - ) - } - - @Test - fun `should parse spec sample 250 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> > > foo - |bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
- *
- *

foo - * bar

- *
- *
- *
- */ - parsed.assertEquals( - blockQuote( - blockQuote( - blockQuote(paragraph("foo bar")), - ), - ), - ) - } - - @Test - fun `should parse spec sample 251 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |>>> foo - |> bar - |>>baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
- *
- *

foo - * bar - * baz

- *
- *
- *
- */ - parsed.assertEquals( - blockQuote( - blockQuote( - blockQuote(paragraph("foo bar baz")), - ), - ), - ) - } - - @Test - fun `should parse spec sample 252 correctly (Block quotes)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> code - | - |> not code - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
code
-         * 
- *
- *
- *

not code

- *
- */ - parsed.assertEquals( - blockQuote(indentedCodeBlock("code")), - blockQuote(paragraph("not code")), - ) - } - - @Test - fun `should parse spec sample 253 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |A paragraph - |with two lines. - | - | indented code - | - |> A block quote. - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

A paragraph - * with two lines.

- *
indented code
-         * 
- *
- *

A block quote.

- *
- */ - parsed.assertEquals( - paragraph("A paragraph with two lines."), - indentedCodeBlock("indented code"), - blockQuote(paragraph("A block quote.")), - ) - } - - @Test - fun `should parse spec sample 254 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |1. A paragraph - | with two lines. - | - | indented code - | - | > A block quote. - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. - *

    A paragraph - * with two lines.

    - *
    indented code
    -         * 
    - *
    - *

    A block quote.

    - *
    - *
  2. - *
- */ - parsed.assertEquals( - orderedList( - listItem( - paragraph("A paragraph with two lines."), - indentedCodeBlock("indented code"), - blockQuote(paragraph("A block quote.")), - ), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 255 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- one - | - | two - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • one
  • - *
- *

two

- */ - parsed.assertEquals( - unorderedList(listItem(paragraph("one"))), - paragraph("two"), - ) - } - - @Test - fun `should parse spec sample 256 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- one - | - | two - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    one

    - *

    two

    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("one"), paragraph("two")), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 257 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - one - | - | two - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • one
  • - *
- *
 two
-         * 
- */ - parsed.assertEquals( - unorderedList(listItem(paragraph("one"))), - indentedCodeBlock(" two"), - ) - } - - @Test - fun `should parse spec sample 258 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - one - | - | two - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    one

    - *

    two

    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("one"), paragraph("two")), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 259 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - | > > 1. one - |>> - |>> two - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
- *
    - *
  1. - *

    one

    - *

    two

    - *
  2. - *
- *
- *
- */ - parsed.assertEquals( - blockQuote( - blockQuote( - orderedList( - listItem(paragraph("one"), paragraph("two")), - isTight = false, - ), - ), - ), - ) - } - - @Test - fun `should parse spec sample 260 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |>>- one - |>> - | > > two - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
- *
    - *
  • one
  • - *
- *

two

- *
- *
- */ - parsed.assertEquals( - blockQuote( - blockQuote( - unorderedList(listItem(paragraph("one"))), - paragraph("two"), - ), - ), - ) - } - - @Test - fun `should parse spec sample 261 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |-one - | - |2.two - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

-one

- *

2.two

- */ - parsed.assertEquals( - paragraph("-one"), - paragraph("2.two"), - ) - } - - @Test - fun `should parse spec sample 262 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- foo - | - | - | bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    foo

    - *

    bar

    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem( - paragraph("foo"), - paragraph("bar"), - ), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 263 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |1. foo - | - | ``` - | bar - | ``` - | - | baz - | - | > bam - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. - *

    foo

    - *
    bar
    -         * 
    - *

    baz

    - *
    - *

    bam

    - *
    - *
  2. - *
- */ - parsed.assertEquals( - orderedList( - listItem( - paragraph("foo"), - fencedCodeBlock("bar"), - paragraph("baz"), - blockQuote(paragraph("bam")), - ), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 264 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- Foo - | - | bar - | - | - | baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    Foo

    - *
    bar
    -         *
    -         *
    -         * baz
    -         * 
    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("Foo"), indentedCodeBlock("bar\n\n\nbaz")), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 265 correctly (List items)`() { - val parsed = processor.processMarkdownDocument("123456789. ok") - - /* - * Expected HTML: - *
    - *
  1. ok
  2. - *
- */ - parsed.assertEquals(orderedList(listItem(paragraph("ok")), startFrom = 123456789)) - } - - @Test - fun `should parse spec sample 266 correctly (List items)`() { - val parsed = processor.processMarkdownDocument("1234567890. not ok") - - /* - * Expected HTML: - *

1234567890. not ok

- */ - parsed.assertEquals(paragraph("1234567890. not ok")) - } - - @Test - fun `should parse spec sample 267 correctly (List items)`() { - val parsed = processor.processMarkdownDocument("0. ok") - - /* - * Expected HTML: - *
    - *
  1. ok
  2. - *
- */ - parsed.assertEquals(orderedList(listItem(paragraph("ok")), startFrom = 0)) - } - - @Test - fun `should parse spec sample 268 correctly (List items)`() { - val parsed = processor.processMarkdownDocument("003. ok") - - /* - * Expected HTML: - *
    - *
  1. ok
  2. - *
- */ - parsed.assertEquals(orderedList(listItem(paragraph("ok")), startFrom = 3)) - } - - @Test - fun `should parse spec sample 269 correctly (List items)`() { - val parsed = processor.processMarkdownDocument("-1. not ok") - - /* - * Expected HTML: - *

-1. not ok

- */ - parsed.assertEquals(paragraph("-1. not ok")) - } - - @Test - fun `should parse spec sample 270 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- foo - | - | bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    foo

    - *
    bar
    -         * 
    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("foo"), indentedCodeBlock("bar")), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 271 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - | 10. foo - | - | bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. - *

    foo

    - *
    bar
    -         * 
    - *
  2. - *
- */ - parsed.assertEquals( - orderedList( - listItem(paragraph("foo"), indentedCodeBlock("bar")), - startFrom = 10, - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 272 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - | indented code - | - |paragraph - | - | more code - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
indented code
-         * 
- *

paragraph

- *
more code
-         * 
- */ - parsed.assertEquals( - indentedCodeBlock("indented code"), - paragraph("paragraph"), - indentedCodeBlock("more code"), - ) - } - - @Test - fun `should parse spec sample 273 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |1. indented code - | - | paragraph - | - | more code - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. - *
    indented code
    -         * 
    - *

    paragraph

    - *
    more code
    -         * 
    - *
  2. - *
- */ - parsed.assertEquals( - orderedList( - listItem( - indentedCodeBlock("indented code"), - paragraph("paragraph"), - indentedCodeBlock("more code"), - ), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 274 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |1. indented code - | - | paragraph - | - | more code - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. - *
     indented code
    -         * 
    - *

    paragraph

    - *
    more code
    -         * 
    - *
  2. - *
- */ - parsed.assertEquals( - orderedList( - listItem( - indentedCodeBlock(" indented code"), - paragraph("paragraph"), - indentedCodeBlock("more code"), - ), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 275 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - | foo - | - |bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- *

bar

- */ - parsed.assertEquals( - paragraph("foo"), - paragraph("bar"), - ) - } - - @Test - fun `should parse spec sample 276 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- foo - | - | bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • foo
  • - *
- *

bar

- */ - parsed.assertEquals( - unorderedList(listItem(paragraph("foo"))), - paragraph("bar"), - ) - } - - @Test - fun `should parse spec sample 277 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- foo - | - | bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    foo

    - *

    bar

    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("foo"), paragraph("bar")), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 278 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- - | foo - |- - | ``` - | bar - | ``` - |- - | baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • foo
  • - *
  • - *
    bar
    -         * 
    - *
  • - *
  • - *
    baz
    -         * 
    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("foo")), - listItem(fencedCodeBlock("bar")), - listItem(indentedCodeBlock("baz")), - ), - ) - } - - @Test - fun `should parse spec sample 279 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- - | foo - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • foo
  • - *
- */ - parsed.assertEquals(unorderedList(listItem(paragraph("foo")))) - } - - @Test - fun `should parse spec sample 280 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- - | - | foo - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *
- *

foo

- */ - parsed.assertEquals( - unorderedList(listItem()), - paragraph("foo"), - ) - } - - @Test - fun `should parse spec sample 281 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- foo - |- - |- bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • foo
  • - *
  • - *
  • bar
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("foo")), - listItem(), - listItem(paragraph("bar")), - ), - ) - } - - @Test - fun `should parse spec sample 282 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- foo - |- - |- bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • foo
  • - *
  • - *
  • bar
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("foo")), - listItem(), - listItem(paragraph("bar")), - ), - ) - } - - @Test - fun `should parse spec sample 283 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |1. foo - |2. - |3. bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. foo
  2. - *
  3. - *
  4. bar
  5. - *
- */ - parsed.assertEquals( - orderedList( - listItem(paragraph("foo")), - listItem(), - listItem(paragraph("bar")), - ), - ) - } - - @Test - fun `should parse spec sample 284 correctly (List items)`() { - val parsed = processor.processMarkdownDocument("*") - - /* - * Expected HTML: - *
    - *
  • - *
- */ - parsed.assertEquals(unorderedList(listItem(), bulletMarker = '*')) - } - - @Test - fun `should parse spec sample 285 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |foo - |* - | - |foo - |1. - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo - * *

- *

foo - * 1.

- */ - parsed.assertEquals( - paragraph("foo \\*"), - paragraph("foo 1."), - ) - } - - @Test - fun `should parse spec sample 286 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - | 1. A paragraph - | with two lines. - | - | indented code - | - | > A block quote. - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. - *

    A paragraph - * with two lines.

    - *
    indented code
    -         * 
    - *
    - *

    A block quote.

    - *
    - *
  2. - *
- */ - parsed.assertEquals( - orderedList( - listItem( - paragraph("A paragraph with two lines."), - indentedCodeBlock("indented code"), - blockQuote(paragraph("A block quote.")), - ), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 287 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - | 1. A paragraph - | with two lines. - | - | indented code - | - | > A block quote. - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. - *

    A paragraph - * with two lines.

    - *
    indented code
    -         * 
    - *
    - *

    A block quote.

    - *
    - *
  2. - *
- */ - parsed.assertEquals( - orderedList( - listItem( - paragraph("A paragraph with two lines."), - indentedCodeBlock("indented code"), - blockQuote(paragraph("A block quote.")), - ), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 288 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - | 1. A paragraph - | with two lines. - | - | indented code - | - | > A block quote. - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. - *

    A paragraph - * with two lines.

    - *
    indented code
    -         * 
    - *
    - *

    A block quote.

    - *
    - *
  2. - *
- */ - parsed.assertEquals( - orderedList( - listItem( - paragraph("A paragraph with two lines."), - indentedCodeBlock("indented code"), - blockQuote(paragraph("A block quote.")), - ), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 289 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - | 1. A paragraph - | with two lines. - | - | indented code - | - | > A block quote. - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
1.  A paragraph
-         *     with two lines.
-         *
-         *         indented code
-         *
-         *     > A block quote.
-         * 
- */ - parsed.assertEquals( - indentedCodeBlock( - """ - |1. A paragraph - | with two lines. - | - | indented code - | - | > A block quote. - """ - .trimMargin(), - ), - ) - } - - @Test - fun `should parse spec sample 290 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - | 1. A paragraph - |with two lines. - | - | indented code - | - | > A block quote. - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. - *

    A paragraph - * with two lines.

    - *
    indented code
    -         * 
    - *
    - *

    A block quote.

    - *
    - *
  2. - *
- */ - parsed.assertEquals( - orderedList( - listItem( - paragraph("A paragraph with two lines."), - indentedCodeBlock("indented code"), - blockQuote(paragraph("A block quote.")), - ), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 291 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - | 1. A paragraph - | with two lines. - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. A paragraph - * with two lines.
  2. - *
- */ - parsed.assertEquals( - orderedList( - listItem(paragraph("A paragraph with two lines.")), - ), - ) - } - - @Test - fun `should parse spec sample 292 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> 1. > Blockquote - |continued here. - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
    - *
  1. - *
    - *

    Blockquote - * continued here.

    - *
    - *
  2. - *
- *
- */ - parsed.assertEquals( - blockQuote( - orderedList(listItem(blockQuote(paragraph("Blockquote continued here.")))), - ), - ) - } - - @Test - fun `should parse spec sample 293 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |> 1. > Blockquote - |> continued here. - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
- *
    - *
  1. - *
    - *

    Blockquote - * continued here.

    - *
    - *
  2. - *
- *
- */ - parsed.assertEquals( - blockQuote( - orderedList(listItem(blockQuote(paragraph("Blockquote continued here.")))), - ), - ) - } - - @Test - fun `should parse spec sample 294 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- foo - | - bar - | - baz - | - boo - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • foo - *
      - *
    • bar - *
        - *
      • baz - *
          - *
        • boo
        • - *
        - *
      • - *
      - *
    • - *
    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem( - paragraph("foo"), - unorderedList( - listItem( - paragraph("bar"), - unorderedList( - listItem( - paragraph("baz"), - unorderedList(listItem(paragraph("boo"))), - ), - ), - ), - ), - ), - ), - ) - } - - @Test - fun `should parse spec sample 295 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- foo - | - bar - | - baz - | - boo - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • foo
  • - *
  • bar
  • - *
  • baz
  • - *
  • boo
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("foo")), - listItem(paragraph("bar")), - listItem(paragraph("baz")), - listItem(paragraph("boo")), - ), - ) - } - - @Test - fun `should parse spec sample 296 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |10) foo - | - bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. foo - *
      - *
    • bar
    • - *
    - *
  2. - *
- */ - parsed.assertEquals( - orderedList( - listItem( - paragraph("foo"), - unorderedList(listItem(paragraph("bar"))), - ), - startFrom = 10, - delimiter = ')', - ), - ) - } - - @Test - fun `should parse spec sample 297 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |10) foo - | - bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. foo
  2. - *
- *
    - *
  • bar
  • - *
- */ - parsed.assertEquals( - orderedList( - listItem(paragraph("foo")), - startFrom = 10, - delimiter = ')', - ), - unorderedList(listItem(paragraph("bar"))), - ) - } - - @Test - fun `should parse spec sample 298 correctly (List items)`() { - val parsed = processor.processMarkdownDocument("- - foo") - - /* - * Expected HTML: - *
    - *
  • - *
      - *
    • foo
    • - *
    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem( - unorderedList(listItem(paragraph("foo"))), - ), - ), - ) - } - - @Test - fun `should parse spec sample 299 correctly (List items)`() { - val parsed = processor.processMarkdownDocument("1. - 2. foo") - - /* - * Expected HTML: - *
    - *
  1. - *
      - *
    • - *
        - *
      1. foo
      2. - *
      - *
    • - *
    - *
  2. - *
- */ - parsed.assertEquals( - orderedList( - listItem( - unorderedList( - listItem( - orderedList( - listItem(paragraph("foo")), - startFrom = 2, - ), - ), - ), - ), - ), - ) - } - - @Test - fun `should parse spec sample 300 correctly (List items)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- # Foo - |- Bar - | --- - | baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    Foo

    - *
  • - *
  • - *

    Bar

    - * baz
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(heading(level = 1, "Foo")), - listItem(heading(level = 2, "Bar"), paragraph("baz")), - ), - ) - } - - @Test - fun `should parse spec sample 301 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- foo - |- bar - |+ baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • foo
  • - *
  • bar
  • - *
- *
    - *
  • baz
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("foo")), - listItem(paragraph("bar")), - ), - unorderedList( - listItem(paragraph("baz")), - bulletMarker = '+', - ), - ) - } - - @Test - fun `should parse spec sample 302 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |1. foo - |2. bar - |3) baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. foo
  2. - *
  3. bar
  4. - *
- *
    - *
  1. baz
  2. - *
- */ - parsed.assertEquals( - orderedList( - listItem(paragraph("foo")), - listItem(paragraph("bar")), - ), - orderedList( - listItem(paragraph("baz")), - startFrom = 3, - delimiter = ')', - ), - ) - } - - @Test - fun `should parse spec sample 303 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |Foo - |- bar - |- baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo

- *
    - *
  • bar
  • - *
  • baz
  • - *
- */ - parsed.assertEquals( - paragraph("Foo"), - unorderedList( - listItem(paragraph("bar")), - listItem(paragraph("baz")), - ), - ) - } - - @Test - fun `should parse spec sample 304 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |The number of windows in my house is - |14. The number of doors is 6. - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

The number of windows in my house is - * 14. The number of doors is 6.

- */ - parsed.assertEquals( - paragraph("The number of windows in my house is 14. The number of doors is 6."), - ) - } - - @Test - fun `should parse spec sample 305 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |The number of windows in my house is - |1. The number of doors is 6. - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

The number of windows in my house is

- *
    - *
  1. The number of doors is 6.
  2. - *
- */ - parsed.assertEquals( - paragraph("The number of windows in my house is"), - orderedList(listItem(paragraph("The number of doors is 6."))), - ) - } - - @Test - fun `should parse spec sample 306 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- foo - | - |- bar - | - | - |- baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    foo

    - *
  • - *
  • - *

    bar

    - *
  • - *
  • - *

    baz

    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("foo")), - listItem(paragraph("bar")), - listItem(paragraph("baz")), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 307 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- foo - | - bar - | - baz - | - | - | bim - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • foo - *
      - *
    • bar - *
        - *
      • - *

        baz

        - *

        bim

        - *
      • - *
      - *
    • - *
    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem( - paragraph("foo"), - unorderedList( - listItem( - paragraph("bar"), - unorderedList( - listItem( - paragraph("baz"), - paragraph("bim"), - ), - isTight = false, - ), - ), - ), - ), - ), - ) - } - - @Test - fun `should parse spec sample 308 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- foo - |- bar - | - | - | - |- baz - |- bim - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • foo
  • - *
  • bar
  • - *
- * - *
    - *
  • baz
  • - *
  • bim
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("foo")), - listItem(paragraph("bar")), - ), - htmlBlock(""), - unorderedList( - listItem(paragraph("baz")), - listItem(paragraph("bim")), - ), - ) - } - - @Test - fun `should parse spec sample 309 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- foo - | - | notcode - | - |- foo - | - | - | - | code - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    foo

    - *

    notcode

    - *
  • - *
  • - *

    foo

    - *
  • - *
- * - *
code
-         * 
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("foo"), paragraph("notcode")), - listItem(paragraph("foo")), - isTight = false, - ), - htmlBlock(""), - indentedCodeBlock("code"), - ) - } - - @Test - fun `should parse spec sample 310 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- a - | - b - | - c - | - d - | - e - | - f - |- g - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • a
  • - *
  • b
  • - *
  • c
  • - *
  • d
  • - *
  • e
  • - *
  • f
  • - *
  • g
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("a")), - listItem(paragraph("b")), - listItem(paragraph("c")), - listItem(paragraph("d")), - listItem(paragraph("e")), - listItem(paragraph("f")), - listItem(paragraph("g")), - ), - ) - } - - @Test - fun `should parse spec sample 311 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |1. a - | - | 2. b - | - | 3. c - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. - *

    a

    - *
  2. - *
  3. - *

    b

    - *
  4. - *
  5. - *

    c

    - *
  6. - *
- */ - parsed.assertEquals( - orderedList( - listItem(paragraph("a")), - listItem(paragraph("b")), - listItem(paragraph("c")), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 312 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- a - | - b - | - c - | - d - | - e - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • a
  • - *
  • b
  • - *
  • c
  • - *
  • d - * - e
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("a")), - listItem(paragraph("b")), - listItem(paragraph("c")), - listItem(paragraph("d - e")), - ), - ) - } - - @Test - fun `should parse spec sample 313 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |1. a - | - | 2. b - | - | 3. c - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. - *

    a

    - *
  2. - *
  3. - *

    b

    - *
  4. - *
- *
3. c
-         * 
- */ - parsed.assertEquals( - orderedList( - listItem(paragraph("a")), - listItem(paragraph("b")), - isTight = false, - ), - indentedCodeBlock("3. c"), - ) - } - - @Test - fun `should parse spec sample 314 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- a - |- b - | - |- c - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    a

    - *
  • - *
  • - *

    b

    - *
  • - *
  • - *

    c

    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("a")), - listItem(paragraph("b")), - listItem(paragraph("c")), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 315 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |* a - |* - | - |* c - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    a

    - *
  • - *
  • - *
  • - *

    c

    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("a")), - listItem(), - listItem(paragraph("c")), - isTight = false, - bulletMarker = '*', - ), - ) - } - - @Test - fun `should parse spec sample 316 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- a - |- b - | - | c - |- d - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    a

    - *
  • - *
  • - *

    b

    - *

    c

    - *
  • - *
  • - *

    d

    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("a")), - listItem(paragraph("b"), paragraph("c")), - listItem(paragraph("d")), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 317 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- a - |- b - | - | [ref]: /url - |- d - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    a

    - *
  • - *
  • - *

    b

    - *
  • - *
  • - *

    d

    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("a")), - listItem(paragraph("b")), - listItem(paragraph("d")), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 318 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- a - |- ``` - | b - | - | - | ``` - |- c - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • a
  • - *
  • - *
    b
    -         *
    -         *
    -         * 
    - *
  • - *
  • c
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("a")), - listItem(fencedCodeBlock("b")), - listItem(paragraph("c")), - ), - ) - } - - @Test - fun `should parse spec sample 319 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- a - | - b - | - | c - |- d - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • a - *
      - *
    • - *

      b

      - *

      c

      - *
    • - *
    - *
  • - *
  • d
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem( - paragraph("a"), - unorderedList( - listItem( - paragraph("b"), - paragraph("c"), - ), - isTight = false, - ), - ), - listItem(paragraph("d")), - ), - ) - } - - @Test - fun `should parse spec sample 320 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |* a - | > b - | > - |* c - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • a - *
    - *

    b

    - *
    - *
  • - *
  • c
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem(paragraph("a"), blockQuote(paragraph("b"))), - listItem(paragraph("c")), - bulletMarker = '*', - ), - ) - } - - @Test - fun `should parse spec sample 321 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- a - | > b - | ``` - | c - | ``` - |- d - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • a - *
    - *

    b

    - *
    - *
    c
    -         * 
    - *
  • - *
  • d
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem( - paragraph("a"), - blockQuote(paragraph("b")), - fencedCodeBlock("c"), - ), - listItem(paragraph("d")), - ), - ) - } - - @Test - fun `should parse spec sample 322 correctly (Lists)`() { - val parsed = processor.processMarkdownDocument("- a") - - /* - * Expected HTML: - *
    - *
  • a
  • - *
- */ - parsed.assertEquals(unorderedList(listItem(paragraph("a")))) - } - - @Test - fun `should parse spec sample 323 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- a - | - b - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • a - *
      - *
    • b
    • - *
    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem( - paragraph("a"), - unorderedList(listItem(paragraph("b"))), - ), - ), - ) - } - - @Test - fun `should parse spec sample 324 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |1. ``` - | foo - | ``` - | - | bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  1. - *
    foo
    -         * 
    - *

    bar

    - *
  2. - *
- */ - parsed.assertEquals( - orderedList( - listItem( - fencedCodeBlock("foo"), - paragraph("bar"), - ), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 325 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |* foo - | * bar - | - | baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    foo

    - *
      - *
    • bar
    • - *
    - *

    baz

    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem( - paragraph("foo"), - unorderedList( - listItem(paragraph("bar")), - bulletMarker = '*', - ), - paragraph("baz"), - ), - bulletMarker = '*', - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 326 correctly (Lists)`() { - val parsed = - processor.processMarkdownDocument( - """ - |- a - | - b - | - c - | - |- d - | - e - | - f - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *
    - *
  • - *

    a

    - *
      - *
    • b
    • - *
    • c
    • - *
    - *
  • - *
  • - *

    d

    - *
      - *
    • e
    • - *
    • f
    • - *
    - *
  • - *
- */ - parsed.assertEquals( - unorderedList( - listItem( - paragraph("a"), - unorderedList( - listItem(paragraph("b")), - listItem(paragraph("c")), - ), - ), - listItem( - paragraph("d"), - unorderedList( - listItem(paragraph("e")), - listItem(paragraph("f")), - ), - ), - isTight = false, - ), - ) - } - - @Test - fun `should parse spec sample 327 correctly (Inlines)`() { - val parsed = processor.processMarkdownDocument("`hi`lo`") - - /* - * Expected HTML: - *

hilo`

- */ - parsed.assertEquals(paragraph("`hi`lo\\`")) - } - - @Test - fun `should parse spec sample 328 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("`foo`") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("`foo`")) - } - - @Test - fun `should parse spec sample 329 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("`` foo ` bar ``") - - /* - * Expected HTML: - *

foo ` bar

- */ - parsed.assertEquals(paragraph("``foo ` bar``")) - } - - @Test - fun `should parse spec sample 330 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("` `` `") - - /* - * Expected HTML: - *

``

- */ - parsed.assertEquals(paragraph("``")) - } - - @Test - fun `should parse spec sample 331 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("` `` `") - - /* - * Expected HTML: - *

``

- */ - parsed.assertEquals(paragraph(" `` ")) - } - - @Test - fun `should parse spec sample 332 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("` a`") - - /* - * Expected HTML: - *

a

- */ - parsed.assertEquals(paragraph("` a`")) - } - - @Test - fun `should parse spec sample 333 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("` b `") - - /* - * Expected HTML: - *

 b 

- */ - parsed.assertEquals(paragraph("` b `")) - } - - @Test - fun `should parse spec sample 334 correctly (Code spans)`() { - val parsed = - processor.processMarkdownDocument( - """ - |` ` - |` ` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

  - *

- */ - parsed.assertEquals(paragraph("` ` ` `")) - } - - @Test - fun `should parse spec sample 335 correctly (Code spans)`() { - val parsed = - processor.processMarkdownDocument( - """ - |`` - |foo - |bar - |baz - |`` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo bar baz

- */ - parsed.assertEquals(paragraph("`foo bar baz`")) - } - - @Test - fun `should parse spec sample 336 correctly (Code spans)`() { - val parsed = - processor.processMarkdownDocument( - """ - |`` - |foo - |`` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("`foo `")) - } - - @Test - fun `should parse spec sample 337 correctly (Code spans)`() { - val parsed = - processor.processMarkdownDocument( - """ - |`foo bar - |baz` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo bar baz

- */ - parsed.assertEquals(paragraph("`foo bar baz`")) - } - - @Test - fun `should parse spec sample 338 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("`foo\\`bar`") - - /* - * Expected HTML: - *

foo\bar`

- */ - parsed.assertEquals(paragraph("`foo\\`bar\\`")) - } - - @Test - fun `should parse spec sample 339 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("``foo`bar``") - - /* - * Expected HTML: - *

foo`bar

- */ - parsed.assertEquals(paragraph("``foo`bar``")) - } - - @Test - fun `should parse spec sample 340 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("` foo `` bar `") - - /* - * Expected HTML: - *

foo `` bar

- */ - parsed.assertEquals(paragraph("```foo `` bar```")) - } - - @Test - fun `should parse spec sample 341 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("*foo`*`") - - /* - * Expected HTML: - *

*foo*

- */ - parsed.assertEquals(paragraph("\\*foo`*`")) - } - - @Test - fun `should parse spec sample 342 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("[not a `link](/foo`)") - - /* - * Expected HTML: - *

[not a link](/foo)

- */ - parsed.assertEquals(paragraph("\\[not a `link](/foo`\\)")) - } - - @Test - fun `should parse spec sample 343 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("``") - - /* - * Expected HTML: - *

<a href="">`

- */ - parsed.assertEquals(paragraph("`
\\`")) - } - - @Test - fun `should parse spec sample 344 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("`") - - /* - * Expected HTML: - *

`

- */ - parsed.assertEquals(paragraph("\\`")) - } - - @Test - fun `should parse spec sample 345 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("``") - - /* - * Expected HTML: - *

<https://foo.bar.baz>`

- */ - parsed.assertEquals(paragraph("`\\`")) - } - - @Test - fun `should parse spec sample 346 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("`") - - /* - * Expected HTML: - *

https://foo.bar.`baz`

- */ - parsed.assertEquals(paragraph("[https://foo.bar.\\`baz](https://foo.bar.`baz)\\`")) - } - - @Test - fun `should parse spec sample 347 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("```foo``") - - /* - * Expected HTML: - *

```foo``

- */ - parsed.assertEquals(paragraph("\\`\\`\\`foo\\`\\`")) - } - - @Test - fun `should parse spec sample 348 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("`foo") - - /* - * Expected HTML: - *

`foo

- */ - parsed.assertEquals(paragraph("\\`foo")) - } - - @Test - fun `should parse spec sample 349 correctly (Code spans)`() { - val parsed = processor.processMarkdownDocument("`foo``bar``") - - /* - * Expected HTML: - *

`foobar

- */ - parsed.assertEquals(paragraph("\\`foo`bar`")) - } - - @Test - fun `should parse spec sample 350 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo bar*") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("*foo bar*")) - } - - @Test - fun `should parse spec sample 351 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("a * foo bar*") - - /* - * Expected HTML: - *

a * foo bar*

- */ - parsed.assertEquals(paragraph("a \\* foo bar\\*")) - } - - @Test - fun `should parse spec sample 352 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("a*\"foo\"*") - - /* - * Expected HTML: - *

a*"foo"*

- */ - parsed.assertEquals(paragraph("a\\*\"foo\"\\*")) - } - - @Test - fun `should parse spec sample 353 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("* a *") - - /* - * Expected HTML: - *

* a *

- */ - parsed.assertEquals(paragraph("\\* a \\*")) - } - - @Ignore("need to update escapeInlineMarkdownChars implementation") - @Test - fun `should parse spec sample 354 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument( - """ - |*$*alpha. - | - |*£*bravo. - | - |*€*charlie. - """.trimMargin(), - ) - - /* - * Expected HTML: - *

*$*alpha.

- *

*£*bravo.

- *

*€*charlie.

- */ - parsed.assertEquals(paragraph("*$*alpha."), paragraph("*£*bravo."), paragraph("*€*charlie.")) - } - - @Test - fun `should parse spec sample 355 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo*bar*") - - /* - * Expected HTML: - *

foobar

- */ - parsed.assertEquals(paragraph("foo*bar*")) - } - - @Test - fun `should parse spec sample 356 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("5*6*78") - - /* - * Expected HTML: - *

5678

- */ - parsed.assertEquals(paragraph("5*6*78")) - } - - @Test - fun `should parse spec sample 357 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_foo bar_") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("_foo bar_")) - } - - @Test - fun `should parse spec sample 358 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_ foo bar_") - - /* - * Expected HTML: - *

_ foo bar_

- */ - parsed.assertEquals(paragraph("\\_ foo bar\\_")) - } - - @Test - fun `should parse spec sample 359 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("a_\"foo\"_") - - /* - * Expected HTML: - *

a_"foo"_

- */ - parsed.assertEquals(paragraph("a\\_\"foo\"\\_")) - } - - @Test - fun `should parse spec sample 360 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo_bar_") - - /* - * Expected HTML: - *

foo_bar_

- */ - parsed.assertEquals(paragraph("foo\\_bar\\_")) - } - - @Test - fun `should parse spec sample 361 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("5_6_78") - - /* - * Expected HTML: - *

5_6_78

- */ - parsed.assertEquals(paragraph("5\\_6\\_78")) - } - - @Test - fun `should parse spec sample 362 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("пристаням_стремятся_") - - /* - * Expected HTML: - *

пристаням_стремятся_

- */ - parsed.assertEquals(paragraph("пристаням\\_стремятся\\_")) - } - - @Test - fun `should parse spec sample 363 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("aa_\"bb\"_cc") - - /* - * Expected HTML: - *

aa_"bb"_cc

- */ - parsed.assertEquals(paragraph("aa\\_\"bb\"\\_cc")) - } - - @Test - fun `should parse spec sample 364 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo-_(bar)_") - - /* - * Expected HTML: - *

foo-(bar)

- */ - parsed.assertEquals(paragraph("foo-_\\(bar\\)_")) - } - - @Test - fun `should parse spec sample 365 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_foo*") - - /* - * Expected HTML: - *

_foo*

- */ - parsed.assertEquals(paragraph("\\_foo\\*")) - } - - @Test - fun `should parse spec sample 366 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo bar *") - - /* - * Expected HTML: - *

*foo bar *

- */ - parsed.assertEquals(paragraph("\\*foo bar \\*")) - } - - @Test - fun `should parse spec sample 367 correctly (Emphasis and strong emphasis)`() { - val parsed = - processor.processMarkdownDocument( - """ - |*foo bar - |* - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

*foo bar - * *

- */ - parsed.assertEquals(paragraph("\\*foo bar \\*")) - } - - @Test - fun `should parse spec sample 368 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*(*foo)") - - /* - * Expected HTML: - *

*(*foo)

- */ - parsed.assertEquals(paragraph("\\*\\(\\*foo\\)")) - } - - @Test - fun `should parse spec sample 369 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*(*foo*)*") - - /* - * Expected HTML: - *

(foo)

- */ - parsed.assertEquals(paragraph("*\\(*foo*\\)*")) - } - - @Test - fun `should parse spec sample 370 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo*bar") - - /* - * Expected HTML: - *

foobar

- */ - parsed.assertEquals(paragraph("*foo*bar")) - } - - @Test - fun `should parse spec sample 371 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_foo bar _") - - /* - * Expected HTML: - *

_foo bar _

- */ - parsed.assertEquals(paragraph("\\_foo bar \\_")) - } - - @Test - fun `should parse spec sample 372 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_(_foo)") - - /* - * Expected HTML: - *

_(_foo)

- */ - parsed.assertEquals(paragraph("\\_\\(\\_foo\\)")) - } - - @Test - fun `should parse spec sample 373 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_(_foo_)_") - - /* - * Expected HTML: - *

(foo)

- */ - parsed.assertEquals(paragraph("_\\(_foo_\\)_")) - } - - @Test - fun `should parse spec sample 374 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_foo_bar") - - /* - * Expected HTML: - *

_foo_bar

- */ - parsed.assertEquals(paragraph("\\_foo\\_bar")) - } - - @Test - fun `should parse spec sample 375 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_пристаням_стремятся") - - /* - * Expected HTML: - *

_пристаням_стремятся

- */ - parsed.assertEquals(paragraph("\\_пристаням\\_стремятся")) - } - - @Test - fun `should parse spec sample 376 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_foo_bar_baz_") - - /* - * Expected HTML: - *

foo_bar_baz

- */ - parsed.assertEquals(paragraph("_foo\\_bar\\_baz_")) - } - - @Test - fun `should parse spec sample 377 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_(bar)_.") - - /* - * Expected HTML: - *

(bar).

- */ - parsed.assertEquals(paragraph("_\\(bar\\)_.")) - } - - @Test - fun `should parse spec sample 378 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo bar**") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("**foo bar**")) - } - - @Test - fun `should parse spec sample 379 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("** foo bar**") - - /* - * Expected HTML: - *

** foo bar**

- */ - parsed.assertEquals(paragraph("\\*\\* foo bar\\*\\*")) - } - - @Test - fun `should parse spec sample 380 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("a**\"foo\"**") - - /* - * Expected HTML: - *

a**"foo"**

- */ - parsed.assertEquals(paragraph("a\\*\\*\"foo\"\\*\\*")) - } - - @Test - fun `should parse spec sample 381 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo**bar**") - - /* - * Expected HTML: - *

foobar

- */ - parsed.assertEquals(paragraph("foo**bar**")) - } - - @Test - fun `should parse spec sample 382 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__foo bar__") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("__foo bar__")) - } - - @Test - fun `should parse spec sample 383 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__ foo bar__") - - /* - * Expected HTML: - *

__ foo bar__

- */ - parsed.assertEquals(paragraph("\\_\\_ foo bar\\_\\_")) - } - - @Test - fun `should parse spec sample 384 correctly (Emphasis and strong emphasis)`() { - val parsed = - processor.processMarkdownDocument( - """ - |__ - |foo bar__ - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

__ - * foo bar__

- */ - parsed.assertEquals(paragraph("\\_\\_ foo bar\\_\\_")) - } - - @Test - fun `should parse spec sample 385 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("a__\"foo\"__") - - /* - * Expected HTML: - *

a__"foo"__

- */ - parsed.assertEquals(paragraph("a\\_\\_\"foo\"\\_\\_")) - } - - @Test - fun `should parse spec sample 386 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo__bar__") - - /* - * Expected HTML: - *

foo__bar__

- */ - parsed.assertEquals(paragraph("foo\\_\\_bar\\_\\_")) - } - - @Test - fun `should parse spec sample 387 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("5__6__78") - - /* - * Expected HTML: - *

5__6__78

- */ - parsed.assertEquals(paragraph("5\\_\\_6\\_\\_78")) - } - - @Test - fun `should parse spec sample 388 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("пристаням__стремятся__") - - /* - * Expected HTML: - *

пристаням__стремятся__

- */ - parsed.assertEquals(paragraph("пристаням\\_\\_стремятся\\_\\_")) - } - - @Test - fun `should parse spec sample 389 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__foo, __bar__, baz__") - - /* - * Expected HTML: - *

foo, bar, baz

- */ - parsed.assertEquals(paragraph("__foo, __bar__, baz__")) - } - - @Test - fun `should parse spec sample 390 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo-__(bar)__") - - /* - * Expected HTML: - *

foo-(bar)

- */ - parsed.assertEquals(paragraph("foo-__\\(bar\\)__")) - } - - @Test - fun `should parse spec sample 391 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo bar **") - - /* - * Expected HTML: - *

**foo bar **

- */ - parsed.assertEquals(paragraph("\\*\\*foo bar \\*\\*")) - } - - @Test - fun `should parse spec sample 392 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**(**foo)") - - /* - * Expected HTML: - *

**(**foo)

- */ - parsed.assertEquals(paragraph("\\*\\*\\(\\*\\*foo\\)")) - } - - @Test - fun `should parse spec sample 393 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*(**foo**)*") - - /* - * Expected HTML: - *

(foo)

- */ - parsed.assertEquals(paragraph("*\\(**foo**\\)*")) - } - - @Test - fun `should parse spec sample 394 correctly (Emphasis and strong emphasis)`() { - val parsed = - processor.processMarkdownDocument( - """ - |**Gomphocarpus (*Gomphocarpus physocarpus*, syn. - |*Asclepias physocarpa*)** - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Gomphocarpus (Gomphocarpus physocarpus, syn. - * Asclepias physocarpa)

- */ - parsed.assertEquals( - paragraph( - "**Gomphocarpus \\(*Gomphocarpus physocarpus*, syn. *Asclepias physocarpa*\\)**", - ), - ) - } - - @Test - fun `should parse spec sample 395 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo \"*bar*\" foo**") - - /* - * Expected HTML: - *

foo "bar" foo

- */ - parsed.assertEquals(paragraph("**foo \"*bar*\" foo**")) - } - - @Test - fun `should parse spec sample 396 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo**bar") - - /* - * Expected HTML: - *

foobar

- */ - parsed.assertEquals(paragraph("**foo**bar")) - } - - @Test - fun `should parse spec sample 397 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__foo bar __") - - /* - * Expected HTML: - *

__foo bar __

- */ - parsed.assertEquals(paragraph("\\_\\_foo bar \\_\\_")) - } - - @Test - fun `should parse spec sample 398 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__(__foo)") - - /* - * Expected HTML: - *

__(__foo)

- */ - parsed.assertEquals(paragraph("\\_\\_\\(\\_\\_foo\\)")) - } - - @Test - fun `should parse spec sample 399 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_(__foo__)_") - - /* - * Expected HTML: - *

(foo)

- */ - parsed.assertEquals(paragraph("_\\(__foo__\\)_")) - } - - @Test - fun `should parse spec sample 400 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__foo__bar") - - /* - * Expected HTML: - *

__foo__bar

- */ - parsed.assertEquals(paragraph("\\_\\_foo\\_\\_bar")) - } - - @Test - fun `should parse spec sample 401 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__пристаням__стремятся") - - /* - * Expected HTML: - *

__пристаням__стремятся

- */ - parsed.assertEquals(paragraph("\\_\\_пристаням\\_\\_стремятся")) - } - - @Test - fun `should parse spec sample 402 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__foo__bar__baz__") - - /* - * Expected HTML: - *

foo__bar__baz

- */ - parsed.assertEquals(paragraph("__foo\\_\\_bar\\_\\_baz__")) - } - - @Test - fun `should parse spec sample 403 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__(bar)__.") - - /* - * Expected HTML: - *

(bar).

- */ - parsed.assertEquals(paragraph("__\\(bar\\)__.")) - } - - @Test - fun `should parse spec sample 404 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo [bar](/url)*") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("*foo [bar](/url)*")) - } - - @Test - fun `should parse spec sample 405 correctly (Emphasis and strong emphasis)`() { - val parsed = - processor.processMarkdownDocument( - """ - |*foo - |bar* - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo - * bar

- */ - parsed.assertEquals(paragraph("*foo bar*")) - } - - @Test - fun `should parse spec sample 406 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_foo __bar__ baz_") - - /* - * Expected HTML: - *

foo bar baz

- */ - parsed.assertEquals(paragraph("_foo __bar__ baz_")) - } - - @Test - fun `should parse spec sample 407 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_foo _bar_ baz_") - - /* - * Expected HTML: - *

foo bar baz

- */ - parsed.assertEquals(paragraph("_foo _bar_ baz_")) - } - - @Test - fun `should parse spec sample 408 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__foo_ bar_") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("__foo_ bar_")) - } - - @Test - fun `should parse spec sample 409 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo *bar**") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("*foo *bar**")) - } - - @Test - fun `should parse spec sample 410 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo **bar** baz*") - - /* - * Expected HTML: - *

foo bar baz

- */ - parsed.assertEquals(paragraph("*foo **bar** baz*")) - } - - @Test - fun `should parse spec sample 411 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo**bar**baz*") - - /* - * Expected HTML: - *

foobarbaz

- */ - parsed.assertEquals(paragraph("*foo**bar**baz*")) - } - - @Test - fun `should parse spec sample 412 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo**bar*") - - /* - * Expected HTML: - *

foo**bar

- */ - parsed.assertEquals(paragraph("*foo\\*\\*bar*")) - } - - @Test - fun `should parse spec sample 413 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("***foo** bar*") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("***foo** bar*")) - } - - @Test - fun `should parse spec sample 414 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo **bar***") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("*foo **bar***")) - } - - @Test - fun `should parse spec sample 415 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo**bar***") - - /* - * Expected HTML: - *

foobar

- */ - parsed.assertEquals(paragraph("*foo**bar***")) - } - - @Test - fun `should parse spec sample 416 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo***bar***baz") - - /* - * Expected HTML: - *

foobarbaz

- */ - parsed.assertEquals(paragraph("foo***bar***baz")) - } - - @Test - fun `should parse spec sample 417 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo******bar*********baz") - - /* - * Expected HTML: - *

foobar***baz

- */ - parsed.assertEquals(paragraph("foo******bar******\\*\\*\\*baz")) - } - - @Test - fun `should parse spec sample 418 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo **bar *baz* bim** bop*") - - /* - * Expected HTML: - *

foo bar baz bim bop

- */ - parsed.assertEquals(paragraph("*foo **bar *baz* bim** bop*")) - } - - @Test - fun `should parse spec sample 419 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo [*bar*](/url)*") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("*foo [*bar*](/url)*")) - } - - @Test - fun `should parse spec sample 420 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("** is not an empty emphasis") - - /* - * Expected HTML: - *

** is not an empty emphasis

- */ - parsed.assertEquals(paragraph("\\*\\* is not an empty emphasis")) - } - - @Test - fun `should parse spec sample 421 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**** is not an empty strong emphasis") - - /* - * Expected HTML: - *

**** is not an empty strong emphasis

- */ - parsed.assertEquals(paragraph("\\*\\*\\*\\* is not an empty strong emphasis")) - } - - @Test - fun `should parse spec sample 422 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo [bar](/url)**") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("**foo [bar](/url)**")) - } - - @Test - fun `should parse spec sample 423 correctly (Emphasis and strong emphasis)`() { - val parsed = - processor.processMarkdownDocument( - """ - |**foo - |bar** - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo - * bar

- */ - parsed.assertEquals(paragraph("**foo bar**")) - } - - @Test - fun `should parse spec sample 424 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__foo _bar_ baz__") - - /* - * Expected HTML: - *

foo bar baz

- */ - parsed.assertEquals(paragraph("__foo _bar_ baz__")) - } - - @Test - fun `should parse spec sample 425 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__foo __bar__ baz__") - - /* - * Expected HTML: - *

foo bar baz

- */ - parsed.assertEquals(paragraph("__foo __bar__ baz__")) - } - - @Test - fun `should parse spec sample 426 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("____foo__ bar__") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("____foo__ bar__")) - } - - @Test - fun `should parse spec sample 427 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo **bar****") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("**foo **bar****")) - } - - @Test - fun `should parse spec sample 428 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo *bar* baz**") - - /* - * Expected HTML: - *

foo bar baz

- */ - parsed.assertEquals(paragraph("**foo *bar* baz**")) - } - - @Test - fun `should parse spec sample 429 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo*bar*baz**") - - /* - * Expected HTML: - *

foobarbaz

- */ - parsed.assertEquals(paragraph("**foo*bar*baz**")) - } - - @Test - fun `should parse spec sample 430 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("***foo* bar**") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("***foo* bar**")) - } - - @Test - fun `should parse spec sample 431 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo *bar***") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("**foo *bar***")) - } - - @Test - fun `should parse spec sample 432 correctly (Emphasis and strong emphasis)`() { - val parsed = - processor.processMarkdownDocument( - """ - |**foo *bar **baz** - |bim* bop** - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo bar baz - * bim bop

- */ - parsed.assertEquals(paragraph("**foo *bar **baz** bim* bop**")) - } - - @Test - fun `should parse spec sample 433 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo [*bar*](/url)**") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("**foo [*bar*](/url)**")) - } - - @Test - fun `should parse spec sample 434 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__ is not an empty emphasis") - - /* - * Expected HTML: - *

__ is not an empty emphasis

- */ - parsed.assertEquals(paragraph("\\_\\_ is not an empty emphasis")) - } - - @Test - fun `should parse spec sample 435 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("____ is not an empty strong emphasis") - - /* - * Expected HTML: - *

____ is not an empty strong emphasis

- */ - parsed.assertEquals(paragraph("\\_\\_\\_\\_ is not an empty strong emphasis")) - } - - @Test - fun `should parse spec sample 436 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo ***") - - /* - * Expected HTML: - *

foo ***

- */ - parsed.assertEquals(paragraph("foo \\*\\*\\*")) - } - - @Test - fun `should parse spec sample 437 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo *\\**") - - /* - * Expected HTML: - *

foo *

- */ - parsed.assertEquals(paragraph("foo *\\**")) - } - - @Test - fun `should parse spec sample 438 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo *_*") - - /* - * Expected HTML: - *

foo _

- */ - parsed.assertEquals(paragraph("foo *\\_*")) - } - - @Test - fun `should parse spec sample 439 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo *****") - - /* - * Expected HTML: - *

foo *****

- */ - parsed.assertEquals(paragraph("foo \\*\\*\\*\\*\\*")) - } - - @Test - fun `should parse spec sample 440 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo **\\***") - - /* - * Expected HTML: - *

foo *

- */ - parsed.assertEquals(paragraph("foo **\\***")) - } - - @Test - fun `should parse spec sample 441 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo **_**") - - /* - * Expected HTML: - *

foo _

- */ - parsed.assertEquals(paragraph("foo **\\_**")) - } - - @Test - fun `should parse spec sample 442 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo*") - - /* - * Expected HTML: - *

*foo

- */ - parsed.assertEquals(paragraph("\\**foo*")) - } - - @Test - fun `should parse spec sample 443 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo**") - - /* - * Expected HTML: - *

foo*

- */ - parsed.assertEquals(paragraph("*foo*\\*")) - } - - @Test - fun `should parse spec sample 444 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("***foo**") - - /* - * Expected HTML: - *

*foo

- */ - parsed.assertEquals(paragraph("\\***foo**")) - } - - @Test - fun `should parse spec sample 445 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("****foo*") - - /* - * Expected HTML: - *

***foo

- */ - parsed.assertEquals(paragraph("\\*\\*\\**foo*")) - } - - @Test - fun `should parse spec sample 446 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo***") - - /* - * Expected HTML: - *

foo*

- */ - parsed.assertEquals(paragraph("**foo**\\*")) - } - - @Test - fun `should parse spec sample 447 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo****") - - /* - * Expected HTML: - *

foo***

- */ - parsed.assertEquals(paragraph("*foo*\\*\\*\\*")) - } - - @Test - fun `should parse spec sample 448 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo ___") - - /* - * Expected HTML: - *

foo ___

- */ - parsed.assertEquals(paragraph("foo \\_\\_\\_")) - } - - @Test - fun `should parse spec sample 449 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo _\\__") - - /* - * Expected HTML: - *

foo _

- */ - parsed.assertEquals(paragraph("foo _\\__")) - } - - @Test - fun `should parse spec sample 450 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo _*_") - - /* - * Expected HTML: - *

foo *

- */ - parsed.assertEquals(paragraph("foo _\\*_")) - } - - @Test - fun `should parse spec sample 451 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo _____") - - /* - * Expected HTML: - *

foo _____

- */ - parsed.assertEquals(paragraph("foo \\_\\_\\_\\_\\_")) - } - - @Test - fun `should parse spec sample 452 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo __\\___") - - /* - * Expected HTML: - *

foo _

- */ - parsed.assertEquals(paragraph("foo __\\___")) - } - - @Test - fun `should parse spec sample 453 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("foo __*__") - - /* - * Expected HTML: - *

foo *

- */ - parsed.assertEquals(paragraph("foo __\\*__")) - } - - @Test - fun `should parse spec sample 454 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__foo_") - - /* - * Expected HTML: - *

_foo

- */ - parsed.assertEquals(paragraph("\\__foo_")) - } - - @Test - fun `should parse spec sample 455 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_foo__") - - /* - * Expected HTML: - *

foo_

- */ - parsed.assertEquals(paragraph("_foo_\\_")) - } - - @Test - fun `should parse spec sample 456 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("___foo__") - - /* - * Expected HTML: - *

_foo

- */ - parsed.assertEquals(paragraph("\\___foo__")) - } - - @Test - fun `should parse spec sample 457 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("____foo_") - - /* - * Expected HTML: - *

___foo

- */ - parsed.assertEquals(paragraph("\\_\\_\\__foo_")) - } - - @Test - fun `should parse spec sample 458 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__foo___") - - /* - * Expected HTML: - *

foo_

- */ - parsed.assertEquals(paragraph("__foo__\\_")) - } - - @Test - fun `should parse spec sample 459 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_foo____") - - /* - * Expected HTML: - *

foo___

- */ - parsed.assertEquals(paragraph("_foo_\\_\\_\\_")) - } - - @Test - fun `should parse spec sample 460 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo**") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("**foo**")) - } - - @Test - fun `should parse spec sample 461 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*_foo_*") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("*_foo_*")) - } - - @Test - fun `should parse spec sample 462 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__foo__") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("__foo__")) - } - - @Test - fun `should parse spec sample 463 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_*foo*_") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("_*foo*_")) - } - - @Test - fun `should parse spec sample 462+1b correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_*foo _bar_*_") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("_*foo _bar_*_")) - } - - @Test - fun `should parse spec sample 462+1c correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__foo _bar___") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("__foo _bar___")) - } - - @Test - fun `should parse spec sample 462+1d correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_*foo _bar_ a*_") - - /* - * Expected HTML: - *

foo bar a

- */ - parsed.assertEquals(paragraph("_*foo _bar_ a*_")) - } - - @Test - fun `should parse spec sample 462+1e correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__foo _bar_ a__") - - /* - * Expected HTML: - *

foo bar a

- */ - parsed.assertEquals(paragraph("__foo _bar_ a__")) - } - - @Test - fun `should parse spec sample 462+1f correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_*foo *bar* a*_") - - /* - * Expected HTML: - *

foo bar a

- */ - parsed.assertEquals(paragraph("_*foo *bar* a*_")) - } - - @Test - fun `should parse spec sample 464 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("****foo****") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("****foo****")) - } - - @Test - fun `should parse spec sample 465 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("____foo____") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("____foo____")) - } - - @Test - fun `should parse spec sample 466 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("******foo******") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("******foo******")) - } - - @Test - fun `should parse spec sample 467 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("***foo***") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("***foo***")) - } - - @Test - fun `should parse spec sample 468 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_____foo_____") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("_____foo_____")) - } - - @Test - fun `should parse spec sample 469 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo _bar* baz_") - - /* - * Expected HTML: - *

foo _bar baz_

- */ - parsed.assertEquals(paragraph("*foo \\_bar* baz\\_")) - } - - @Test - fun `should parse spec sample 470 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo __bar *baz bim__ bam*") - - /* - * Expected HTML: - *

foo bar *baz bim bam

- */ - parsed.assertEquals(paragraph("*foo __bar \\*baz bim__ bam*")) - } - - @Test - fun `should parse spec sample 471 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**foo **bar baz**") - - /* - * Expected HTML: - *

**foo bar baz

- */ - parsed.assertEquals(paragraph("\\*\\*foo **bar baz**")) - } - - @Test - fun `should parse spec sample 472 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*foo *bar baz*") - - /* - * Expected HTML: - *

*foo bar baz

- */ - parsed.assertEquals(paragraph("\\*foo *bar baz*")) - } - - @Test - fun `should parse spec sample 473 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*[bar*](/url)") - - /* - * Expected HTML: - *

*bar*

- */ - parsed.assertEquals(paragraph("\\*[bar\\*](/url)")) - } - - @Test - fun `should parse spec sample 474 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_foo [bar_](/url)") - - /* - * Expected HTML: - *

_foo bar_

- */ - parsed.assertEquals(paragraph("\\_foo [bar\\_](/url)")) - } - - @Test - fun `should parse spec sample 475 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*") - - /* - * Expected HTML: - *

*

- */ - parsed.assertEquals(paragraph("\\*")) - } - - @Test - fun `should parse spec sample 476 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**") - - /* - * Expected HTML: - *

**

- */ - parsed.assertEquals(paragraph("\\*\\*")) - } - - @Test - fun `should parse spec sample 477 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__") - - /* - * Expected HTML: - *

__

- */ - parsed.assertEquals(paragraph("\\_\\_")) - } - - @Test - fun `should parse spec sample 478 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("*a `*`*") - - /* - * Expected HTML: - *

a *

- */ - parsed.assertEquals(paragraph("*a `*`*")) - } - - @Test - fun `should parse spec sample 479 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("_a `_`_") - - /* - * Expected HTML: - *

a _

- */ - parsed.assertEquals(paragraph("_a `_`_")) - } - - @Test - fun `should parse spec sample 480 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("**a") - - /* - * Expected HTML: - *

**ahttps://foo.bar/?q=**

- */ - parsed.assertEquals(paragraph("\\*\\*a[https://foo.bar/?q=\\*\\*](https://foo.bar/?q=**)")) - } - - @Test - fun `should parse spec sample 481 correctly (Emphasis and strong emphasis)`() { - val parsed = processor.processMarkdownDocument("__a") - - /* - * Expected HTML: - *

__ahttps://foo.bar/?q=__

- */ - parsed.assertEquals(paragraph("\\_\\_a[https://foo.bar/?q=\\_\\_](https://foo.bar/?q=__)")) - } - - @Test - fun `should parse spec sample 482 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](/uri \"title\")") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link](/uri \"title\")")) - } - - @Test - fun `should parse spec sample 483 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](/uri)") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link](/uri)")) - } - - @Test - fun `should parse spec sample 484 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[](./target.md)") - - /* - * Expected HTML: - *

- */ - parsed.assertEquals(paragraph("[](./target.md)")) - } - - @Test - fun `should parse spec sample 485 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link]()") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link]()")) - } - - @Test - fun `should parse spec sample 486 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](<>)") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link]()")) - } - - @Ignore - @Test - fun `should parse spec sample 487 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[]()") - - /* - * Expected HTML: - *

- */ - parsed.assertEquals() - } - - @Test - fun `should parse spec sample 488 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](/my uri)") - - /* - * Expected HTML: - *

[link](/my uri)

- */ - parsed.assertEquals(paragraph("\\[link\\]\\(/my uri\\)")) - } - - @Test - fun `should parse spec sample 489 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](
)") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link](
)")) - } - - @Test - fun `should parse spec sample 490 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[link](foo - |bar) - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[link](foo - * bar)

- */ - parsed.assertEquals(paragraph("\\[link\\]\\(foo bar\\)")) - } - - @Test - fun `should parse spec sample 491 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[link]() - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[link]()

- */ - parsed.assertEquals(paragraph("\\[link\\]\\(\\)")) - } - - @Test - fun `should parse spec sample 492 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[a]()") - - /* - * Expected HTML: - *

a

- */ - parsed.assertEquals(paragraph("[a](b\\)c)")) - } - - @Test - fun `should parse spec sample 493 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link]()") - - /* - * Expected HTML: - *

[link](<foo>)

- */ - parsed.assertEquals(paragraph("\\[link\\]\\(\\\\)")) - } - - @Test - fun `should parse spec sample 494 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[a]( - |[a](c) - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[a](<b)c - * [a](<b)c> - * [a](c)

- */ - parsed.assertEquals( - paragraph( - "\\[a\\]\\(\\ \\[a\\]\\(c\\)", - ), - ) - } - - @Test - fun `should parse spec sample 495 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](\\(foo\\))") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link](\\(foo\\))")) - } - - @Test - fun `should parse spec sample 496 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](foo(and(bar)))") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link](foo\\(and\\(bar\\)\\))")) - } - - @Test - fun `should parse spec sample 497 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](foo(and(bar))") - - /* - * Expected HTML: - *

[link](foo(and(bar))

- */ - parsed.assertEquals(paragraph("\\[link\\]\\(foo\\(and\\(bar\\)\\)")) - } - - @Test - fun `should parse spec sample 498 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](foo\\(and\\(bar\\))") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link](foo\\(and\\(bar\\))")) - } - - @Test - fun `should parse spec sample 499 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link]()") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link](foo\\(and\\(bar\\))")) - } - - @Test - fun `should parse spec sample 500 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](foo\\)\\:)") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link](foo\\):)")) - } - - @Test - fun `should parse spec sample 501 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[link](#fragment) - | - |[link](https://example.com#fragment) - | - |[link](https://example.com?foo=3#frag) - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

link

- *

link

- *

link

- */ - parsed.assertEquals( - paragraph("[link](#fragment)"), - paragraph("[link](https://example.com#fragment)"), - paragraph("[link](https://example.com?foo=3#frag)"), - ) - } - - @Test - fun `should parse spec sample 502 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](foo\\bar)") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link](foo\\bar)")) - } - - @Test - fun `should parse spec sample 503 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](foo%20bä)") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link](foo%20bä)")) - } - - @Test - fun `should parse spec sample 504 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](\"title\")") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link](\"title\")")) - } - - @Test - fun `should parse spec sample 505 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[link](/url "title") - |[link](/url 'title') - |[link](/url (title)) - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

link - * link - * link

- */ - parsed.assertEquals( - paragraph("[link](/url \"title\") [link](/url \"title\") [link](/url \"title\")"), - ) - } - - @Test - fun `should parse spec sample 506 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](/url \"title \\\""\")") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link](/url \"title \\\"\\\"\")")) - } - - @Test - fun `should parse spec sample 507 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](/url \"title\")") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link]()")) - } - - @Test - fun `should parse spec sample 508 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](/url \"title \"and\" title\")") - - /* - * Expected HTML: - *

[link](/url "title "and" title")

- */ - parsed.assertEquals(paragraph("\\[link\\]\\(/url \"title \"and\" title\"\\)")) - } - - @Test - fun `should parse spec sample 509 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link](/url 'title \"and\" title')") - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link](/url \"title \\\"and\\\" title\")")) - } - - @Test - fun `should parse spec sample 510 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[link]( /uri - | "title" ) - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

link

- */ - parsed.assertEquals(paragraph("[link](/uri \"title\")")) - } - - @Test - fun `should parse spec sample 511 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link] (/uri)") - - /* - * Expected HTML: - *

[link] (/uri)

- */ - parsed.assertEquals(paragraph("\\[link\\] \\(/uri\\)")) - } - - @Test - fun `should parse spec sample 512 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link [foo [bar]]](/uri)") - - /* - * Expected HTML: - *

link [foo [bar]]

- */ - parsed.assertEquals(paragraph("[link \\[foo \\[bar\\]\\]](/uri)")) - } - - @Test - fun `should parse spec sample 513 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link] bar](/uri)") - - /* - * Expected HTML: - *

[link] bar](/uri)

- */ - parsed.assertEquals(paragraph("\\[link\\] bar\\]\\(/uri\\)")) - } - - @Test - fun `should parse spec sample 514 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link [bar](/uri)") - - /* - * Expected HTML: - *

[link bar

- */ - parsed.assertEquals(paragraph("\\[link [bar](/uri)")) - } - - @Test - fun `should parse spec sample 515 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link \\[bar](/uri)") - - /* - * Expected HTML: - *

link [bar

- */ - parsed.assertEquals(paragraph("[link \\[bar](/uri)")) - } - - @Test - fun `should parse spec sample 516 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[link *foo **bar** `#`*](/uri)") - - /* - * Expected HTML: - *

link foo bar #

- */ - parsed.assertEquals(paragraph("[link *foo **bar** `#`*](/uri)")) - } - - @Test - fun `should parse spec sample 517 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[![moon](moon.jpg)](/uri)") - - /* - * Expected HTML: - *

moon

- */ - parsed.assertEquals(paragraph("[![moon](moon.jpg)](/uri)")) - } - - @Test - fun `should parse spec sample 518 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[foo [bar](/uri)](/uri)") - - /* - * Expected HTML: - *

[foo bar](/uri)

- */ - parsed.assertEquals(paragraph("\\[foo [bar](/uri)\\]\\(/uri\\)")) - } - - @Test - fun `should parse spec sample 519 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[foo *[bar [baz](/uri)](/uri)*](/uri)") - - /* - * Expected HTML: - *

[foo [bar baz](/uri)](/uri)

- */ - parsed.assertEquals(paragraph("\\[foo *\\[bar [baz](/uri)\\]\\(/uri\\)*\\]\\(/uri\\)")) - } - - @Ignore - @Test - fun `should parse spec sample 520 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("![[[foo](uri1)](uri2)](uri3)") - - /* - * Expected HTML: - *

[foo](uri2)

- */ - parsed.assertEquals(paragraph("![\\[\"foo\" (uri1)\\]\\(uri2\\)](uri3)")) - } - - @Test - fun `should parse spec sample 521 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("*[foo*](/uri)") - - /* - * Expected HTML: - *

*foo*

- */ - parsed.assertEquals(paragraph("\\*[foo\\*](/uri)")) - } - - @Test - fun `should parse spec sample 522 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[foo *bar](baz*)") - - /* - * Expected HTML: - *

foo *bar

- */ - parsed.assertEquals(paragraph("[foo \\*bar](baz*)")) - } - - @Test - fun `should parse spec sample 523 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("*foo [bar* baz]") - - /* - * Expected HTML: - *

foo [bar baz]

- */ - parsed.assertEquals(paragraph("*foo \\[bar* baz\\]")) - } - - @Test - fun `should parse spec sample 524 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[foo ") - - /* - * Expected HTML: - *

[foo

- */ - parsed.assertEquals(paragraph("\\[foo ")) - } - - @Test - fun `should parse spec sample 525 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[foo`](/uri)`") - - /* - * Expected HTML: - *

[foo](/uri)

- */ - parsed.assertEquals(paragraph("\\[foo`](/uri)`")) - } - - @Test - fun `should parse spec sample 526 correctly (Links)`() { - val parsed = processor.processMarkdownDocument("[foo") - - /* - * Expected HTML: - *

[foohttps://example.com/?search=](uri)

- */ - parsed.assertEquals( - paragraph( - "\\[foo[https://example.com/?search=\\]\\(uri\\)](https://example.com/?search=]\\(uri\\))", - ), - ) - } - - @Test - fun `should parse spec sample 527 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo][bar] - | - |[bar]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](/url \"title\")")) - } - - @Test - fun `should parse spec sample 528 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[link [foo [bar]]][ref] - | - |[ref]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

link [foo [bar]]

- */ - parsed.assertEquals(paragraph("[link \\[foo \\[bar\\]\\]](/uri)")) - } - - @Test - fun `should parse spec sample 529 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[link \[bar][ref] - | - |[ref]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

link [bar

- */ - parsed.assertEquals(paragraph("[link \\[bar](/uri)")) - } - - @Test - fun `should parse spec sample 530 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[link *foo **bar** `#`*][ref] - | - |[ref]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

link foo bar #

- */ - parsed.assertEquals(paragraph("[link *foo **bar** `#`*](/uri)")) - } - - @Test - fun `should parse spec sample 531 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[![moon](moon.jpg)][ref] - | - |[ref]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

moon

- */ - parsed.assertEquals(paragraph("[![moon](moon.jpg)](/uri)")) - } - - @Test - fun `should parse spec sample 532 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo [bar](/uri)][ref] - | - |[ref]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foo bar]ref

- */ - parsed.assertEquals(paragraph("\\[foo [bar](/uri)\\][ref](/uri)")) - } - - @Test - fun `should parse spec sample 533 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo *bar [baz][ref]*][ref] - | - |[ref]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foo bar baz]ref

- */ - parsed.assertEquals(paragraph("\\[foo *bar [baz](/uri)*\\][ref](/uri)")) - } - - @Test - fun `should parse spec sample 534 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |*[foo*][ref] - | - |[ref]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

*foo*

- */ - parsed.assertEquals(paragraph("\\*[foo\\*](/uri)")) - } - - @Test - fun `should parse spec sample 535 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo *bar][ref]* - | - |[ref]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo *bar*

- */ - parsed.assertEquals(paragraph("[foo \\*bar](/uri)\\*")) - } - - @Test - fun `should parse spec sample 536 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo - | - |[ref]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foo

- */ - parsed.assertEquals(paragraph("\\[foo ")) - } - - @Test - fun `should parse spec sample 537 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo`][ref]` - | - |[ref]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foo][ref]

- */ - parsed.assertEquals(paragraph("\\[foo`][ref]`")) - } - - @Test - fun `should parse spec sample 538 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo - | - |[ref]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foohttps://example.com/?search=][ref]

- */ - parsed.assertEquals( - paragraph( - "\\[foo[https://example.com/?search=\\]\\[ref\\]](https://example.com/?search=][ref])", - ), - ) - } - - @Test - fun `should parse spec sample 539 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo][BaR] - | - |[bar]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](/url \"title\")")) - } - - @Test - fun `should parse spec sample 540 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[ẞ] - | - |[SS]: /url - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

- */ - parsed.assertEquals(paragraph("[ẞ](/url)")) - } - - @Test - fun `should parse spec sample 541 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[Foo - | bar]: /url - | - |[Baz][Foo bar] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Baz

- */ - parsed.assertEquals(paragraph("[Baz](/url)")) - } - - @Test - fun `should parse spec sample 542 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo] [bar] - | - |[bar]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foo] bar

- */ - parsed.assertEquals(paragraph("\\[foo\\] [bar](/url \"title\")")) - } - - @Test - fun `should parse spec sample 543 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo] - |[bar] - | - |[bar]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foo] - * bar

- */ - parsed.assertEquals(paragraph("\\[foo\\] [bar](/url \"title\")")) - } - - @Test - fun `should parse spec sample 544 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo]: /url1 - | - |[foo]: /url2 - | - |[bar][foo] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

bar

- */ - parsed.assertEquals(paragraph("[bar](/url1)")) - } - - @Test - fun `should parse spec sample 545 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[bar][foo\!] - | - |[foo!]: /url - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[bar][foo!]

- */ - parsed.assertEquals(paragraph("\\[bar\\]\\[foo\\!\\]")) - } - - @Test - fun `should parse spec sample 546 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo][ref[] - | - |[ref[]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foo][ref[]

- *

[ref[]: /uri

- */ - parsed.assertEquals( - paragraph("\\[foo\\]\\[ref\\[\\]"), - paragraph("\\[ref\\[\\]: /uri"), - ) - } - - @Test - fun `should parse spec sample 547 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo][ref[bar]] - | - |[ref[bar]]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foo][ref[bar]]

- *

[ref[bar]]: /uri

- */ - parsed.assertEquals( - paragraph("\\[foo\\]\\[ref\\[bar\\]\\]"), - paragraph("\\[ref\\[bar\\]\\]: /uri"), - ) - } - - @Test - fun `should parse spec sample 548 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[[[foo]]] - | - |[[[foo]]]: /url - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[[[foo]]]

- *

[[[foo]]]: /url

- */ - parsed.assertEquals( - paragraph("\\[\\[\\[foo\\]\\]\\]"), - paragraph("\\[\\[\\[foo\\]\\]\\]: /url"), - ) - } - - @Test - fun `should parse spec sample 549 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo][ref\[] - | - |[ref\[]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](/uri)")) - } - - @Test - fun `should parse spec sample 550 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[bar\\]: /uri - | - |[bar\\] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

bar\

- */ - parsed.assertEquals(paragraph("[bar\\\\](/uri)")) - } - - @Test - fun `should parse spec sample 551 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[] - | - |[]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[]

- *

[]: /uri

- */ - parsed.assertEquals( - paragraph("\\[\\]"), - paragraph("\\[\\]: /uri"), - ) - } - - @Test - fun `should parse spec sample 552 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[ - | ] - | - |[ - | ]: /uri - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[ - * ]

- *

[ - * ]: /uri

- */ - parsed.assertEquals( - paragraph("\\[ \\]"), - paragraph("\\[ \\]: /uri"), - ) - } - - @Test - fun `should parse spec sample 553 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo][] - | - |[foo]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](/url \"title\")")) - } - - @Test - fun `should parse spec sample 554 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[*foo* bar][] - | - |[*foo* bar]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("[*foo* bar](/url \"title\")")) - } - - @Test - fun `should parse spec sample 555 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[Foo][] - | - |[foo]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo

- */ - parsed.assertEquals(paragraph("[Foo](/url \"title\")")) - } - - @Test - fun `should parse spec sample 556 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo] - |[] - | - |[foo]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo - * []

- */ - parsed.assertEquals(paragraph("[foo](/url \"title\") \\[\\]")) - } - - @Test - fun `should parse spec sample 557 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo] - | - |[foo]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](/url \"title\")")) - } - - @Test - fun `should parse spec sample 558 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[*foo* bar] - | - |[*foo* bar]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("[*foo* bar](/url \"title\")")) - } - - @Test - fun `should parse spec sample 559 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[[*foo* bar]] - | - |[*foo* bar]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foo bar]

- */ - parsed.assertEquals(paragraph("\\[[*foo* bar](/url \"title\")\\]")) - } - - @Test - fun `should parse spec sample 560 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[[bar [foo] - | - |[foo]: /url - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[[bar foo

- */ - parsed.assertEquals(paragraph("\\[\\[bar [foo](/url)")) - } - - @Test - fun `should parse spec sample 561 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[Foo] - | - |[foo]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo

- */ - parsed.assertEquals(paragraph("[Foo](/url \"title\")")) - } - - @Test - fun `should parse spec sample 562 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo] bar - | - |[foo]: /url - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("[foo](/url) bar")) - } - - @Test - fun `should parse spec sample 563 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |\[foo] - | - |[foo]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foo]

- */ - parsed.assertEquals(paragraph("\\[foo\\]")) - } - - @Test - fun `should parse spec sample 564 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo*]: /url - | - |*[foo*] - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

*foo*

- */ - parsed.assertEquals(paragraph("\\*[foo\\*](/url)")) - } - - @Test - fun `should parse spec sample 565 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo][bar] - | - |[foo]: /url1 - |[bar]: /url2 - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](/url2)")) - } - - @Test - fun `should parse spec sample 566 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo][] - | - |[foo]: /url1 - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo](/url1)")) - } - - @Test - fun `should parse spec sample 567 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo]() - | - |[foo]: /url1 - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("[foo]()")) - } - - @Test - fun `should parse spec sample 568 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo](not a link) - | - |[foo]: /url1 - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo(not a link)

- */ - parsed.assertEquals(paragraph("[foo](/url1)\\(not a link\\)")) - } - - @Test - fun `should parse spec sample 569 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo][bar][baz] - | - |[baz]: /url - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foo]bar

- */ - parsed.assertEquals(paragraph("\\[foo\\][bar](/url)")) - } - - @Test - fun `should parse spec sample 570 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo][bar][baz] - | - |[baz]: /url1 - |[bar]: /url2 - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foobaz

- */ - parsed.assertEquals(paragraph("[foo](/url2)[baz](/url1)")) - } - - @Test - fun `should parse spec sample 571 correctly (Links)`() { - val parsed = - processor.processMarkdownDocument( - """ - |[foo][bar][baz] - | - |[baz]: /url1 - |[foo]: /url2 - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

[foo]bar

- */ - parsed.assertEquals(paragraph("\\[foo\\][bar](/url1)")) - } - - @Test - fun `should parse spec sample 572 correctly (Images)`() { - val parsed = processor.processMarkdownDocument("![foo](/url \"title\")") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("![foo](/url \"title\")")) - } - - @Test - fun `should parse spec sample 573 correctly (Images)`() { - val parsed = - processor.processMarkdownDocument( - """ - |![foo *bar*] - | - |[foo *bar*]: train.jpg "train & tracks" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("![foo *bar*](train.jpg \"train & tracks\")")) - } - - @Test - fun `should parse spec sample 574 correctly (Images)`() { - val parsed = processor.processMarkdownDocument("![foo ![bar](/url)](/url2)") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("![foo ![bar](/url)](/url2)")) - } - - @Ignore - @Test - fun `should parse spec sample 575 correctly (Images)`() { - val parsed = processor.processMarkdownDocument("![foo [bar](/url)](/url2)") - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("![foo \"bar\" (/url)](/url2)")) - } - - @Test - fun `should parse spec sample 576 correctly (Images)`() { - val parsed = - processor.processMarkdownDocument( - """ - |![foo *bar*][] - | - |[foo *bar*]: train.jpg "train & tracks" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("![foo *bar*](train.jpg \"train & tracks\")")) - } - - @Test - fun `should parse spec sample 577 correctly (Images)`() { - val parsed = - processor.processMarkdownDocument( - """ - |![foo *bar*][foobar] - | - |[FOOBAR]: train.jpg "train & tracks" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("![foo *bar*](train.jpg \"train & tracks\")")) - } - - @Test - fun `should parse spec sample 578 correctly (Images)`() { - val parsed = processor.processMarkdownDocument("![foo](train.jpg)") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("![foo](train.jpg)")) - } - - @Test - fun `should parse spec sample 579 correctly (Images)`() { - val parsed = processor.processMarkdownDocument("My ![foo bar](/path/to/train.jpg \"title\" )") - - /* - * Expected HTML: - *

My foo bar

- */ - parsed.assertEquals(paragraph("My ![foo bar](/path/to/train.jpg \"title\")")) - } - - @Test - fun `should parse spec sample 580 correctly (Images)`() { - val parsed = processor.processMarkdownDocument("![foo]()") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("![foo](url)")) - } - - @Test - fun `should parse spec sample 581 correctly (Images)`() { - val parsed = processor.processMarkdownDocument("![](/url)") - - /* - * Expected HTML: - *

- */ - parsed.assertEquals(paragraph("![](/url)")) - } - - @Test - fun `should parse spec sample 582 correctly (Images)`() { - val parsed = - processor.processMarkdownDocument( - """ - |![foo][bar] - | - |[bar]: /url - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("![foo](/url)")) - } - - @Test - fun `should parse spec sample 583 correctly (Images)`() { - val parsed = - processor.processMarkdownDocument( - """ - |![foo][bar] - | - |[BAR]: /url - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("![foo](/url)")) - } - - @Test - fun `should parse spec sample 584 correctly (Images)`() { - val parsed = - processor.processMarkdownDocument( - """ - |![foo][] - | - |[foo]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("![foo](/url \"title\")")) - } - - @Test - fun `should parse spec sample 585 correctly (Images)`() { - val parsed = - processor.processMarkdownDocument( - """ - |![*foo* bar][] - | - |[*foo* bar]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("![*foo* bar](/url \"title\")")) - } - - @Test - fun `should parse spec sample 586 correctly (Images)`() { - val parsed = - processor.processMarkdownDocument( - """ - |![Foo][] - | - |[foo]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo

- */ - parsed.assertEquals(paragraph("![Foo](/url \"title\")")) - } - - @Test - fun `should parse spec sample 587 correctly (Images)`() { - val parsed = - processor.processMarkdownDocument( - """ - |![foo] - |[] - | - |[foo]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo - * []

- */ - parsed.assertEquals(paragraph("![foo](/url \"title\") \\[\\]")) - } - - @Test - fun `should parse spec sample 588 correctly (Images)`() { - val parsed = - processor.processMarkdownDocument( - """ - |![foo] - | - |[foo]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("![foo](/url \"title\")")) - } - - @Test - fun `should parse spec sample 589 correctly (Images)`() { - val parsed = - processor.processMarkdownDocument( - """ - |![*foo* bar] - | - |[*foo* bar]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo bar

- */ - parsed.assertEquals(paragraph("![*foo* bar](/url \"title\")")) - } - - @Test - fun `should parse spec sample 590 correctly (Images)`() { - val parsed = - processor.processMarkdownDocument( - """ - |![[foo]] - | - |[[foo]]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

![[foo]]

- *

[[foo]]: /url "title"

- */ - parsed.assertEquals( - paragraph("\\!\\[\\[foo\\]\\]"), - paragraph("\\[\\[foo\\]\\]: /url \"title\""), - ) - } - - @Test - fun `should parse spec sample 591 correctly (Images)`() { - val parsed = - processor.processMarkdownDocument( - """ - |![Foo] - | - |[foo]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

Foo

- */ - parsed.assertEquals(paragraph("![Foo](/url \"title\")")) - } - - @Test - fun `should parse spec sample 592 correctly (Images)`() { - val parsed = - processor.processMarkdownDocument( - """ - |!\[foo] - | - |[foo]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

![foo]

- */ - parsed.assertEquals(paragraph("\\!\\[foo\\]")) - } - - @Test - fun `should parse spec sample 593 correctly (Images)`() { - val parsed = - processor.processMarkdownDocument( - """ - |\![foo] - | - |[foo]: /url "title" - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

!foo

- */ - parsed.assertEquals(paragraph("\\![foo](/url \"title\")")) - } - - @Test - fun `should parse spec sample 594 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

http://foo.bar.baz

- */ - parsed.assertEquals(paragraph("[http://foo.bar.baz](http://foo.bar.baz)")) - } - - @Test - fun `should parse spec sample 595 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

https://foo.bar.baz/test?q=hello&id=22&boolean

- */ - parsed.assertEquals( - paragraph( - "[https://foo.bar.baz/test?q=hello&id=22&boolean](https://foo.bar.baz/test?q=hello&id=22&boolean)", - ), - ) - } - - @Test - fun `should parse spec sample 596 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

irc://foo.bar:2233/baz

- */ - parsed.assertEquals(paragraph("[irc://foo.bar:2233/baz](irc://foo.bar:2233/baz)")) - } - - @Test - fun `should parse spec sample 597 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

MAILTO:FOO@BAR.BAZ

- */ - parsed.assertEquals(paragraph("[MAILTO:FOO@BAR.BAZ](MAILTO:FOO@BAR.BAZ)")) - } - - @Test - fun `should parse spec sample 598 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

a+b+c:d

- */ - parsed.assertEquals(paragraph("[a+b+c:d](a+b+c:d)")) - } - - @Test - fun `should parse spec sample 599 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

made-up-scheme://foo,bar

- */ - parsed.assertEquals(paragraph("[made-up-scheme://foo,bar](made-up-scheme://foo,bar)")) - } - - @Test - fun `should parse spec sample 600 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

https://../

- */ - parsed.assertEquals(paragraph("[https://../](https://../)")) - } - - @Test - fun `should parse spec sample 601 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

localhost:5001/foo

- */ - parsed.assertEquals(paragraph("[localhost:5001/foo](localhost:5001/foo)")) - } - - @Test - fun `should parse spec sample 602 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

<https://foo.bar/baz bim>

- */ - parsed.assertEquals(paragraph("\\")) - } - - @Ignore - @Test - fun `should parse spec sample 603 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

https://example.com/\[\

- */ - parsed.assertEquals(paragraph("[https://example.com/\\[\\\\](https://example.com/\\[\\)")) - } - - @Test - fun `should parse spec sample 604 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

foo@bar.example.com

- */ - parsed.assertEquals(paragraph("[foo@bar.example.com](mailto:foo@bar.example.com)")) - } - - @Test - fun `should parse spec sample 605 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

foo+special@Bar.baz-bar0.com

- */ - parsed.assertEquals( - paragraph( - "[foo+special@Bar.baz-bar0.com](mailto:foo+special@Bar.baz-bar0.com)", - ), - ) - } - - @Test - fun `should parse spec sample 606 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

<foo+@bar.example.com>

- */ - parsed.assertEquals(paragraph("\\")) - } - - @Test - fun `should parse spec sample 607 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("<>") - - /* - * Expected HTML: - *

<>

- */ - parsed.assertEquals(paragraph("\\<\\>")) - } - - @Test - fun `should parse spec sample 608 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("< https://foo.bar >") - - /* - * Expected HTML: - *

< https://foo.bar >

- */ - parsed.assertEquals(paragraph("\\< https://foo.bar \\>")) - } - - @Test - fun `should parse spec sample 609 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

<m:abc>

- */ - parsed.assertEquals(paragraph("\\")) - } - - @Test - fun `should parse spec sample 610 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

<foo.bar.baz>

- */ - parsed.assertEquals(paragraph("\\")) - } - - @Test - fun `should parse spec sample 611 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("https://example.com") - - /* - * Expected HTML: - *

https://example.com

- */ - parsed.assertEquals(paragraph("https://example.com")) - } - - @Test - fun `should parse spec sample 612 correctly (Autolinks)`() { - val parsed = processor.processMarkdownDocument("foo@bar.example.com") - - /* - * Expected HTML: - *

foo@bar.example.com

- */ - parsed.assertEquals(paragraph("foo@bar.example.com")) - } - - @Test - fun `should parse spec sample 613 correctly (Raw HTML)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

- */ - parsed.assertEquals(paragraph("")) - } - - @Test - fun `should parse spec sample 614 correctly (Raw HTML)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

- */ - parsed.assertEquals(paragraph("")) - } - - @Test - fun `should parse spec sample 615 correctly (Raw HTML)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

- */ - parsed.assertEquals(paragraph("")) - } - - @Test - fun `should parse spec sample 616 correctly (Raw HTML)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

- */ - parsed.assertEquals( - paragraph( - "", - ), - ) - } - - @Test - fun `should parse spec sample 617 correctly (Raw HTML)`() { - val parsed = processor.processMarkdownDocument("Foo ") - - /* - * Expected HTML: - *

Foo

- */ - parsed.assertEquals(paragraph("Foo ")) - } - - @Test - fun `should parse spec sample 618 correctly (Raw HTML)`() { - val parsed = processor.processMarkdownDocument("<33> <__>") - - /* - * Expected HTML: - *

<33> <__>

- */ - parsed.assertEquals(paragraph("\\<33\\> \\<\\_\\_\\>")) - } - - @Test - fun `should parse spec sample 619 correctly (Raw HTML)`() { - val parsed = processor.processMarkdownDocument("
") - - /* - * Expected HTML: - *

<a h*#ref="hi">

- */ - parsed.assertEquals(paragraph("\\
")) - } - - @Test - fun `should parse spec sample 620 correctly (Raw HTML)`() { - val parsed = processor.processMarkdownDocument(" ") - - /* - * Expected HTML: - *

<a href="hi'> <a href=hi'>

- */ - parsed.assertEquals(paragraph("\\
\\")) - } - - @Test - fun `should parse spec sample 621 correctly (Raw HTML)`() { - val parsed = - processor.processMarkdownDocument( - """ - |< a>< - |foo> - | - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

< a>< - * foo><bar/ > - * <foo bar=baz - * bim!bop />

- */ - parsed.assertEquals( - paragraph( - "\\< a\\>\\< foo\\>\\ \\", - ), - ) - } - - @Test - fun `should parse spec sample 622 correctly (Raw HTML)`() { - val parsed = processor.processMarkdownDocument("
") - - /* - * Expected HTML: - *

<a href='bar'title=title>

- */ - parsed.assertEquals(paragraph("\\
")) - } - - @Test - fun `should parse spec sample 623 correctly (Raw HTML)`() { - val parsed = processor.processMarkdownDocument("
") - - /* - * Expected HTML: - *

- */ - parsed.assertEquals(paragraph("")) - } - - @Test - fun `should parse spec sample 624 correctly (Raw HTML)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

</a href="foo">

- */ - parsed.assertEquals(paragraph("\\")) - } - - @Test - fun `should parse spec sample 625 correctly (Raw HTML)`() { - val parsed = - processor.processMarkdownDocument( - """ - |foo - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("foo ")) - } - - @Test - fun `should parse spec sample 626 correctly (Raw HTML)`() { - val parsed = - processor.processMarkdownDocument( - """ - |foo foo --> - | - |foo foo --> - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo foo -->

- *

foo foo -->

- */ - parsed.assertEquals( - paragraph("foo foo --\\>"), - paragraph("foo foo --\\>"), - ) - } - - @Test - fun `should parse spec sample 627 correctly (Raw HTML)`() { - val parsed = processor.processMarkdownDocument("foo ") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("foo ")) - } - - @Test - fun `should parse spec sample 628 correctly (Raw HTML)`() { - val parsed = processor.processMarkdownDocument("foo ") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("foo ")) - } - - @Test - fun `should parse spec sample 629 correctly (Raw HTML)`() { - val parsed = processor.processMarkdownDocument("foo &<]]>") - - /* - * Expected HTML: - *

foo &<]]>

- */ - parsed.assertEquals(paragraph("foo &<]]>")) - } - - @Test - fun `should parse spec sample 630 correctly (Raw HTML)`() { - val parsed = processor.processMarkdownDocument("foo ") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("foo ")) - } - - @Test - fun `should parse spec sample 631 correctly (Raw HTML)`() { - val parsed = processor.processMarkdownDocument("foo ") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("foo ")) - } - - @Test - fun `should parse spec sample 632 correctly (Raw HTML)`() { - val parsed = processor.processMarkdownDocument("") - - /* - * Expected HTML: - *

<a href=""">

- */ - parsed.assertEquals(paragraph("\\
")) - } - - @Test - fun `should parse spec sample 633 correctly (Hard line breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |foo - |baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo
- * baz

- */ - parsed.assertEquals(paragraph("foo
baz")) - } - - @Test - fun `should parse spec sample 634 correctly (Hard line breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |foo\ - |baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo
- * baz

- */ - parsed.assertEquals(paragraph("foo
baz")) - } - - @Ignore - @Test - fun `should parse spec sample 635 correctly (Hard line breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |foo - |baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo
- * baz

- */ - parsed.assertEquals(paragraph("foo\nbaz")) - } - - @Ignore - @Test - fun `should parse spec sample 636 correctly (Hard line breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |foo - | bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo
- * bar

- */ - parsed.assertEquals(paragraph("foo\nbar")) - } - - @Ignore - @Test - fun `should parse spec sample 637 correctly (Hard line breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |foo\ - | bar - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo
- * bar

- */ - parsed.assertEquals(paragraph("foo\nbar")) - } - - @Ignore - @Test - fun `should parse spec sample 638 correctly (Hard line breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |*foo - |bar* - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo
- * bar

- */ - parsed.assertEquals(paragraph("*foo\nbar*")) - } - - @Ignore - @Test - fun `should parse spec sample 639 correctly (Hard line breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |*foo\ - |bar* - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo
- * bar

- */ - parsed.assertEquals(paragraph("*foo\nbar*")) - } - - @Test - fun `should parse spec sample 640 correctly (Hard line breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |`code - |span` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

code span

- */ - parsed.assertEquals(paragraph("`code span`")) - } - - @Test - fun `should parse spec sample 641 correctly (Hard line breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |`code\ - |span` - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

code\ span

- */ - parsed.assertEquals(paragraph("`code\\ span`")) - } - - @Test - fun `should parse spec sample 642 correctly (Hard line breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |
- """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

- */ - parsed.assertEquals(paragraph("")) - } - - @Test - fun `should parse spec sample 643 correctly (Hard line breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - | - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

- */ - parsed.assertEquals(paragraph("")) - } - - @Test - fun `should parse spec sample 644 correctly (Hard line breaks)`() { - val parsed = processor.processMarkdownDocument("foo\\") - - /* - * Expected HTML: - *

foo\

- */ - parsed.assertEquals(paragraph("foo\\")) - } - - @Test - fun `should parse spec sample 645 correctly (Hard line breaks)`() { - val parsed = processor.processMarkdownDocument("foo ") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(paragraph("foo")) - } - - @Test - fun `should parse spec sample 646 correctly (Hard line breaks)`() { - val parsed = processor.processMarkdownDocument("### foo\\") - - /* - * Expected HTML: - *

foo\

- */ - parsed.assertEquals(heading(level = 3, "foo\\")) - } - - @Test - fun `should parse spec sample 647 correctly (Hard line breaks)`() { - val parsed = processor.processMarkdownDocument("### foo ") - - /* - * Expected HTML: - *

foo

- */ - parsed.assertEquals(heading(level = 3, "foo")) - } - - @Test - fun `should parse spec sample 648 correctly (Soft line breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |foo - |baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo - * baz

- */ - parsed.assertEquals(paragraph("foo baz")) - } - - @Test - fun `should parse spec sample 649 correctly (Soft line breaks)`() { - val parsed = - processor.processMarkdownDocument( - """ - |foo - | baz - """ - .trimMargin(), - ) - - /* - * Expected HTML: - *

foo - * baz

- */ - parsed.assertEquals(paragraph("foo baz")) - } - - @Test - fun `should parse spec sample 650 correctly (Textual content)`() { - val parsed = processor.processMarkdownDocument("hello $.;'there") - - /* - * Expected HTML: - *

hello $.;'there

- */ - parsed.assertEquals(paragraph("hello \$.;'there")) - } - - @Test - fun `should parse spec sample 651 correctly (Textual content)`() { - val parsed = processor.processMarkdownDocument("Foo χρῆν") - - /* - * Expected HTML: - *

Foo χρῆν

- */ - parsed.assertEquals(paragraph("Foo χρῆν")) - } - - @Test - fun `should parse spec sample 652 correctly (Textual content)`() { - val parsed = processor.processMarkdownDocument("Multiple spaces") - - /* - * Expected HTML: - *

Multiple spaces

- */ - parsed.assertEquals(paragraph("Multiple spaces")) - } -} diff --git a/markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/TestUtils.kt b/markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/TestUtils.kt deleted file mode 100644 index be88cc352..000000000 --- a/markdown/core/src/test/kotlin/org/jetbrains/jewel/markdown/TestUtils.kt +++ /dev/null @@ -1,245 +0,0 @@ -package org.jetbrains.jewel.markdown - -import org.commonmark.node.Node -import org.commonmark.parser.Parser -import org.commonmark.renderer.html.HtmlRenderer -import org.intellij.lang.annotations.Language -import org.jetbrains.jewel.markdown.MarkdownBlock.BlockQuote -import org.jetbrains.jewel.markdown.MarkdownBlock.CodeBlock -import org.jetbrains.jewel.markdown.MarkdownBlock.CodeBlock.FencedCodeBlock -import org.jetbrains.jewel.markdown.MarkdownBlock.CodeBlock.IndentedCodeBlock -import org.jetbrains.jewel.markdown.MarkdownBlock.Heading -import org.jetbrains.jewel.markdown.MarkdownBlock.HtmlBlock -import org.jetbrains.jewel.markdown.MarkdownBlock.ListBlock -import org.jetbrains.jewel.markdown.MarkdownBlock.ListBlock.BulletList -import org.jetbrains.jewel.markdown.MarkdownBlock.ListBlock.OrderedList -import org.jetbrains.jewel.markdown.MarkdownBlock.ListItem -import org.jetbrains.jewel.markdown.MarkdownBlock.Paragraph -import org.jetbrains.jewel.markdown.MarkdownBlock.ThematicBreak -import org.junit.Assert - -fun List.assertEquals(vararg expected: MarkdownBlock) { - val differences = findDifferences(expected.toList(), indentSize = 0) - Assert.assertTrue( - "The following differences were found:\n\n" + - "${differences.joinToString("\n").replace('\t', '→')}\n\n", - differences.isEmpty(), - ) -} - -fun List.findDifferences( - expected: List, - indentSize: Int, -): List = buildList { - val indent = " ".repeat(indentSize) - val thisSize = this@findDifferences.size - if (expected.size != thisSize) { - add("$indent * Content size mismatch. Was $thisSize, but we expected ${expected.size}") - add("$indent Actual: ${this@findDifferences}") - add("$indent Expected: $expected\n") - add("$indent ℹ️ Note: skipping cells comparison as it's meaningless") - return@buildList - } - - for ((i, item) in this@findDifferences.withIndex()) { - val difference = item.findDifferenceWith(expected[i], indentSize + 2) - if (difference.isNotEmpty()) { - add( - "$indent * Item #$i is not the same as the expected value.\n\n" + - "${difference.joinToString("\n")}\n", - ) - } - } -} - -private fun MarkdownBlock.findDifferenceWith( - expected: MarkdownBlock, - indentSize: Int, -): List { - val indent = " ".repeat(indentSize) - if (this.javaClass != expected.javaClass) { - return listOf( - "$indent * Block type mismatch.\n\n" + - "$indent Actual: ${javaClass.name}\n" + - "$indent Expected: ${expected.javaClass.name}\n", - ) - } - - return when (this) { - is Paragraph -> diffParagraph(this, expected, indent) - is BlockQuote -> content.findDifferences((expected as BlockQuote).content, indentSize) - is HtmlBlock -> diffHtmlBlock(this, expected, indent) - is FencedCodeBlock -> diffFencedCodeBlock(this, expected, indent) - is IndentedCodeBlock -> diffIndentedCodeBlock(this, expected, indent) - is Heading -> diffHeading(this, expected, indent) - is ListBlock -> diffList(this, expected, indentSize, indent) - is ListItem -> content.findDifferences((expected as ListItem).content, indentSize) - is ThematicBreak -> emptyList() // They can only differ in their node - else -> error("Unsupported MarkdownBlock: ${this.javaClass.name}") - } -} - -private var htmlRenderer = HtmlRenderer.builder().build() - -fun BlockWithInlineMarkdown.toHtml() = buildString { - for (node in this@toHtml.inlineContent) { - // new lines are rendered as spaces in tests - append(htmlRenderer.render(node.value).replace("\n", " ")) - } -} - -private fun diffParagraph(actual: Paragraph, expected: MarkdownBlock, indent: String) = buildList { - val actualInlineHtml = actual.toHtml() - val expectedInlineHtml = (expected as Paragraph).toHtml() - if (actualInlineHtml != expectedInlineHtml) { - add( - "$indent * Paragraph raw content mismatch.\n\n" + - "$indent Actual: $actualInlineHtml\n" + - "$indent Expected: $expectedInlineHtml\n", - ) - } -} - -private fun diffHtmlBlock(actual: HtmlBlock, expected: MarkdownBlock, indent: String) = buildList { - if (actual.content != (expected as HtmlBlock).content) { - add( - "$indent * HTML block content mismatch.\n\n" + - "$indent Actual: ${actual.content}\n" + - "$indent Expected: ${expected.content}\n", - ) - } -} - -private fun diffFencedCodeBlock(actual: FencedCodeBlock, expected: MarkdownBlock, indent: String) = - buildList { - if (actual.mimeType != (expected as FencedCodeBlock).mimeType) { - add( - "$indent * Fenced code block mime type mismatch.\n\n" + - "$indent Actual: ${actual.mimeType}\n" + - "$indent Expected: ${expected.mimeType}", - ) - } - - if (actual.content != expected.content) { - add( - "$indent * Fenced code block content mismatch.\n\n" + - "$indent Actual: ${actual.content}\n" + - "$indent Expected: ${expected.content}", - ) - } - } - -private fun diffIndentedCodeBlock(actual: CodeBlock, expected: MarkdownBlock, indent: String) = - buildList { - if (actual.content != (expected as IndentedCodeBlock).content) { - add( - "$indent * Indented code block content mismatch.\n\n" + - "$indent Actual: ${actual.content}\n" + - "$indent Expected: ${expected.content}", - ) - } - } - -private fun diffHeading(actual: Heading, expected: MarkdownBlock, indent: String) = buildList { - val actualInlineHtml = actual.toHtml() - val expectedInlineHtml = (expected as Heading).toHtml() - if (actualInlineHtml != expectedInlineHtml) { - add( - "$indent * Heading raw content mismatch.\n\n" + - "$indent Actual: $actualInlineHtml\n" + - "$indent Expected: $expectedInlineHtml", - ) - } -} - -private fun diffList(actual: ListBlock, expected: MarkdownBlock, indentSize: Int, indent: String) = - buildList { - addAll(actual.items.findDifferences((expected as ListBlock).items, indentSize)) - - if (actual.isTight != expected.isTight) { - add( - "$indent * List isTight mismatch.\n\n" + - "$indent Actual: ${actual.isTight}\n" + - "$indent Expected: ${expected.isTight}", - ) - } - - when (actual) { - is OrderedList -> { - if (actual.startFrom != (expected as OrderedList).startFrom) { - add( - "$indent * List startFrom mismatch.\n\n" + - "$indent Actual: ${actual.startFrom}\n" + - "$indent Expected: ${expected.startFrom}", - ) - } - - if (actual.delimiter != expected.delimiter) { - add( - "$indent * List delimiter mismatch.\n\n" + - "$indent Actual: ${actual.delimiter}\n" + - "$indent Expected: ${expected.delimiter}", - ) - } - } - - is BulletList -> { - if (actual.bulletMarker != (expected as BulletList).bulletMarker) { - add( - "$indent * List bulletMarker mismatch.\n\n" + - "$indent Actual: ${actual.bulletMarker}\n" + - "$indent Expected: ${expected.bulletMarker}", - ) - } - } - } - } - -private val parser = Parser.builder().build() - -private fun Node.children() = buildList { - var child = firstChild - while (child != null) { - add(child) - child = child.next - } -} - -/** skip root Document and Paragraph nodes */ -private fun inlineMarkdowns(content: String): List { - val document = parser.parse(content).firstChild ?: return emptyList() - return if (document.firstChild is org.commonmark.node.Paragraph) { - document.firstChild - } else { - document - }.children().map { x -> x.toInlineNode() } -} - -fun paragraph(@Language("Markdown") content: String): Paragraph = Paragraph(inlineMarkdowns(content)) - -fun indentedCodeBlock(content: String) = IndentedCodeBlock(content) - -fun fencedCodeBlock(content: String, mimeType: MimeType? = null) = - FencedCodeBlock(content, mimeType) - -fun blockQuote(vararg contents: MarkdownBlock) = BlockQuote(contents.toList()) - -fun unorderedList( - vararg items: ListItem, - isTight: Boolean = true, - bulletMarker: Char = '-', -) = BulletList(items.toList(), isTight, bulletMarker) - -fun orderedList( - vararg items: ListItem, - isTight: Boolean = true, - startFrom: Int = 1, - delimiter: Char = '.', -) = OrderedList(items.toList(), isTight, startFrom, delimiter) - -fun listItem(vararg items: MarkdownBlock) = ListItem(items.toList()) - -internal fun heading(level: Int, @Language("Markdown") content: String) = - Heading(inlineMarkdowns(content), level) - -fun htmlBlock(content: String) = HtmlBlock(content) diff --git a/markdown/extension/gfm-alerts/api/gfm-alerts.api b/markdown/extension/gfm-alerts/api/gfm-alerts.api index c292a1850..7bea82238 100644 --- a/markdown/extension/gfm-alerts/api/gfm-alerts.api +++ b/markdown/extension/gfm-alerts/api/gfm-alerts.api @@ -1,67 +1,3 @@ -public abstract interface class org/jetbrains/jewel/markdown/extensions/github/alerts/Alert : org/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock { - public abstract fun getContent ()Ljava/util/List; -} - -public final class org/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Caution : org/jetbrains/jewel/markdown/extensions/github/alerts/Alert { - public static final field $stable I - public fun (Ljava/util/List;)V - public final fun component1 ()Ljava/util/List; - public final fun copy (Ljava/util/List;)Lorg/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Caution; - public static synthetic fun copy$default (Lorg/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Caution;Ljava/util/List;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Caution; - public fun equals (Ljava/lang/Object;)Z - public fun getContent ()Ljava/util/List; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class org/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Important : org/jetbrains/jewel/markdown/extensions/github/alerts/Alert { - public static final field $stable I - public fun (Ljava/util/List;)V - public final fun component1 ()Ljava/util/List; - public final fun copy (Ljava/util/List;)Lorg/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Important; - public static synthetic fun copy$default (Lorg/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Important;Ljava/util/List;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Important; - public fun equals (Ljava/lang/Object;)Z - public fun getContent ()Ljava/util/List; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class org/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Note : org/jetbrains/jewel/markdown/extensions/github/alerts/Alert { - public static final field $stable I - public fun (Ljava/util/List;)V - public final fun component1 ()Ljava/util/List; - public final fun copy (Ljava/util/List;)Lorg/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Note; - public static synthetic fun copy$default (Lorg/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Note;Ljava/util/List;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Note; - public fun equals (Ljava/lang/Object;)Z - public fun getContent ()Ljava/util/List; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class org/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Tip : org/jetbrains/jewel/markdown/extensions/github/alerts/Alert { - public static final field $stable I - public fun (Ljava/util/List;)V - public final fun component1 ()Ljava/util/List; - public final fun copy (Ljava/util/List;)Lorg/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Tip; - public static synthetic fun copy$default (Lorg/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Tip;Ljava/util/List;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Tip; - public fun equals (Ljava/lang/Object;)Z - public fun getContent ()Ljava/util/List; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class org/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Warning : org/jetbrains/jewel/markdown/extensions/github/alerts/Alert { - public static final field $stable I - public fun (Ljava/util/List;)V - public final fun component1 ()Ljava/util/List; - public final fun copy (Ljava/util/List;)Lorg/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Warning; - public static synthetic fun copy$default (Lorg/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Warning;Ljava/util/List;ILjava/lang/Object;)Lorg/jetbrains/jewel/markdown/extensions/github/alerts/Alert$Warning; - public fun equals (Ljava/lang/Object;)Z - public fun getContent ()Ljava/util/List; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - public final class org/jetbrains/jewel/markdown/extensions/github/alerts/AlertStyling { public static final field $stable I public static final field Companion Lorg/jetbrains/jewel/markdown/extensions/github/alerts/AlertStyling$Companion; @@ -115,8 +51,8 @@ public final class org/jetbrains/jewel/markdown/extensions/github/alerts/Caution public final class org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertBlockRenderer : org/jetbrains/jewel/markdown/extensions/MarkdownBlockRendererExtension { public static final field $stable I public fun (Lorg/jetbrains/jewel/markdown/extensions/github/alerts/AlertStyling;Lorg/jetbrains/jewel/markdown/rendering/MarkdownStyling;)V - public fun canRender (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock;)Z - public fun render (Lorg/jetbrains/jewel/markdown/MarkdownBlock$CustomBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Landroidx/compose/runtime/Composer;I)V + public fun canRender-oaZXzmo (Lorg/commonmark/node/CustomBlock;)Z + public fun render-WESUQbY (Lorg/commonmark/node/CustomBlock;Lorg/jetbrains/jewel/markdown/rendering/MarkdownBlockRenderer;Lorg/jetbrains/jewel/markdown/rendering/InlineMarkdownRenderer;Landroidx/compose/runtime/Composer;I)V } public final class org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertProcessorExtension : org/jetbrains/jewel/markdown/extensions/MarkdownProcessorExtension { diff --git a/markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/Alert.kt b/markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/Alert.kt deleted file mode 100644 index 79247d6e3..000000000 --- a/markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/Alert.kt +++ /dev/null @@ -1,18 +0,0 @@ -package org.jetbrains.jewel.markdown.extensions.github.alerts - -import org.jetbrains.jewel.markdown.MarkdownBlock - -public sealed interface Alert : MarkdownBlock.CustomBlock { - - public val content: List - - public data class Note(override val content: List) : Alert - - public data class Tip(override val content: List) : Alert - - public data class Important(override val content: List) : Alert - - public data class Warning(override val content: List) : Alert - - public data class Caution(override val content: List) : Alert -} diff --git a/markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/AlertBlock.kt b/markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/AlertBlock.kt new file mode 100644 index 000000000..e16e62aee --- /dev/null +++ b/markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/AlertBlock.kt @@ -0,0 +1,12 @@ +package org.jetbrains.jewel.markdown.extensions.github.alerts + +import org.commonmark.node.CustomBlock +import org.jetbrains.jewel.foundation.GenerateDataFunctions + +@GenerateDataFunctions +internal class AlertBlock(val kind: Kind) : CustomBlock() { + + enum class Kind { + Note, Tip, Important, Warning, Caution + } +} diff --git a/markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertBlockRenderer.kt b/markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertBlockRenderer.kt index 5ffdddb5b..3354bf0c3 100644 --- a/markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertBlockRenderer.kt +++ b/markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertBlockRenderer.kt @@ -21,11 +21,6 @@ import androidx.compose.ui.unit.dp import org.jetbrains.jewel.foundation.theme.LocalContentColor import org.jetbrains.jewel.markdown.MarkdownBlock.CustomBlock import org.jetbrains.jewel.markdown.extensions.MarkdownBlockRendererExtension -import org.jetbrains.jewel.markdown.extensions.github.alerts.Alert.Caution -import org.jetbrains.jewel.markdown.extensions.github.alerts.Alert.Important -import org.jetbrains.jewel.markdown.extensions.github.alerts.Alert.Note -import org.jetbrains.jewel.markdown.extensions.github.alerts.Alert.Tip -import org.jetbrains.jewel.markdown.extensions.github.alerts.Alert.Warning import org.jetbrains.jewel.markdown.rendering.InlineMarkdownRenderer import org.jetbrains.jewel.markdown.rendering.MarkdownBlockRenderer import org.jetbrains.jewel.markdown.rendering.MarkdownStyling @@ -38,7 +33,7 @@ public class GitHubAlertBlockRenderer( ) : MarkdownBlockRendererExtension { override fun canRender(block: CustomBlock): Boolean = - block is Alert + block.value is AlertBlock @Composable override fun render( @@ -49,20 +44,19 @@ public class GitHubAlertBlockRenderer( // Smart cast doesn't work in this case, and then the detection for redundant suppression is // also borked @Suppress("MoveVariableDeclarationIntoWhen", "RedundantSuppression") - val alert = block as? Alert + val alert = block.value as AlertBlock - when (alert) { - is Caution -> Alert(alert, styling.caution, blockRenderer) - is Important -> Alert(alert, styling.important, blockRenderer) - is Note -> Alert(alert, styling.note, blockRenderer) - is Tip -> Alert(alert, styling.tip, blockRenderer) - is Warning -> Alert(alert, styling.warning, blockRenderer) - else -> error("Unsupported block of type ${block.javaClass.name} cannot be rendered") + when (alert.kind) { + AlertBlock.Kind.Caution -> Alert(block, styling.caution, blockRenderer) + AlertBlock.Kind.Important -> Alert(block, styling.important, blockRenderer) + AlertBlock.Kind.Note -> Alert(block, styling.note, blockRenderer) + AlertBlock.Kind.Tip -> Alert(block, styling.tip, blockRenderer) + AlertBlock.Kind.Warning -> Alert(block, styling.warning, blockRenderer) } } @Composable - private fun Alert(block: Alert, styling: BaseAlertStyling, blockRenderer: MarkdownBlockRenderer) { + private fun Alert(block: CustomBlock, styling: BaseAlertStyling, blockRenderer: MarkdownBlockRenderer) { Column( Modifier.drawBehind { val isLtr = layoutDirection == Ltr @@ -109,7 +103,7 @@ public class GitHubAlertBlockRenderer( styling.titleTextStyle.color.takeOrElse { LocalContentColor.current }, ) { Text( - text = block.javaClass.simpleName, + text = (block.value as AlertBlock).kind.name, style = styling.titleTextStyle, modifier = Modifier.pointerHoverIcon(PointerIcon.Default, overrideDescendants = true), ) @@ -118,7 +112,7 @@ public class GitHubAlertBlockRenderer( CompositionLocalProvider( LocalContentColor provides styling.textColor.takeOrElse { LocalContentColor.current }, ) { - blockRenderer.render(block.content) + blockRenderer.render(block.children) } } } diff --git a/markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertProcessorExtension.kt b/markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertProcessorExtension.kt index 44b672306..be14dd876 100644 --- a/markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertProcessorExtension.kt +++ b/markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertProcessorExtension.kt @@ -20,11 +20,7 @@ import org.jetbrains.jewel.markdown.extensions.MarkdownBlockProcessorExtension import org.jetbrains.jewel.markdown.extensions.MarkdownBlockRendererExtension import org.jetbrains.jewel.markdown.extensions.MarkdownProcessorExtension import org.jetbrains.jewel.markdown.extensions.MarkdownRendererExtension -import org.jetbrains.jewel.markdown.extensions.github.alerts.AlertBlock.Caution -import org.jetbrains.jewel.markdown.extensions.github.alerts.AlertBlock.Important -import org.jetbrains.jewel.markdown.extensions.github.alerts.AlertBlock.Note -import org.jetbrains.jewel.markdown.extensions.github.alerts.AlertBlock.Tip -import org.jetbrains.jewel.markdown.extensions.github.alerts.AlertBlock.Warning +import org.jetbrains.jewel.markdown.extensions.github.alerts.AlertBlock.Kind import org.jetbrains.jewel.markdown.processing.MarkdownProcessor import org.jetbrains.jewel.markdown.rendering.MarkdownStyling @@ -41,18 +37,19 @@ public object GitHubAlertProcessorExtension : MarkdownProcessorExtension { override fun canProcess(block: CustomBlock): Boolean = block is AlertBlock override fun processMarkdownBlock(block: CustomBlock, processor: MarkdownProcessor): MarkdownBlock.CustomBlock? { - val children = processor.processChildren(block) - - if (children.isEmpty()) return null - - return when (block) { - is Caution -> Alert.Caution(children) - is Important -> Alert.Important(children) - is Note -> Alert.Note(children) - is Tip -> Alert.Tip(children) - is Warning -> Alert.Warning(children) - else -> error("Unsupported custom block of type ${block.javaClass.name}") - } + error("should use CustomNode parser instead") +// val children = processor.processChildren(block) +// +// if (children.isEmpty()) return null +// +// return when (block) { +// is Caution -> Alert.Caution(children) +// is Important -> Alert.Important(children) +// is Note -> Alert.Note(children) +// is Tip -> Alert.Tip(children) +// is Warning -> Alert.Warning(children) +// else -> error("Unsupported custom block of type ${block.javaClass.name}") +// } } } } @@ -95,11 +92,11 @@ private class AlertParser(type: String) : AbstractBlockParser() { private val block = when (type.lowercase()) { - "note" -> Note() - "tip" -> Tip() - "important" -> Important() - "warning" -> Warning() - "caution" -> Caution() + "note" -> AlertBlock(Kind.Note) + "tip" -> AlertBlock(Kind.Tip) + "important" -> AlertBlock(Kind.Important) + "warning" -> AlertBlock(Kind.Warning) + "caution" -> AlertBlock(Kind.Caution) else -> error("Unsupported highlighted blockquote type: '$type'") } @@ -139,12 +136,12 @@ private class AlertTextContentNodeRenderer(private val context: TextContentNodeR override fun render(node: Node) { val premise = - when (node as? AlertBlock) { - is Caution -> "\uD83D\uDED1 Caution! " - is Important -> "⚠\uFE0F Important! " - is Note -> "ℹ\uFE0F Note: " - is Tip -> "\uD83D\uDCA1 Tip: " - is Warning -> "⚠\uFE0F Warning: " + when ((node as? AlertBlock)?.kind) { + Kind.Caution -> "\uD83D\uDED1 Caution! " + Kind.Important -> "⚠\uFE0F Important! " + Kind.Note -> "ℹ\uFE0F Note: " + Kind.Tip -> "\uD83D\uDCA1 Tip: " + Kind.Warning -> "⚠\uFE0F Warning: " null -> error("Unsupported node type ${node.javaClass.name}") } @@ -160,16 +157,3 @@ private class AlertTextContentNodeRenderer(private val context: TextContentNodeR } } } - -internal sealed class AlertBlock : CustomBlock() { - - class Note : AlertBlock() - - class Tip : AlertBlock() - - class Important : AlertBlock() - - class Warning : AlertBlock() - - class Caution : AlertBlock() -} diff --git a/markdown/extension/gfm-alerts/src/test/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertBlockExtensionTest.kt b/markdown/extension/gfm-alerts/src/test/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertBlockExtensionTest.kt index d95e5b0ff..90e892aa0 100644 --- a/markdown/extension/gfm-alerts/src/test/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertBlockExtensionTest.kt +++ b/markdown/extension/gfm-alerts/src/test/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertBlockExtensionTest.kt @@ -6,16 +6,11 @@ import org.commonmark.node.Node import org.commonmark.node.Paragraph import org.commonmark.parser.Parser import org.commonmark.renderer.text.TextContentRenderer -import org.jetbrains.jewel.markdown.extensions.github.alerts.AlertBlock.Caution -import org.jetbrains.jewel.markdown.extensions.github.alerts.AlertBlock.Important -import org.jetbrains.jewel.markdown.extensions.github.alerts.AlertBlock.Note -import org.jetbrains.jewel.markdown.extensions.github.alerts.AlertBlock.Tip -import org.jetbrains.jewel.markdown.extensions.github.alerts.AlertBlock.Warning import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Test -class GitHubAlertBlockCustomBlockTest { +class GitHubAlertBlockExtensionTest { private val parser = Parser.builder() @@ -44,8 +39,8 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a Note node, but was ${firstChild.javaClass.name}", - firstChild is Note, + "Parsed node should be a Note node, but was $firstChild", + firstChild is AlertBlock && firstChild.kind == AlertBlock.Kind.Note, ) val contents = firstChild.children @@ -81,8 +76,8 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a Tip node, but was ${firstChild.javaClass.name}", - firstChild is Tip, + "Parsed node should be a Tip node, but was $firstChild", + firstChild is AlertBlock && firstChild.kind == AlertBlock.Kind.Tip, ) val contents = firstChild.children @@ -117,8 +112,8 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a Important node, but was ${firstChild.javaClass.name}", - firstChild is Important, + "Parsed node should be a Important node, but was $firstChild", + firstChild is AlertBlock && firstChild.kind == AlertBlock.Kind.Important, ) val contents = firstChild.children @@ -153,8 +148,8 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a Warning node, but was ${firstChild.javaClass.name}", - firstChild is Warning, + "Parsed node should be a Warning node, but was $firstChild", + firstChild is AlertBlock && firstChild.kind == AlertBlock.Kind.Warning, ) val contents = firstChild.children @@ -189,8 +184,8 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a Caution node, but was ${firstChild.javaClass.name}", - firstChild is Caution, + "Parsed node should be a Caution node, but was $firstChild", + firstChild is AlertBlock && firstChild.kind == AlertBlock.Kind.Caution, ) val contents = firstChild.children @@ -225,8 +220,8 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a Note node, but was ${firstChild.javaClass.name}", - firstChild is Note, + "Parsed node should be a Note node, but was $firstChild", + firstChild is AlertBlock && firstChild.kind == AlertBlock.Kind.Note, ) val contents = firstChild.children @@ -261,8 +256,8 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a Tip node, but was ${firstChild.javaClass.name}", - firstChild is Tip, + "Parsed node should be a Tip node, but was $firstChild", + firstChild is AlertBlock && firstChild.kind == AlertBlock.Kind.Tip, ) val contents = firstChild.children @@ -297,8 +292,8 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a Important node, but was ${firstChild.javaClass.name}", - firstChild is Important, + "Parsed node should be a Important node, but was $firstChild", + firstChild is AlertBlock && firstChild.kind == AlertBlock.Kind.Important, ) val contents = firstChild.children @@ -333,8 +328,8 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a Warning node, but was ${firstChild.javaClass.name}", - firstChild is Warning, + "Parsed node should be a Warning node, but was $firstChild", + firstChild is AlertBlock && firstChild.kind == AlertBlock.Kind.Warning, ) val contents = firstChild.children @@ -369,8 +364,8 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a Caution node, but was ${firstChild.javaClass.name}", - firstChild is Caution, + "Parsed node should be a Caution node, but was $firstChild", + firstChild is AlertBlock && firstChild.kind == AlertBlock.Kind.Caution, ) val contents = firstChild.children @@ -407,8 +402,8 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a Caution node, but was ${firstChild.javaClass.name}", - firstChild is Caution, + "Parsed node should be a Caution node, but was $firstChild", + firstChild is AlertBlock && firstChild.kind == AlertBlock.Kind.Caution, ) val contents = firstChild.children @@ -416,7 +411,7 @@ class GitHubAlertBlockCustomBlockTest { val firstContent = contents.first() assertTrue( - "Parsed content should be a Paragraph, but was ${firstContent.javaClass.name}", + "Parsed content should be a Paragraph, but was $firstContent", firstContent is Paragraph, ) assertEquals( @@ -443,7 +438,7 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a BlockQuote node, but was ${firstChild.javaClass.name}", + "Parsed node should be a BlockQuote node, but was $firstChild", firstChild is BlockQuote, ) } @@ -466,7 +461,7 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a BlockQuote node, but was ${firstChild.javaClass.name}", + "Parsed node should be a BlockQuote node, but was $firstChild", firstChild is BlockQuote, ) } @@ -488,7 +483,7 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a BlockQuote node, but was ${firstChild.javaClass.name}", + "Parsed node should be a BlockQuote node, but was $firstChild", firstChild is BlockQuote, ) } @@ -510,7 +505,7 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a BlockQuote node, but was ${firstChild.javaClass.name}", + "Parsed node should be a BlockQuote node, but was $firstChild", firstChild is BlockQuote, ) } @@ -531,7 +526,7 @@ class GitHubAlertBlockCustomBlockTest { val firstChild = children.first() assertTrue( - "Parsed node should be a BlockQuote node, but was ${firstChild.javaClass.name}", + "Parsed node should be a BlockQuote node, but was $firstChild", firstChild is BlockQuote, ) } diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownCatalog.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownCatalog.kt index 0e6453c72..90f005973 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownCatalog.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/MarkdownCatalog.kt @@ -757,7 +757,7 @@ Markdown: Syntax * [Philosophy](#philosophy) * [Inline HTML](#html) * [Automatic Escaping for Special Characters](#autoescape) -* [Block Elements](#block) +* [MarkdownBlock Elements](#block) * [Paragraphs and Line Breaks](#p) * [Headers](#header) * [Blockquotes](#blockquote) @@ -921,7 +921,7 @@ and `&` in your example code needs to be escaped.) * * * -

Block Elements

+

MarkdownBlock Elements

Paragraphs and Line Breaks