Giter Club home page Giter Club logo

ascii-tables's Introduction

ascii-tables

Quickly format tables in ASCII. Great for code comments, or Github Markdown!

Play with it: https://ozh.github.io/ascii-tables/

Input text like this

Col1	Col2	Col3	Numeric Column
Value 1	Value 2	123	10.0
Separate	cols    with a tab or 4 spaces	-2,027.1
This is a row with only one cell

Press Create Table to get something like:

ASCII table (mysql style)

+----------------------------------+---------+------------------------+----------------+
|               Col1               |  Col2   |          Col3          | Numeric Column |
+----------------------------------+---------+------------------------+----------------+
| Value 1                          | Value 2 | 123                    |           10.0 |
| Separate                         | cols    | with a tab or 4 spaces |       -2,027.1 |
| This is a row with only one cell |         |                        |                |
+----------------------------------+---------+------------------------+----------------+

ASCII table (separated style)

+==================================+=========+========================+================+
|               Col1               |  Col2   |          Col3          | Numeric Column |
+==================================+=========+========================+================+
| Value 1                          | Value 2 | 123                    |           10.0 |
+----------------------------------+---------+------------------------+----------------+
| Separate                         | cols    | with a tab or 4 spaces |       -2,027.1 |
+----------------------------------+---------+------------------------+----------------+
| This is a row with only one cell |         |                        |                |
+----------------------------------+---------+------------------------+----------------+

ASCII table (compact style)

                Col1                  Col2              Col3            Numeric Column  
 ---------------------------------- --------- ------------------------ ---------------- 
  Value 1                            Value 2   123                                10.0  
  Separate                           cols      with a tab or 4 spaces         -2,027.1  
  This is a row with only one cell                                                      

ASCII table (Github Markdown style)

|               Col1               |  Col2   |          Col3          | Numeric Column |
|----------------------------------|---------|------------------------|----------------|
| Value 1                          | Value 2 | 123                    |           10.0 |
| Separate                         | cols    | with a tab or 4 spaces |       -2,027.1 |
| This is a row with only one cell |         |                        |                |

ASCII table (Reddit Markdown style)

               Col1               |  Col2   |          Col3          | Numeric Column 
----------------------------------|---------|------------------------|----------------
 Value 1                          | Value 2 | 123                    |           10.0 
 Separate                         | cols    | with a tab or 4 spaces |       -2,027.1 
 This is a row with only one cell |         |                        |                

ASCII table (reStructuredText Grid style)

+----------------------------------+---------+------------------------+----------------+
|               Col1               |  Col2   |          Col3          | Numeric Column |
+==================================+=========+========================+================+
| Value 1                          | Value 2 | 123                    |           10.0 |
| Separate                         | cols    | with a tab or 4 spaces |       -2,027.1 |
| This is a row with only one cell |         |                        |                |
+----------------------------------+---------+------------------------+----------------+

ASCII table (reStructuredText Simple style)

 ================================== ========= ======================== ================ 
                Col1                  Col2              Col3            Numeric Column  
 ================================== ========= ======================== ================ 
  Value 1                            Value 2   123                                10.0  
  Separate                           cols      with a tab or 4 spaces         -2,027.1  
  This is a row with only one cell                                                      
 ================================== ========= ======================== ================ 

ASCII table (Jira style)

|| Col1                             || Col2    || Col3                   || Numeric Column ||
|  Value 1                          |  Value 2 |  123                    |  10.0           | 
|  Separate                         |  cols    |  with a tab or 4 spaces |  -2,027.1       | 
|  This is a row with only one cell |          |                         |                 | 

ASCII table (rounded style)

.----------------------------------.---------.------------------------.----------------.
|               Col1               |  Col2   |          Col3          | Numeric Column |
:----------------------------------+---------+------------------------+----------------:
| Value 1                          | Value 2 | 123                    |           10.0 |
:----------------------------------+---------+------------------------+----------------:
| Separate                         | cols    | with a tab or 4 spaces |       -2,027.1 |
:----------------------------------+---------+------------------------+----------------:
| This is a row with only one cell |         |                        |                |
'----------------------------------'---------'------------------------'----------------'

ASCII table (bubbles style)

 o88888888888888888888888888888888888(_)888888888(_)888888888888888888888888(_)88888888888888888o 
(_)               Col1               (_)  Col2   (_)          Col3          (_) Numeric Column (_)
(888888888888888888888888888888888888(_)888888888(_)888888888888888888888888(_)888888888888888888)
(_) Value 1                          (_) Value 2 (_) 123                    (_)           10.0 (_)
(_) Separate                         (_) cols    (_) with a tab or 4 spaces (_)       -2,027.1 (_)
(_) This is a row with only one cell (_)         (_)                        (_)                (_)
 O8oooooooooooooooooooooooooooooooooo(_)ooooooooo(_)oooooooooooooooooooooooo(_)oooooooooooooooo8O 

ASCII table (girder style)

//==================================[]=========[]========================[]================\\
||               Col1               ||  Col2   ||          Col3          || Numeric Column ||
|]==================================[]=========[]========================[]================[|
|| Value 1                          || Value 2 || 123                    ||           10.0 ||
|| Separate                         || cols    || with a tab or 4 spaces ||       -2,027.1 ||
|| This is a row with only one cell ||         ||                        ||                ||
\\==================================[]=========[]========================[]================//

ASCII table (dots style)

........................................................................................
:               Col1               :  Col2   :          Col3          : Numeric Column :
:..................................:.........:........................:................:
: Value 1                          : Value 2 : 123                    :           10.0 :
: Separate                         : cols    : with a tab or 4 spaces :       -2,027.1 :
: This is a row with only one cell :         :                        :                :
:..................................:.........:........................:................:

Unicode table

╔══════════════════════════════════╦═════════╦════════════════════════╦════════════════╗
║               Col1               ║  Col2   ║          Col3          ║ Numeric Column ║
╠══════════════════════════════════╬═════════╬════════════════════════╬════════════════╣
║ Value 1                          ║ Value 2 ║ 123                    ║           10.0 ║
║ Separate                         ║ cols    ║ with a tab or 4 spaces ║       -2,027.1 ║
║ This is a row with only one cell ║         ║                        ║                ║
╚══════════════════════════════════╩═════════╩════════════════════════╩════════════════╝

Unicode (single line) table

┌──────────────────────────────────┬─────────┬────────────────────────┬────────────────┐
│               Col1               │  Col2   │          Col3          │ Numeric Column │
├──────────────────────────────────┼─────────┼────────────────────────┼────────────────┤
│ Value 1                          │ Value 2 │ 123                    │           10.0 │
│ Separate                         │ cols    │ with a tab or 4 spaces │       -2,027.1 │
│ This is a row with only one cell │         │                        │                │
└──────────────────────────────────┴─────────┴────────────────────────┴────────────────┘

Github Markdown table

|               Col1               |  Col2   |          Col3          | Numeric Column |
|----------------------------------|---------|------------------------|----------------|
| Value 1                          | Value 2 | 123                    |           10.0 |
| Separate                         | cols    | with a tab or 4 spaces |       -2,027.1 |
| This is a row with only one cell |         |                        |                |

Jira table

||             Col1               ||  Col2  ||          Col3         || Numeric Column ||
| Value 1                          | Value 2 | 123                    |           10.0 |
| Separate                         | cols    | with a tab or 4 spaces |       -2,027.1 |
| This is a row with only one cell |         |                        |                |

MediaWiki markup

{| class="wikitable"

! Col1
! Col2
! Col3
! Numeric Column
|-

| Value 1
| Value 2
| 123
| 10.0
|-

| Separate
| cols
| with a tab or 4 spaces
| -2,027.1
|-

| This is a row with only one cell
|
|
|
|}

Or even a boring html <table>

Leading characters can be added by selecting a comment style:

Style Characters Usage
none "" no comment style applied
doubleslant "// " C++/C#/F#/Java/JavaScript/Rust/Swift
hash "# " Perl/PowerShell/Python/R/Ruby
doubledash "-- " ada/AppleScript/Haskell/Lua/SQL
percent "% " MATLAB
singlespace " " (1 space) MediaWiki
quadspace "    " (4 spaces) reddit
singlequote "' " (single quote) VBA
rem "REM " BASIC/DOS batch file
c "C " Fortran IV
exclamation "! " Fortran 90
slantsplat "/* ... */ " CSS
xml "<!-- ... -->" XML

License

WTFPL. Do whatever the hell you want with it.

ascii-tables's People

Contributors

andrewlane avatar dwesely avatar enterprisey avatar everlastingbugstopper avatar gwenaelpellenarkeup avatar ishu3101 avatar nekno avatar ozh avatar t1ml3arn avatar thurstonzd avatar tuoris avatar waldyrious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ascii-tables's Issues

Reddit : add Pipe "|" to comment style drop-down.

To better support tables in Reddit-style markdown, it would be ideal to allow a table to begin and end with a pipe character. As noted in Reddit's Markdown Guide:

Tip: Tables can be written without the row-leading and -ending pipe (|) characters, but the result can be surprising when the parser has to guess whether the row is a table row or something else. Leading and trailing pipes make it explicit you are writing a table.

While a more "correct" method might be to add an option to the Output Style drop-down, I think an easier fix would be to use the Comment Style drop-down:

  • Add <option value="pipe">"|" Pipe</option> to the #commenting select element.
  • Add the following case statement in script.js:
    case "pipe":
        prefix = "|";
        suffix = "|";
        break;

I've confirmed this creates valid tables in Reddit posts.

Add documentation for non JS users

Hi, I'd like to integrate your module in the next version of asciio.

Could you write down how to install the needed environment and how to generate bales from the command line?

I can manage that of course but I think it would be a good addition for other non JS developers that like what you are doing and want to use it.

Bad parse Github Markdown

Input

Col1	Col2	Col3	Numeric Column
Value 1	Value 2	123	10.0
Separate	cols	with a tab or 4 spaces	-2,027.1
This is a row with only one cell			
new row	1		
new row 2			
new row 3			
new row 4			
new row 5

clic on "Create" button
result is

|               Col1               |  Col2   |          Col3          | Numeric Column |
|----------------------------------|---------|------------------------|----------------|
| Value 1                          | Value 2 | 123                    |           10.0 |
| Separate                         | cols    | with a tab or 4 spaces |       -2,027.1 |
| This is a row with only one cell |         |                        |                |
| new row                          | 1       |                        |                |
| new row 2                        |         |                        |                |
| new row 3                        |         |                        |                |
| new row 4                        |         |                        |                |
| new row 5                        |         |                        |                |

clic on "Parse" button
result is

Col1	Col2	Col3	Numeric Column
Value 1	Value 2	123	10.0
Separate	cols	with a tab or 4 spaces	-2,027.1
This is a row with only one cell			
new row	1		
new row 2			
new row 3			
new row 4			
new row 5			

It's OK

Now ...

Input:

Col1	Col2	Col3	Numeric Column
Value 1	Value 2	123	10.0
Separate	cols	with a tab or 4 spaces	-2,027.1
This is a row with only one cell			
new row	1		
new row 2			
new row 3			
new row 4			
new row 5			
new row 6	
new row 7	

clic on "Create" button
result :

|               Col1               |  Col2   |          Col3          | Numeric Column |
|----------------------------------|---------|------------------------|----------------|
| Value 1                          | Value 2 | 123                    |           10.0 |
| Separate                         | cols    | with a tab or 4 spaces |       -2,027.1 |
| This is a row with only one cell |         |                        |                |
| new row                          | 1       |                        |                |
| new row 2                        |         |                        |                |
| new row 3                        |         |                        |                |
| new row 4                        |         |                        |                |
| new row 5                        |         |                        |                |
| new row 6                        |         |                        |                |
| new row 7                        |         |                        |                |


clic on "Parse" button
result :

new row 2			
Col1	Col2	Col3	Numeric Column
Separate	cols	with a tab or 4 spaces	-2,027.1
This is a row with only one cell			
new row	1		
Value 1	Value 2	123	10.0
new row 3			
new row 4			
new row 5			
new row 6			
new row 7			

It's WRONG !

https in README

the link in README point to http site and it show error about not being secure, github pages don't do automatic redirect to https.

Feature: provide option for stripping double quotes around (CSV) field values

First things first: Great tool, thank you for providing it for free.

Sometimes, CSV data is produced in which fields are all categorically double-quoted.
For instance, PowerShell's Export-Csv and ConvertTo-Csv cmdlets produce such data; e.g.:

"Col1","Col2","Col3"
"Col1Val1","Col2Val1","Col3Val1"
"Col1Val2","Col2Val2","Col3Val2"
"Col1Val3","Col2Val3","Col3Val3"
"Col1Val4","Col2Val4","Col3Val4"
"Col1Val5","Col2Val5","Col3,Val5"

It would be great if there were an option to strip these double quotes, so they don't show up in the output table.

In that context, quoting-aware parsing would be helpful, as any embedded , chars. (in double-quoted fields) aren't currently recognized as such (see last column of last row) which relates to #47.

Thus, instead of:

+------------+------------+------------+-------+
|   "Col1"   |   "Col2"   |   "Col3"   |       |
+------------+------------+------------+-------+
| "Col1Val1" | "Col2Val1" | "Col3Val1" |       |
| "Col1Val2" | "Col2Val2" | "Col3Val2" |       |
| "Col1Val3" | "Col2Val3" | "Col3Val3" |       |
| "Col1Val4" | "Col2Val4" | "Col3Val4" |       |
| "Col1Val5" | "Col2Val5" | "Col3      | Val5" |
+------------+------------+------------+-------+

It would be great to have:


+----------+----------+-----------+
|   Col1   |   Col2   |   Col3    |
+----------+----------+-----------+
| Col1Val1 | Col2Val1 | Col3Val1  |
| Col1Val2 | Col2Val2 | Col3Val2  |
| Col1Val3 | Col2Val3 | Col3Val3  |
| Col1Val4 | Col2Val4 | Col3Val4  |
| Col1Val5 | Col2Val5 | Col3,Val5 |
+----------+----------+-----------+

Feature suggestion: Monospace

Your ascii-tables tool is SO AWESOME!

I've never seen anything quite like it. I love it.

I don't know whether this would be interesting to you, but a feature that I'd personally love and would use would be the ability to output a monospaced table that would look good when pasting into a Facebook post.

I've been trying to use your tool plus sites like http://slothsoft.net/UnicodeMapper/?lang=en-us and http://qaz.wtf/u/convert.cgi but haven't quite figured it out yet.

It looks like the hyphens and spaces lose their monospacing.

But I bet it's possible.

Any ideas?

Feature: allow an option to set width of the column

I am using this as a plugin on my website to prepare the table layout for the description. There's a need to be displayed as a table and I can't control the width of any column.

There's no way to implement it either.
I feel it will be great to have this as a feature.

No option for left, center, right

I would like an option to make the values on either the left side of the column, the right side of the column, or the center of the column.

Feature Request: change input format

I like that you can change the output format to any number of tables but I would like to convert one table to another using this tool.

I think that an Input Style dropdown would be perfect.

Artist's rendition

input style

idea: merge and centre text

Similar to the Excel function. Or even just merge the cells to have categories and what not.

So I can do something like this:

 ╔══════════════════════════════╗
 ║         Windows 10           ║
 ╠════════════╦═════════════════╣
 ║      OU    ║  Computer Name  ║
 ╠════════════╬═════════════════╣
 ║ xx-zzz     ║ JSMITH-LT       ║
 ║ xx-zzz     ║ JSMITH-DT       ║
 ║ yy-aaa     ║ JDOE-LT2        ║
 ║ zz-bbb     ║ HSIMPSON-DT     ║
 ╠════════════╩═════════════════╣
 ║         Windows 7            ║
 ╠════════════╦═════════════════╣
 ║ xx-zzz     ║ xx-zzz-eng1     ║
 ║ zz-bbb     ║ nflanders-lt    ║
 ╚════════════╩═════════════════╝

With a way to set justification either on the merge or any of the cells, left, right, centre, (full?), would be ideal too.

Parse back from output doesn't work if comment is present

I think that parsing this

// ┌────┬───────┬───────┐
// │    │  OBJ  │  COM  │
// ├────┼───────┼───────┤
// │  1 │ S1    │ S1    │
// │ 12 │ S1+S2 │ S1+S2 │
// └────┴───────┴───────┘

should work if i set "Unicode (single line)" as output style and "C++/C#" as comment style.

some character display problem

image

as the image shows, when i append some chinese characters to the header's last column, the table can't align normally

Headerless tables don't work in GitHub Markdown output

GitHub Markdown does not support headerless tables. When the "Header location = None" is selected, the resulting table is

| lorem    | ipsum | dolor       |
| sit      | amet  | consectitur |
| adipisci | elit  |             |

which results in this:

| lorem | ipsum | dolor |
| sit | amet | consectitur |
| adipisci | elit | |

Instead, it should be:

|          |       |             |
|----------|-------|-------------|
| lorem    | ipsum | dolor       |
| sit      | amet  | consectitur |
| adipisci | elit  |             |

which results in:

lorem ipsum dolor
sit amet consectitur
adipisci elit

See mixmark-io/turndown-plugin-gfm#10 and https://stackoverflow.com/questions/17536216/create-a-table-without-a-header-in-markdown for similar discussions elsewhere (with the same suggested wokaround).

Idea: line prefix

To make it easy to generate comments, even indented, offer an input for a prefix that appears on every line, e.g. "⎵⎵⎵⎵#⎵" would be a four-space indented Python comment.

NPM Package

Hi, you should consider packaging this as an NPM package so people can use it in their JS projects.

Idea: Re-parse table

When somebody uses the output of the table generator and edits that, it would be nice to re-generate the layout. So for instance:

+-------+-------+
| Hello | Table |
+=======+=======+
| Someone changed | this table manually |
+-------+-------+

Can may be re-parsed to:

+-----------------+---------------------+
| Hello           | Table               |
+=================+=====================+
| Someone changed | this table manually |
+-----------------+---------------------+

This would be a cool feature that http://www.tablesgenerator.com/text_tables lacks.

Make cell output multiline

Hi,

Great tool you have here and I have used it multiple time to send formatted table to my customer. They love that the data is properly formatted in cells.

I have several instances where the string in one cell is too long, and if I copy and paste the generated table as it is to email, it will wrap and ruined the table format.

I wish you could add line break command, for example "\n" or other, than will break the long line into multiple line.

This will help me format the cell so that the total length will fit common size, eg 78 character, and will not causing wrapping when pasted to email.

Thanks.

Comment style: Javadoc

Would be nice to add Javadoc comment style: prefix with "* ":

/**
 * +---------+---------+------+
 * |  Col1   |  Col2   | Col3 |
 * +---------+---------+------+
 * | Value 1 | Value 2 |  123 |
 * | Value 3 | Value 4 |  789 |
 * +---------+---------+------+
 */

Library on NPM

This is nice library did you though about creating it as JavaScript library with nice API so you can actually write tables in browser and Node.js.

Is this Open Source? Maybe you should pick a license like MIT or it's All right reserved?

I can help with creating a library with your code if you need help.

Cannot "parse" wikimedia

Summary

If you load up the default input, by refreshing the page, and switch your output style to wikimedia and hit "parse" on the output, you'll get an error prompt. When you hit "OK" your input goes blank but your output remains. Switching the output style afterwards will also not affect the input nor the output.

Investigation

Current default input (with correct tabs):

Col1    Col2    Col3    Numeric Column
Value 1 Value 2 123 10.0
Separate    cols    with a tab or 4 spaces  -2,027.1
This is a row with only one cell

Current wikitable output of above input:

{| class="wikitable"

! Col1                             
! Col2    
! Col3                   
! Numeric Column 
|-

| Value 1                          
| Value 2 
| 123                    
| 10.0           
|-

| Separate                         
| cols    
| with a tab or 4 spaces 
| -2,027.1       
|-

| This is a row with only one cell 
|         
|                        
|                
|}

Prompt
ascii-tables-error-prompt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.