turicas / rows

A common, beautiful interface to tabular data, no matter the format
GNU Lesser General Public License v3.0
865 stars 136 forks source link

Txt line break #322

Open jsbueno opened 5 years ago

jsbueno commented 5 years ago

This PR fixes the immediate issues exposed at https://gist.github.com/turicas/8bd86dd425d2212dbe214d725121be7c?fbclid=IwAR1VitQE02l7OiCjCKDsdYTJJ9-mC53xlFOD2yhWoxZyCPWrjqchl7H7CPo

That is - any cell containing a line-feed character breaks the text-plugin output.

Besides creating multiline cells in the text output, the code also includes a "blank" line bellow any row having a multi-line cell, so that contents are visually separateted.

Not covered by this code: Parsing back text-tables with multi-line cells. (I invite the discussion of what features would be better to enable that in this very same PR - although merging it as is will be mostly harmless - the output of the text plug-in is supposed to be pretty, but it is a dangerous road to ensure data integrity round-trip between its output and back - multi-line cells will complicate a lot the current logic)

jsbueno commented 5 years ago

"before :"

+-----------------------+----------------------------------+
|          nome         |             endereco             |
+-----------------------+----------------------------------+
|         José da Silva | Rua dos Bobos, 0
Cidade Fantasma |
| José Maria
(Zé Maria) |                       R. XPTO, 1 |
+-----------------------+----------------------------------+

"after" :

+---------------+------------------+
|      nome     |     endereco     |
+---------------+------------------+
| José da Silva | Rua dos Bobos, 0 |
|               |  Cidade Fantasma |
|               |                  |
|    José Maria |       R. XPTO, 1 |
|    (Zé Maria) |                  |
+---------------+------------------+