Skip to content

In markdown tables, | should be escaped to | or the table will be collapsed. not only nl2br #686

@shellyln

Description

@shellyln

What happened

When I put a value containing | in the extra_def of column, the table is collapsed.

What you expected to happened

Expect | to be escaped and not treated as a special character in the table.

What stack trace or error message from tbls did you see?

Anything else we need to know?

Environment

  • tbls version
    • 1.85.0
  • Database version
    • json DSN
  • OS ( Ubuntu bionic, macOS Calalina, WSL2, etc )
    • Windows 11
  • Shell ( bash, zsh, poworshell, etc )
    • poworshell
  • Stacktrace or error message from tbls ( If you can, set DEBUG=1)
  • Config ( .tbls.yml )
dsn: json://schema.json

docPath: doc/schema

format:
  # Adjust the column width of Markdown format table
  # Default is false
  adjust: false
  # Sort the order of table list and columns
  # Default is false
  sort: true
  # Display sequential numbers in table rows
  # Default is false
  number: false
  # The comments for each table in the Tables section of the index page will display the text up to the first double newline (first paragraph).
  # Default is false
  showOnlyFirstParagraph: false
  # Hide table columns without values
  # Default is false
  hideColumnsWithoutValues: false
  # It can be boolean or array
  # hideColumnsWithoutValues: ["Parents", "Children"]

er:
  # Skip generation of ER diagram
  # Default is false
  skip: false
  # ER diagram image format (`png`, `jpg`, `svg`, `mermaid`)
  # Default is `svg`
  format: mermaid
  # Add table/column comment to ER diagram
  # Default is false
  comment: false
  # Hide relation definition from ER diagram
  # Default is false
  hideDef: false
  # Show column settings in ER diagram. If this section is not set, all columns will be displayed (default).
  showColumnTypes:
    # Show related columns
    related: true
    # Show primary key columns
    primary: true
  # Distance between tables that display relations in the ER
  # Default is 1
  distance: 2
  # ER diagram (png/jpg) font (font name, font file, font path or keyword)
  # Default is "" (system default)
  font:

schema.json

{
    "tables": [
        {
            "name": "Foo",
            "type": "table",
            "comment": "Foo",
            "columns": [
                {
                    "name": "Id",
                    "type": "Id",
                    "nullable": false,
                    "comment": "Id"
                },
                {
                    "name": "AAA",
                    "type": "Text",
                    "nullable": false,
                    "default": "\"A\"",
                    "extra_def": "01234|56789|abcde|fghij",
                    "comment": "Comment of AAA"
                },
                {
                    "name": "BBB",
                    "type": "Text",
                    "nullable": false,
                    "default": "\"B\"",
                    "extra_def": "01234|56789|abcde|fghij",
                    "comment": "Comment of BBB"
                }
            ]
        }
    ],
    "driver": {
        "name": "",
        "database_version": ""
    }
}

result markdown

## Columns

| Name | Type | Default | Nullable | Extra Definition | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | ---------------- | -------- | ------- | ------- |
| AAA | Text | "A" | false | 01234|56789|abcde|fghij |  |  | Comment of AAA |
| BBB | Text | "B" | false | 01234|56789|abcde|fghij |  |  | Comment of BBB |
| Id | Id |  | false |  |  |  | Id |

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions