Create a Table with Highlighted Source Code in Asciidoc
I Would Like to Highlight Some of My Code in Tables. I Tried Many Ways but I Could Get It Fixed. I Would Appreciate If Someone Can Help Me. 1 Answer Great...
I would like to highlight some of my code in tables. I tried many ways but I could get it fixed.
I would appreciate if someone can help me.
1 Answer
great question!
Most AsciiDoc syntax is not rendered inside a table, only basic syntax like *bold*.
You have to explicitly tell Asciidoctor to render the whole feature set.
There are two ways to do so:
1) prepend the character a to the | of the cell where you want Asciidoctor to render the full syntax
2) configure a whole column to be rendered as AsciiDoc by stating your wish in front of the table: [cols="a,a"] will render a AsciiDoc in both columns of a two column table.
here is a gist to demonstrate this:
docs can be found here:
Examples:
|====
|Col1 | Col2
| even complex formattings like source code highlighting works this way
a|
[source, groovy]
----
5.times {
println it
}
----
|====
[cols="a,a"]
|====
|Col1 | Col2
| even complex formattings like source code highlighting works this way
|
[source, groovy]
----
5.times {
println it
}
----
|====
See the gist for a rendering of these examples