qjebbs / vscode-markdown-extended

Extended syntaxes to built-in markdown & What you see is what you get exporter.
MIT License
123 stars 25 forks source link

Preserve table indentation and handle code spans #139

Closed rbolsius closed 1 year ago

rbolsius commented 2 years ago

This pull request fixes both issues from #138.

  1. The indentation of the first line of the table is preserved and applied to all the subsequent lines in the table.
  2. Code spans inside of tables are parsed correctly so that pipe characters occurring inside of code spans will not be treated as column delimiters.
rbolsius commented 2 years ago

Here is a demonstration of the table formatting before the fix:

table-formatting-test-before

And after the fix:

table-formatting-test-after

Here is the original Markdown used as the test case:

# Table Formatting Test Cases

## Table Without Leading Column Delimiters

one | two
-:|
1 |
12 | abc \| def
123 | abc `|` def
1234 | ``double | ` backtick``
12345 | ```triple | `` backtick```

## Table with Leading Column Delimiters

| one | two
| -:|
| 1 |
| 12 | abc \| def
| 123 | abc `|` def
| 1234 | ``double | ` backtick``
| 12345 | ```triple | `` backtick```

## Indented Tables

1.  Indented table without leading column delimiters:

    one | two
    -:|
    1 |
    12 | abc \| def
    123 | abc `|` def
    1234 | ``double | ` backtick``
    12345 | ```triple | `` backtick```

2.  Indented table with leading column delimiters:

    | one | two
    | -:|
    | 1 |
    | 12 | abc \| def
    | 123 | abc `|` def
    | 1234 | ``double | ` backtick``
    | 12345 | ```triple | `` backtick```
qjebbs commented 1 year ago

Thanks!