Search code examples
text-formattingasciidocasciidoctor

Asciidoc formatting options for semi-tabular data


I have a query regarding how to layout some semi-tabular data in Asciidoc.

The verbatim Asciidoc I currently have is this, including some framing regular text from the surrounding narrative (it's from a section about Java GC, using a very simplified case study):

The heap parameters are set up as shown, and we assume that they do not change over time. 
Of course a real application would normally have a dynamically resizing heap, but this 
example is to illustrate a simple case study.

----
Overall heap size:   2G

Old generation:    1.5G

Young generation:  500M
        Eden:      400M
        S1:         50M
        S2:         50M
----

After the application has reached its steady state, the following GC metrics 
are observed:

----
Allocation rate: 100M/s
Young GC time:      0ms
Full GC time:     100ms
Object lifetime:  200ms
----

So at steady state, a young GC will occur every 4 seconds.

My question is this: Is this the only way to lay this out? What other methods are there? I am a reasonably proficient Asciidoc user, but keep stumbling upon new features, which makes me think that perhaps there is an alternative layout approach I could take.


Solution

  • If you want to format your data in a nice way, you can format the data as table. Specify 'delimiter separated' (dsv) as format and you will get a nice looking table.

    In addition, you can specify the separator to make sure that only the : is used as such (second example):

    The heap parameters are set up as shown, and we assume that they do not change over time. 
    Of course a real application would normally have a dynamically resizing heap, but this 
    example is to illustrate a simple case study.
    
    [format="dsv"]
    |====
    Overall heap size:   2G
    
    Old generation:    1.5G
    
    Young generation:  500M
            Eden:      400M
            S1:         50M
            S2:         50M
    |====
    
    After the application has reached its steady state, the following GC metrics 
    are observed:
    
    [format="dsv",separator=":"]
    |====
    Allocation rate: 100M/s
    Young GC time:      0ms
    Full GC time:     100ms
    Object lifetime:  200ms
    |====
    
    So at steady state, a young GC will occur every 4 seconds.
    

    This lets you also specify alignment, width and other cell attributes in the properties of the table: http://www.methods.co.nz/asciidoc/chunked/ch23.html

    Is this what you where looking for?