Tabbed code blocks

This page demonstrates @asciidoctor/tabs in Antora: use tabs for multiple languages, or to separate exercise instructions from solutions.

Language tabs

  • Java

  • Python

public class Hello {
  public static void main(String[] args) {
    System.out.println("Hello");
  }
}
def main():
    print("Hello")

if __name__ == "__main__":
    main()

Exercise and solution

  • Exercise

  • Solution

Try writing a function that returns the sum of two integers. Use your language’s usual entry point if you need a quick test.

function add(a, b) {
  return a + b;
}
console.log(add(2, 3));