@@ -59,15 +59,15 @@ class CodeBlocksTest : BaseAbstractTest() {
59
59
// where XXX=language of code block
60
60
assertEquals(
61
61
""" test("hello kotlin")""" ,
62
- content.getElementsByClass(" lang-kotlin" ).singleOrNull()?.text ()
62
+ content.getElementsByClass(" lang-kotlin" ).singleOrNull()?.wholeText ()
63
63
)
64
64
assertEquals(
65
65
""" test("hello custom")""" ,
66
- content.getElementsByClass(" lang-custom" ).singleOrNull()?.text ()
66
+ content.getElementsByClass(" lang-custom" ).singleOrNull()?.wholeText ()
67
67
)
68
68
assertEquals(
69
69
""" test("hello other")""" ,
70
- content.getElementsByClass(" lang-other" ).singleOrNull()?.text ()
70
+ content.getElementsByClass(" lang-other" ).singleOrNull()?.wholeText ()
71
71
)
72
72
}
73
73
@@ -99,15 +99,15 @@ class CodeBlocksTest : BaseAbstractTest() {
99
99
val content = renderedContent(" root/test/test.html" )
100
100
assertEquals(
101
101
""" test("hello kotlin")""" ,
102
- content.getElementsByClass(" lang-kotlin" ).singleOrNull()?.text ()
102
+ content.getElementsByClass(" lang-kotlin" ).singleOrNull()?.wholeText ()
103
103
)
104
104
assertEquals(
105
105
""" test("hello custom")""" ,
106
- content.getElementsByClass(" custom-language-block" ).singleOrNull()?.text ()
106
+ content.getElementsByClass(" custom-language-block" ).singleOrNull()?.wholeText ()
107
107
)
108
108
assertEquals(
109
109
""" test("hello other")""" ,
110
- content.getElementsByClass(" lang-other" ).singleOrNull()?.text ()
110
+ content.getElementsByClass(" lang-other" ).singleOrNull()?.wholeText ()
111
111
)
112
112
}
113
113
@@ -139,15 +139,73 @@ class CodeBlocksTest : BaseAbstractTest() {
139
139
val content = renderedContent(" root/test/test.html" )
140
140
assertEquals(
141
141
""" test("hello kotlin")""" ,
142
- content.getElementsByClass(" lang-kotlin" ).singleOrNull()?.text ()
142
+ content.getElementsByClass(" lang-kotlin" ).singleOrNull()?.wholeText ()
143
143
)
144
144
assertEquals(
145
145
""" test("hello custom")""" ,
146
- content.getElementsByClass(" custom-language-block" ).singleOrNull()?.text ()
146
+ content.getElementsByClass(" custom-language-block" ).singleOrNull()?.wholeText ()
147
147
)
148
148
assertEquals(
149
149
""" test("hello other")""" ,
150
- content.getElementsByClass(" other-language-block" ).singleOrNull()?.text()
150
+ content.getElementsByClass(" other-language-block" ).singleOrNull()?.wholeText()
151
+ )
152
+ }
153
+
154
+ @Test
155
+ fun `multiline code block rendering with linebreaks` () = testCode(
156
+ """
157
+ /src/test.kt
158
+ package test
159
+
160
+ /**
161
+ * Hello, world!
162
+ *
163
+ * ```kotlin
164
+ * // something before linebreak
165
+ *
166
+ * test("hello kotlin")
167
+ * ```
168
+ *
169
+ * ```custom
170
+ * // something before linebreak
171
+ *
172
+ * test("hello custom")
173
+ * ```
174
+ *
175
+ * ```other
176
+ * // something before linebreak
177
+ *
178
+ * test("hello other")
179
+ * ```
180
+ */
181
+ fun test(string: String) {}
182
+ """ .trimIndent(),
183
+ listOf (CustomPlugin (applyOtherRenderer = false )) // we add only one custom renderer
184
+ ) {
185
+ val content = renderedContent(" root/test/test.html" )
186
+ assertEquals(
187
+ """
188
+ // something before linebreak
189
+
190
+ test("hello kotlin")
191
+ """ .trimIndent(),
192
+ content.getElementsByClass(" lang-kotlin" ).singleOrNull()?.wholeText()
193
+ )
194
+ assertEquals(
195
+ """
196
+ // something before linebreak
197
+
198
+ test("hello custom")
199
+ """ .trimIndent(),
200
+ content.getElementsByClass(" custom-language-block" ).singleOrNull()?.wholeText()
201
+ )
202
+ assertEquals(
203
+ """
204
+ // something before linebreak
205
+
206
+ test("hello other")
207
+ """ .trimIndent(),
208
+ content.getElementsByClass(" lang-other" ).singleOrNull()?.wholeText()
151
209
)
152
210
}
153
211
@@ -165,7 +223,7 @@ class CodeBlocksTest : BaseAbstractTest() {
165
223
}
166
224
167
225
private object CustomHtmlBlockRenderer : HtmlCodeBlockRenderer {
168
- override fun isApplicable (language : String , code : String ): Boolean = language == " custom"
226
+ override fun isApplicable (language : String ): Boolean = language == " custom"
169
227
170
228
override fun FlowContent.buildCodeBlock (language : String , code : String ) {
171
229
div(" custom-language-block" ) {
@@ -175,7 +233,7 @@ class CodeBlocksTest : BaseAbstractTest() {
175
233
}
176
234
177
235
private object CustomOtherHtmlBlockRenderer : HtmlCodeBlockRenderer {
178
- override fun isApplicable (language : String , code : String ): Boolean = language == " other"
236
+ override fun isApplicable (language : String ): Boolean = language == " other"
179
237
180
238
override fun FlowContent.buildCodeBlock (language : String , code : String ) {
181
239
div(" other-language-block" ) {
0 commit comments