I'm very glad my tool txt2html has finally published. In this blog post, I'll introduce you the project as well as its key features, usage, and examples of how to use it.
The project
The txt2html project aims to streamline the conversion of plain text files into elegant HTML documents. At present, it operates as a command-line tool that seamlessly performs the transformation.
Key Features
Processing
User can convert text file directly or specify a folder as input, and it will process all the text files within that folder.User-Defined Output Path (v0.1.1)
With version 0.1.1, txt2html introduced the ability for users to specify their desired output path. This feature making it more convenient to organize your converted content.Title Generation from Input File Content (v0.1.2)
In version 0.1.2, It can now automatically generate a title for your HTML document based on the content of the input file. If a title exists, it will be extracted from the first line which followed by two blank lines, and automatically added with the <h1>...</h1> to the top of the body in the generated HTML document.
How to Use
Before running, make sure you have Python3 installed. You can get the code from the repository, and also set it be executable for convenience.
Generate HTML from a Single Text File:
./txt2html.py input_file.txt
Generate HTML from All Text Files in a Folder:
./txt2html.py folder-name
Here are the all flags and their meaning:
Command | Description |
---|---|
-h, --help | Displays the help message |
-v, --version | Displays the version of the tool |
-o, --output | Specify the output directory. Existing output folder will first be removed. If not specified, "./txt2html" will be used. |
Examples
The tool includes examples along with their corresponding outputs. You can see what it looks like on the GitHub Page.
(Note that the example files were generated by utilizing the -o option)
./txt2html.py examples/test-folder -o examples/test-folder-output
Feel free to give it a try and share your brilliant ideas with me!
Top comments (0)