Git Product home page Git Product logo

ascii-table-parser's Introduction

ASCII Table Parser

Parse ASCII tables and get something new, like an HTML table!

ascii-table-parser's People

Contributors

towerofnix avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

ascii-table-parser's Issues

Multiline begin/end regexes

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: ' '

Relative line number

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.

Move join to lines.join

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.

Inclusive line range

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.

Multiline match + join lines

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

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.