1. Include Source Code

A collapsed list
  1. a

  2. b

  3. c

Source Code File
public class FileRenamer {
...
    private static void renameFiles() {
        try (Stream<Path> walk = Files.walk(Paths.get(DIRECTORY + File.separator + "styles"))) {
            walk
                    .filter(Files::isRegularFile)
                    .forEach(file -> {
                        String fileName = file.getFileName().toString();
                        String newFileName =
                                fileName.substring(0, fileName.length() - 4)
                                        + ".min"
                                        + fileName.substring(fileName.length() - 4);
                        // tag::rename-file[]
                        try {
                            Files.move(file, (1)
                                    file.getParent().resolve(newFileName)); (2)
                        } catch (IOException e) {
                            System.err.println(e.getMessage());
                        }
                        // end::rename-file[]
                    });
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
...
}

[source, java]
.Java code from project
----
include::src/main/java/at/htl/asciidoc/FileRenamer.java[tag=rename-file,indent=0]
----

2. Line Numbering the source code

[source,java,linenums]

3. Highlight Source Code

4. Line-Numbering + Highlighting

[source,java,linenums,highlight=4..5]

5. Images

With the backend attribute, it is possible to control the output:

  • In the pdf the image is full-size

  • in the slides and html the image is 50% sized

ifdef::backend-html5,backend-revealjs[image:animal-pet-cute-kitten-45201.jpg[width=50%]]
ifdef::backend-pdf[image:animal-pet-cute-kitten-45201.jpg[]]
Cute kitten (credits to pixabay)

animal pet cute kitten 45201

6. Diagrams

[plantuml,bsp,png]

@startuml
class A
class B
A -left-> B
@enduml
bsp