asciidocasciidoctor

Trim whitespace in included sourcecode snippet


Is there any way to trim the beginning indentation white spaces in a included source code snippet?


Solution

  • Yes, you need to use the indent attribute in your include directive, see Indent included content. If you include code from a snippet.src file, it will look something like this:

    include::snippet.src[indent=0]
    

    or

    [source,indent=0]
    ----
    include::snippet.src[]
    ----