To convert the provided HTML table to plain text using html2text
and then format it into a plain text table using Emacs, follow these steps:
html2text
Assuming you have html2text
installed, you can run the following command in your terminal:
html2text t1.html
This will output the plain text version of the HTML table:
First week of treatment Second week of treatment Third week of treatment Group 1 12.80±0.46212 18.52±0.76c 34.39±1.032a Control Group 2 12.52±0.28196 23.05±0.51b 35.59±0.77a Group 3 15.30±0.27750 28.19±0.60a 36±0.83a
Open the plain text output in Emacs.
Use Emacs' table mode to format the text into a table. You can do this by selecting the text and running the command M-x table-capture
. This will prompt you to specify the number of columns and rows.
Here’s how the final plain text table might look after formatting in Emacs:
+---------+----------------------+----------------------+----------------------+ | | First week of | Second week of | Third week of | | | treatment | treatment | treatment | +---------+----------------------+----------------------+----------------------+ | Group 1 | 12.80±0.46212 | 18.52±0.76c | 34.39±1.032a | +---------+----------------------+----------------------+----------------------+ | Control | | | | +---------+----------------------+----------------------+----------------------+ | Group 2 | 12.52±0.28196 | 23.05±0.51b | 35.59±0.77a | +---------+----------------------+----------------------+----------------------+ | Group 3 | 15.30±0.27750 | 28.19±0.60a | 36±0.83a | +---------+----------------------+----------------------+----------------------+
This table is now formatted in a way that is easy to read and aligns the columns properly.
When using Emacs' table-capture
function, it will prompt you for a column delimiter regexp. This regexp is used to identify how columns are separated in your plain text data.
In your case, since the plain text output from html2text
uses spaces to separate columns, you can use a regexp that matches one or more spaces as the column delimiter. The appropriate regexp for this is:
\\s-+
\\s-
matches any whitespace character (spaces, tabs, etc.).
+
means "one or more" of the preceding element (in this case, one or more whitespace characters).
Open the plain text output in Emacs.
Select the text you want to convert into a table.
Run M-x table-capture
.
When prompted for the column delimiter regexp, enter:
\\s-+
Emacs will then automatically format the selected text into a table based on the spaces as column delimiters.
If your plain text looks like this:
Group 1 12.80±0.46212 18.52±0.76c 34.39±1.032a Control Group 2 12.52±0.28196 23.05±0.51b 35.59±0.77a Group 3 15.30±0.27750 28.19±0.60a 36±0.83a
After running table-capture
with the regexp \\s-+
, Emacs will format it into a proper table:
+---------+----------------+----------------+----------------+ | Group 1 | 12.80±0.46212 | 18.52±0.76c | 34.39±1.032a | +---------+----------------+----------------+----------------+ | Control | | | | +---------+----------------+----------------+----------------+ | Group 2 | 12.52±0.28196 | 23.05±0.51b | 35.59±0.77a | +---------+----------------+----------------+----------------+ | Group 3 | 15.30±0.27750 | 28.19±0.60a | 36±0.83a | +---------+----------------+----------------+----------------+
This should work perfectly for your data! Let me know if you need further clarification.
The server is busy. Please try again later.