Reputation: 507
I try to put some source code into a table using asciidoc. For whatever reason, I do not manage to put it well formated into a cell.
This is my test I use at https://asciidoclive.com for testing:
.The working version of the code (outside table)
....
/* define the types we need for the struct */
typedef void* (*open)();
typedef void (*updateNumber)(void*, int);
typedef void (*updateLabel)(void*, const char*);
typedef void (*close)(void*);
....
.Not working inside of a table
[options="header"]
|=======================
|function |getProperty
|example 1
|
....
/* define the types we need for the struct */
typedef void* (*open)();
typedef void (*updateNumber)(void*, int);
typedef void (*updateLabel)(void*, const char*);
typedef void (*close)(void*);
....
|example 2
|
`/* define the types we need for the struct */
typedef void* (*open)();
typedef void (*updateNumber)(void*, int);
typedef void (*updateLabel)(void*, const char*);
typedef void (*close)(void*);`
|=======================
I wanted to show more things I tried, but StackOverflow does not let me put in more code :-(
I tried with ++++, ----, .... and backticks. While the first three do not work at all, backticks are working somehow but do not work properly with the *pointers and interprets it as bold sometimes.
How can I solve this?
Upvotes: 0
Views: 361
Reputation: 507
Finally, I found it by fortune. The cell must be defined to render asciidoc content. Otherwise it only renders as reduced function set (only basic stuff working).
.Working inside of a table
[options="header", cols="1,4"]
|=======================
|function |getProperty
|example 1
a|
[source,C]
....
/* define the types we need for the struct */
typedef void* (*open)();
typedef void (*updateNumber)(void*, int);
typedef void (*updateLabel)(void*, const char*);
typedef void (*close)(void*);
....
|example 2
a|
[source,C]
----
/* define the types we need for the struct */
typedef void* (*open)();
typedef void (*updateNumber)(void*, int);
typedef void (*updateLabel)(void*, const char*);
typedef void (*close)(void*);
----
|=======================
Please note the a| instead of a simple | symbol used.
This is the page where it is explained in a good manner:
https://blog.mrhaki.com/2014/11/awesome-asciidoctor-styling-columns-and.html
Upvotes: 1