vimwiki-backup / vimwiki

Automatically exported from code.google.com/p/vimwiki
1 stars 1 forks source link

cell alingment #226

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

in the changelog of 0.9.1 I find this entry:

NEW: HTML Table cell text alignment, see :h vimwiki-syntax-tables 

I'm using vimwiki 1.2. If I look up the documentation I can't find a hint how 
to align cells. I need to align a column to the right.

Any hint appreciated.

And please keep up the great work!
Volker

Original issue reported on code.google.com by volker.d...@gmx.de on 4 Jul 2011 at 7:37

GoogleCodeExporter commented 9 years ago
As far as I remember cell alignments was removed from vimwiki tables due to 
table autoformatting. We should introduce new syntax for cell alignments.

For example:

| left aligned | right aligned | centered cell |
|--------------+---------------+---------------|
| #l hello     | #r world      | #c !!!        |

Any thoughts?

Original comment by habamax on 4 Jul 2011 at 11:29

GoogleCodeExporter commented 9 years ago
I would prefer  http://michelf.com/projects/php-markdown/extra/#table

| left aligned | right aligned | centered cell |
|:-------------|--------------:|:-------------:|
| hello        | world         | !!!           |

Original comment by stu.andrews on 12 Jul 2011 at 11:14

GoogleCodeExporter commented 9 years ago
I guess it is for column, isn't it? We should implement it too.

What about individual cells?

Original comment by habamax on 13 Jul 2011 at 11:34

GoogleCodeExporter commented 9 years ago
Alignment for individual cells is a secondary issue at best, and people should 
be discouraged to use anything else but column alignments (and styling), 
despite the fact that it does not work reliably in browsers and may have to be 
pushed to individual cells during conversion to HTML.

By far the best is to separate all the styling and presentation from the 
content of cells. Do not even consider putting cell alignment directives inside 
table cells, that is a terrible idea (example: countless wikis...)

The above suggestion is not too bad by wiki standards, but what if 
* I do not want the horizontal line after the header (I assume it is implied 
there)?
* the table has no header, or has both header and footer, or ... ?
* I need the first column in bold, the second in "inline code"?

Good design example (those are not easy to come by): 
http://www.methods.co.nz/asciidoc/newtables.html
Those tables are also quite general in allowing most markup inside, but I am 
putting it here as an example of good separation of content and presentation 
details: all "configuration" is usually one short line (unfortunately, they 
also fell for the individual cell overrides stuck inside a little later on, but 
I do not think people use it much).

For vimwiki, something like this would fit nicely:

{{|%configuration
| cell 1 |   ...       | cell n |

||| multicell 1-3 | ...| cell n |
| cell 1 |   ...       | cell n |
}}|

It can be modified to allow block environments inside cells (forget about 
aligning it on screen, of course, these would be general tables, not toy 
examples). I am not going to elaborate on it here. A real table also ought to 
have a caption.

Different groups of rows are simply separated by empty lines (simple -----* as 
separator not too bad either, but anything more complicated than that is a 
mistake). The configuration then determines how it gets presented: 

* style: you want a nice open table, or framed one, or you insist on overriding 
a decent default and making it a "prison window" style table etc.
* column specification: the second important bit, specifies alignment and 
column style
* header/footer: the first group is a "header", for instance

Some "configuration" examples from asciidoc:
- [width="40%",frame="topbot",options="header,footer"]
- [width="50%",cols=">s,^2m,^2e",frame="topbot",options="header,footer"]
  (> means right align, ^ center, s "strong", m "monospaced", e "emph")
- [width="80%",cols="3,^2,^2,10",options="header"]
  (digits specify relative widths for columns)
- [cols="h,4*",options="header",grid="all",align="center"]
  (first column "header", then four "default" columns, prison window grid, center alignment for the entire table)

They do not seem to have a way of specifying column groups (which could be 
denoted by ; in column list, for instance), but overall it is pretty simple yet 
reasonably general.

Another example, LaTeX style column specification 
http://en.wikibooks.org/wiki/LaTeX/Tables
- {l*{6}{c}r}   (left aligned column, then six center aligned, then one right 
aligned)
- {|l|l|}     (two left aligned cols, vertical lines everywhere)  

Original comment by tpospi...@gmail.com on 31 Jan 2012 at 7:19

GoogleCodeExporter commented 9 years ago
I've attached a patch to auto-formatting table correctly when using the syntax 
mention by #2.
Although Vimwiki isn't support these syntax yet, Markdown was supported.
So this patch still worth to apply, I think.

I am not familiar with Vim, Please let me know if I make anything wrong.
Thank you.

Original comment by themacropodus@gmail.com on 16 Feb 2013 at 4:10

Attachments:

GoogleCodeExporter commented 9 years ago
The above patch is incorrect when the column is center align and len=3.
Upload the new version of patch.

Original comment by themacropodus@gmail.com on 18 Feb 2013 at 1:55

Attachments:

GoogleCodeExporter commented 9 years ago
Thx!

There should be html stuff implemented too.

I'll have a look into it.

Original comment by habamax on 18 Feb 2013 at 4:06

GoogleCodeExporter commented 9 years ago
I could not see an option for table/column/cell alignment in version 2.1.
I personally find convenient to have cells right aligned, especially for 
numbers.

Here is a quick patch built on top of the patch from comment #6. It does not 
fit the design considerations from comment #4, but I find it useful and will 
use it until there are better integrated options. Logging the patch here as I 
found this bug when looking for that option and other people may find it helpful

Here is an example result:

| left      | middle | right     |
|:----------|:------:|----------:|
| a         |   x    |         3 |
| ab        |  -x-   |        23 |
| abc       | --x--  |       123 |
|:---------:|--------|-----------|
| separator | lines  | set       |
| alignment | for    | following |
|   lines   | -x-    | 23        |
|    abc    | --x--  | 123       |

Original comment by alexandr...@gmail.com on 2 Jan 2014 at 12:46

Attachments: