Quantcast

C source code with a comment inside a table

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

C source code with a comment inside a table

andyandy
Hi,
I used a table to print side by side two C functions.
The functions have a one line comment : // blabla
I noticed that that line is interpreted as Asciidoctor comment
and it is removed form the source code.

For example in the following example,
in the html output  the comment in preserved only for the 3th C function.

Is it a bug or I am not using the table properly ?

Thank you.

// ======== begin =======

[%autowidth.auto,options="auto,header", cols="a,a"]
|===
^| Test1 ^| Test2

|
[source,c]
----
int fun1()
{
// ... comment 1
  return 1;
// ...
}
----

|
[source,c]
----
int fun2()
{
// ... comment 2
  return 2;
// ...
}
----
|===

[source,c]
----
int fun3()
{
// ... comment 3
  return 3;
// ...
}
----

// ======== end  =======
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: C source code with a comment inside a table

mojavelinux
Administrator
You aren't doing anything wrong. Asciidoctor currently removes all line comments before processing the content of the table. I recognize this behavior is not consistent with AsciiDoc Python. However, knowing when to remove the line comments and when not is tricky. We'll need to open an issue to explore possible solutions.

Until then, you have a few workarounds:

1) Put at least one space at the start of the comment line (since an AsciiDoc comment line must start at the left column)
2) Use three forward slashes (AsciiDoc does not allow a comment line to start with exactly three forward slashes)
3) Use an attribute reference instead of a forward slash and add the subs=attributes+ to the source listing to expand

I think (2) is the most elegant:

[source,c]
----
int fun1()
{
/// ... comment 1
  return 1;
/// ...
}
----

Cheers,

-Dan

On Thu, Mar 16, 2017 at 9:59 AM, andyandy [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi,
I used a table to print side by side two C functions.
The functions have a one line comment : // blabla
I noticed that that line is interpreted as Asciidoctor comment
and it is removed form the source code.

For example in the following example,
in the html output  the comment in preserved only for the 3th C function.

Is it a bug or I am not using the table properly ?

Thank you.

// ======== begin =======

[%autowidth.auto,options="auto,header", cols="a,a"]
|===
^| Test1 ^| Test2

|
[source,c]
----
int fun1()
{
// ... comment 1
  return 1;
// ...
}
----

|
[source,c]
----
int fun2()
{
// ... comment 2
  return 2;
// ...
}
----
|===

[source,c]
----
int fun3()
{
// ... comment 3
  return 3;
// ...
}
----

// ======== end  =======


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/C-source-code-with-a-comment-inside-a-table-tp5389.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Loading...