diff --git a/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Ecosystem.kt b/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Ecosystem.kt index ab1f86e6..ca9b0e8e 100644 --- a/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Ecosystem.kt +++ b/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Ecosystem.kt @@ -30,6 +30,8 @@ fun include( // Read file content val file = file(context, path) val raw = "\n" + file.readText() + // The initial line break is a workaround for an issue that may cause blocks at the beginning of the file + // to be not recognized as blocks - which happens in transitive inclusions (aka a nested .include called from an included file). // Evaluate the Quarkdown source. // This automatically converts the source into a value (e.g. a node, a string, a number, etc.) diff --git a/test/src/test/kotlin/eu/iamgio/quarkdown/test/FullPipelineTest.kt b/test/src/test/kotlin/eu/iamgio/quarkdown/test/FullPipelineTest.kt index 82f1ccb8..5f0a260c 100644 --- a/test/src/test/kotlin/eu/iamgio/quarkdown/test/FullPipelineTest.kt +++ b/test/src/test/kotlin/eu/iamgio/quarkdown/test/FullPipelineTest.kt @@ -556,5 +556,17 @@ class FullPipelineTest { it, ) } + + // Included file used as a value. + execute( + """ + .sum {.include {include/include-6.md}} {3} + """.trimIndent(), + ) { + assertEquals( + "

8

", + it, + ) + } } } diff --git a/test/src/test/resources/data/include/include-6.md b/test/src/test/resources/data/include/include-6.md new file mode 100644 index 00000000..5ef16ae1 --- /dev/null +++ b/test/src/test/resources/data/include/include-6.md @@ -0,0 +1,4 @@ +.function {mynumber} + .sum {3} {2} + +.mynumber \ No newline at end of file