开发者

How to markup ascii-art tables automatically?

开发者 https://www.devze.com 2023-04-05 00:57 出处:网络
I have a plain text file with tables: http://uucode.com/tmp/20110913/vim-index.txt (or type \":help index\" in vim)

I have a plain text file with tables:

http://uucode.com/tmp/20110913/vim-index.txt

(or type ":help index" in vim)

I want to convert the table into a computer-friendly form. For example, into HTML or into Excel.

Any suggestion how to make it auto开发者_开发知识库matically? Maybe some lightweight markup tool can recognize such tables? Or probably there are some research papers with useful algorithms?


The plugin "vimwiki : Personal Wiki for Vim" ( http://www.vim.org/scripts/script.php?script_id=2226 ) defines a table syntax for its wiki pages:

 | Year | Temperature (low) | Temperature (high) |
 |------+-------------------+--------------------|
 | 1900 | -10               | 25                 |
 | 1910 | -15               | 30                 |
 | 1920 | -10               | 32                 |
 | 1930 | _N/A_             | _N/A_              |
 | 1940 | -2                | 40                 |
>

In HTML the following part >
 | Year | Temperature (low) | Temperature (high) |
 |------+-------------------+--------------------|
>
is higlighted as a table header.

And it provides a command to convert from text to html:

*:Vimwiki2HTML*
    Convert current wiki page to HTML.

Maybe you could use some regular expressions to convert your tables to this format, and then use this plugin to convert it to HTML.

0

精彩评论

暂无评论...
验证码 换一张
取 消