Update Including Code snippets authored by Armin Bernstetter's avatar Armin Bernstetter
For different code highlighting see also the meta-option [`highlightjs`](https://gitlab2.informatik.uni-wuerzburg.de/decker/decker/-/wikis/Custom-Meta-Options#highlightjs)
# Code include
# Add a label to a code block
The following syntax will add a label to the top right of a code block.
````
```{.haskell label="Haskell"}
-- your code here ...
```
````
# Include an entire file
````
```{.haskell style="font-size:xx-small" include="IncludeCode.hs"}
```
````
---
# Include just a range
````
``` {.haskell include="IncludeCode.hs" label="Haskell" startLine="130" endLine="140"}
```
````
---
# Include snippets
You can use this feature to mark snippets in your source code files which you want to include.
Instead of `--` (Haskell comment syntax) use the comment syntax of the respective language you want to include.
### Option A
``` {.txt style="font-size:medium"}
-- start snippet snippet-tagA
CODE
-- end snippet snippet-tagA
```
### Option B
```
-- 8< snippet-tagB
CODE
-- >8
```
---
# Example A
### Source file
```
// start snippet snippet-tagA
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello, World");
}
// end snippet snippet-tagA
```
### Markdown
````markdown
``` {.java include="HelloWorld.java" label="Java" snippet="snippet-tagA"}
```
````
---
# Example B
### In source file
```
-- 8< snippet-tagB
isSnippetEnd :: Text -> Bool -> Text -> Bool
isSnippetEnd name emptyEnd line =
isSnippetTag "end snippet" name line ||
isSnippetTag ">8" name line ||
isUnnamedSnippetTag ">8" line || (emptyEnd && Text.null (Text.strip line))
-- >8
```
### Markdown
````
``` {.haskell include="IncludeCode.hs" label="Haskell" snippet="snippet-tagB"}
```
````
\ No newline at end of file