Code Samples
AsciiDoc supports code samples using the [source] attribute before a new block. If you specify the coding language, the sample will be highlighted correctly in HTML output. Unlike other blocks in Asciidoc, line breaks and space indentations are preserved. Have a look at the example:
.Sample Code <1>
[source,ruby] <2>
==== <3>
puts "Hello, world." <4>
%w{a b c}.each do |x|
puts x
end
==== <5>Practice time
:exercise-file: exercise-2-3-6 include::exercises.adoc[tags=intro;exercise-2-3-6]
We’re done with blocks - good job! The next lesson covers inline markup.
+++ <div class="cta tutorial"><a class="button" href="/learn/lessons/lesson-2-4/">Start next lesson »</a></div> ++++