user1053031
user1053031

Reputation: 747

Asciidoc. How to display complex regex correctly in a table cell

I need to display some complex regular expression "as-is", i.e. w/o any modifications. Of course i can modify this regex to make asciidoc engine render it as needed for me, but are there more convenient ways to do that? Are there any ways to tell asciidoc to just display some string? W/o any modifications?

Thanks in advance.

Upvotes: 1

Views: 396

Answers (1)

jackrabbit
jackrabbit

Reputation: 5663

Looking at the parser, Asciidoctor first finds cell delimiters and only then looks inside the cells. This means that even marking your cell as literal will not allow you to avoid escaping the |. The only alternative processing is for CSV table content, but then you will have to escape any , appearing in the regex.

My 2 most successful attempts were:

  • using a literal block (note the escaped \|):

    [cols="1a,1"]
    |===
    |....
    a\|b
    ....
    |done
    |===
    

    or

    [cols="1l,1"]
    |===
    |a\|b
    |done
    |===
    
  • using CSV content:

    ,===
    a|b,done
    ,===
    

The advantage of the literal block is that it prevents the regex from being interpreted somehow by the backend.

Upvotes: 2

Related Questions