Parse ASCII tables and get something new, like an HTML table!
towerofnix / ascii-table-parser Goto Github PK
View Code? Open in Web Editor NEWSmall utility for tables. Experiment by changing the files in tables/.
License: MIT License
Small utility for tables. Experiment by changing the files in tables/.
License: MIT License
Following #1 - what if the description has a varied amount of lines?
For example, given these two tables:
+-----------------------------+
| Slime |
+-----------------------------+
| Slimes are amazing. I don't |
| know what you mean when you |
| say that they're furry, |
| though. |
+-----------------------------+
+-----------------------------+
| Ratattack |
+-----------------------------+
| Now THESE are furry! |
+-----------------------------+
How can we match the description of both of these?
I'd probably go with something like this:
tableSplit: "\n\n"
getData:
description:
match: '\|\s(.+?(?=\s+\|))'
group: 1
lines:
begin: 3
end:
regex: '\+-----------------------------\+'
join: ' '
In this example:
/----- Hello world! -----\
| This is just an |
| example. I'm working |
| on it :) |
+------------------------+
\-- CODE: 42 --/
/----- INTERMISSION -----\
| Quick reminder that |
| the codes are fake! |
+------------------------+
\-- CODE: 123 --/
..how can we get the CODE
?
We know it comes after the description, and we're already matching that, so maybe we should just make the line number relative to the previous match?
getData:
description: # ...
code:
line: +1
lineRelativeToPrevious: true # <----
regex: 'CODE:\s+([0-9]+)\s+'
group: 1
PS it would be relative to the end of the previous match.
Following #1. Just move join
to lines.join
:
lines:
begin: 1
end: 2
join: ' '
# will be changed to
lines:
begin: 1
end: 2
join: ' '
Because join
will only apply when there are multiple lines for a match.
Following #2 - If the begin and/or end is a regex, how can we get the things that are only between those lines?
Should be simple enough:
lines:
begin: # begin regex
end: # end regex
inclusive: false
lines.inclusive should be true by default.
How can we get the description text out of this?
+-----------------------------+
| Slime |
+-----------------------------+
| Slimes are amazing. I don't |
| know what you mean when you |
| say that they're furry, |
| though. |
+-----------------------------+
I think something like this might do well:
match: # regex to get text inbetween lines
group: # ^^
lines: # lines to use match/group on
begin: 4 # slimes are amazing..
end: 7 # ..though
join: ' ' # join each line by spaces
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.