ozh / ascii-tables Goto Github PK
View Code? Open in Web Editor NEW⚡ Quickly format table in ASCII. Great for code comments, or Github Markdown!
Home Page: https://ozh.github.io/ascii-tables/
⚡ Quickly format table in ASCII. Great for code comments, or Github Markdown!
Home Page: https://ozh.github.io/ascii-tables/
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.
Support for Restructured Text Grid tables:
http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#grid-tables
e.g. my data is CSV but I want some values to be able to have commas in them
Please add the option to choose any character as separator, not limiting the input to lists formatted with tabs and spaces anymore.
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.
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 !
Can the support be added to list tables as they are easiest to edit text & move cells around
Source:
https://docutils.sourceforge.io/docs/ref/rst/directives.html#toc-entry-23
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.
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.
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
|
|
|
|}
When I click the create table button, if there is an error during the parsing an alert opens, once you close it the contents of the Input disappear. Means you have to start again instead of just correcting issue
||heading 1||heading 2||heading 3||
|col A1|col A2|col A3|
|col B1|col B2|col B3|
Reference: https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=tables
It would be a nice enhancement to align numbers to the right.
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 |
+----------+----------+-----------+
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.
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.
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.
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.
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).
Hi, you should consider packaging this as an NPM package so people can use it in their JS projects.
If I paste some table data to the website: https://ozh.github.io/ascii-tables/
Is any data stored or transmitted anywhere?
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?
As the title says. This makes rST processor to mark the table in a special way (looks like a code block?), rather than just add it to the output as is.
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.
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:
<option value="pipe">"|" Pipe</option>
to the #commenting
select element.case
statement in script.js
: case "pipe":
prefix = "|";
suffix = "|";
break;
I've confirmed this creates valid tables in Reddit posts.
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.
Sometimes it is kinda hard getting a tab key. (there's shortcuts like ctrl-opt-tab
on mac, but I bet most people don't know these)
very handy webpage, BTW! Thanks
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.
Would be nice to add Javadoc comment style: prefix with "* "
:
/**
* +---------+---------+------+
* | Col1 | Col2 | Col3 |
* +---------+---------+------+
* | Value 1 | Value 2 | 123 |
* | Value 3 | Value 4 | 789 |
* +---------+---------+------+
*/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.