Asciidoctor-pdf: Source code blocks are rendered without indentation in versions 1.5.0.beta.3 and 1.5.0.beta.4

Created on 5 Sep 2019  路  5Comments  路  Source: asciidoctor/asciidoctor-pdf

Source code blocks, such as this one:

[source,c]
----
int main() {
    lsp_event_loop();
    return 0;
}

void lsp_event_loop(void) {
    for(;;) {
        unsigned long content_length = lsp_parse_header(); //<1>
        cJSON *request = lsp_parse_content(content_length); //<2>
        json_rpc(request); //<3>
        cJSON_Delete(request); //<4>
    }
}
----

are rendered without indentation.

This is the rendered output:
image

It worked fine with 1.5.0.beta.2 and earlier versions, but is broken in 1.5.0.beta.3 and 1.5.0.beta.4.

My document is available in this repository, so you can take a look at it as an example. It can be compiled with make command.

bug compliance

All 5 comments

It looks like the tab processing broke. Sigh. It has been a game of whack-a-mole to get this logic stabilized. I'll take a look. It just means we need more tests.

Can you tell me which version of Asciidoctor core you're using?

asciidoctor -v

(That matters since Asciidoctor PDF uses Asciidoctor).

Thank you for the quick response.
Sure, version is:

Asciidoctor 2.0.10 [https://asciidoctor.org]
Runtime Environment (ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-linux]) (lc:UTF-8 fs:UTF-8 in:UTF-8 ex:UTF-8)

I think it is a problem with asciidoctor-pdf specifically, because I downgraded to 1.5.0.beta.2 without touching Asciidoctor core and it started indenting again.

As a workaround, you can set the tabsize attribute on the document, which activates the same logic as before.

= Document Title
:tabsize: 4

content here

(You could also set it from the API or CLI).

Yes, I know the problem is with Asciidoctor PDF. I had made the assumption that core always replaces tabs, but that's not always true. And tabs must always be replaced in the PDF since PDF doesn't support tabs.

Was this page helpful?
0 / 5 - 0 ratings