Oskar
Oskar

Reputation: 482

ASCII doc - display special characters in table column

I would place the following regexp: ^(?!\s)[^0-9!#|$^`\\~_%&\"'(){}*+,./:;<=>?@\]\[]*(?<!\s)$ in the ASCII doc table.

Example Ascii doc:

[%autowidth]
|===
|Path|Type|Validation|Rule|Description

| type
| String
| Required
| <here I would like to place it>
|Placeholder

|===

I tried many ways to handle that but with no results. I used for e.g."

But all of this methods use special characters that are also in my regex. Do you have an idea how can I display any string using Ascii doc functionalities?

Upvotes: 0

Views: 67

Answers (2)

eskwayrd
eskwayrd

Reputation: 4521

Do you want the regex to look like regular prose? If so, place it directly in the table markup and escape select markup characters with a backslash:

| \^(?!\s)[^0-9!#\|$^`\\~_%&\"'(){}*+,./:;<=>?@\]\[]*(?<!\s)$

Here, the initial caret is escaped to prevent superscript, and the pipe is escaped to prevent introducing a new table cell.

If you want the regex to show as inline monospace, do the same thing but surround the regex with unconstrained inline monospace markup "``":

| ``\^(?!\s)[^0-9!#\|$^`\\~_%&\"'(){}*+,./:;<=>?@\]\[]*(?<!\s)$``

Using HTML entities is another choice that can work, but makes the content harder to maintain.

AsciiDoc has a feature called Literal Monospace that would be the correct solution if your regex does not contain a plus symbol. Since there is a plus, it doesn't work like you expect.

The pass::[] macro could be used, but escaping the regex is harder.

Upvotes: 1

Stas Simonov
Stas Simonov

Reputation: 582

Just convert your line to the HTML codes:

&#x5e;&#x28;&#x3f;&#x21;&#x5c;&#x73;&#x29;&#x5b;&#x5e;&#x30;&#x2d;&#x39;&#x21;&#x23;&#x7c;&#x24;&#x5e;&#x60;&#x5c;&#x5c;&#x7e;&#x5f;&#x25;&#x26;&#x5c;&#x22;&#x27;&#x28;&#x29;&#x7b;&#x7d;&#x2a;&#x2b;&#x2c;&#x2e;&#x2f;&#x3a;&#x3b;&#x3c;&#x3d;&#x3e;&#x3f;&#x40;&#x5c;&#x5d;&#x5c;&#x5b;&#x5d;&#x2a;&#x28;&#x3f;&#x3c;&#x21;&#x5c;&#x73;&#x29;&#x24;

It works with Ascii doc version 2.0.10

Upvotes: 2

Related Questions