Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsciiDoc table prettifier #1396

Open
Andronovss opened this issue Jul 13, 2023 · 3 comments
Open

AsciiDoc table prettifier #1396

Andronovss opened this issue Jul 13, 2023 · 3 comments

Comments

@Andronovss
Copy link

Andronovss commented Jul 13, 2023

Why the new feature should be added

Very often, tables in adoc don't look too good for visual presentation, especially after converting from other formats. Also, we need to format tables in a more readable way for humans. Now, we have to align the table elements manually.
It would be great to have the same functionality to control tables visually as the MarkdownTablePrettify-VSCodeExt plugin has.

How the new feature should work

We have two tables as examples in this case:

.beforeFormate
|===
|Header 1 |Header 2 |Header 3

|Column 1, row 1 |Column 2, row 1     |Column 3, row 1

|Column 1, row 2   |Column 2, row 2 |Column 3, row 2

   |Column 1, row 3  |Column 2, row 3     |Column 3, row 3
|===

and

.afterFormate
|===
|Header 1        |Header 2        |Header 3

|Column 1, row 1 |Column 2, row 1 |Column 3, row 1

|Column 1, row 2 |Column 2, row 2 |Column 3, row 2

|Column 1, row 3 |Column 2, row 3 |Column 3, row 3
|===

I saw the post asciidoctor/atom-language-asciidoc#140 and even agree in some ways. After two days of researching, I could not find an acceptable algorithm for bypassing tables precisely because of the table customization options in adoc.

Perhaps, we should restrict the usage of the table formatting and limit ourselves to the simple option.

@mojavelinux
Copy link
Member

The practice of putting multiple table cells on the same line is considered an anti-pattern in the AsciiDoc ecosystem, largely for this reason. AsciiDoc allows each cell to be placed on its own line, similar to the style of a list. I would dislike seeing an IDE encouraging the use of spaces to align columns in the table source. It makes the document harder to edit and encourages the busy work of aligning cells in a column. I would much prefer the IDE rearrange cells horizontally, with an empty line to separate rows.

See https://docs.asciidoctor.org/asciidoc/latest/tables/add-cells-and-rows/#consecutive and

@Andronovss
Copy link
Author

Dan, I totally agree with you on all points.

My version of the new feature is rather a very rare case when we get an adoc file from another format such as docx.
That's when we have to do table formatting for better human readability.

@Andronovss
Copy link
Author

Wrote a script in python that formats the simplest of tables.

https://github.com/Andronovss/asciidocTablePrettify/tree/master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants