diff --git a/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Data.kt b/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Data.kt index 86912a7d..e0deb188 100644 --- a/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Data.kt +++ b/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Data.kt @@ -21,7 +21,7 @@ import kotlin.io.path.Path */ val Data: Module = setOf( - ::fileContent, + ::read, ::csv, ) @@ -59,8 +59,7 @@ internal fun file( * If not specified or infinite, the whole file is read * @return a string value of the text extracted from the file */ -@Name("filecontent") -fun fileContent( +fun read( @Injected context: Context, path: String, @Name("lines") lineRange: Range = Range.INFINITE, diff --git a/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Text.kt b/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Text.kt index 12a0f968..c5825c7a 100644 --- a/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Text.kt +++ b/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Text.kt @@ -53,7 +53,7 @@ fun text( /** * Creates a code block. Contrary to its standard Markdown implementation with backtick/tilde fences, * this function accepts Markdown content as its body, hence it can be used - for example - - * in combination with [fileContent] to load code from file. + * in combination with [read] to load code from file. * @param language optional language of the code * @param showLineNumbers whether to show line numbers * @param body code content diff --git a/stdlib/src/test/kotlin/eu/iamgio/quarkdown/stdlib/DataTest.kt b/stdlib/src/test/kotlin/eu/iamgio/quarkdown/stdlib/DataTest.kt index fe190bb5..f6aa67c1 100644 --- a/stdlib/src/test/kotlin/eu/iamgio/quarkdown/stdlib/DataTest.kt +++ b/stdlib/src/test/kotlin/eu/iamgio/quarkdown/stdlib/DataTest.kt @@ -36,22 +36,22 @@ class DataTest { assertEquals( "Line 1${LINE_SEPARATOR}Line 2${LINE_SEPARATOR}${LINE_SEPARATOR}Line 4${LINE_SEPARATOR}Line 5", - fileContent(context, path).unwrappedValue, + read(context, path).unwrappedValue, ) assertEquals( "Line 2${LINE_SEPARATOR}${LINE_SEPARATOR}Line 4", - fileContent(context, path, Range(2, 4)).unwrappedValue, + read(context, path, Range(2, 4)).unwrappedValue, ) assertEquals( "Line 1${LINE_SEPARATOR}Line 2", - fileContent(context, path, Range(null, 2)).unwrappedValue, + read(context, path, Range(null, 2)).unwrappedValue, ) assertEquals( "Line 4${LINE_SEPARATOR}Line 5", - fileContent(context, path, Range(4, null)).unwrappedValue, + read(context, path, Range(4, null)).unwrappedValue, ) } 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 51b462cf..89f41ca0 100644 --- a/test/src/test/kotlin/eu/iamgio/quarkdown/test/FullPipelineTest.kt +++ b/test/src/test/kotlin/eu/iamgio/quarkdown/test/FullPipelineTest.kt @@ -155,7 +155,7 @@ class FullPipelineTest { assertEquals("
result: 11
", it) } - execute(".code\n .filecontent {code.txt}") { + execute(".code\n .read {code.txt}") { assertEquals( "Line 1${System.lineSeparator()}Line 2${System.lineSeparator()}${System.lineSeparator()}Line 3
",
it,