txtToWeb
is a command-line tool for converting text files to HTML content. It allows you to easily generate HTML files from plain text documents with optional features like specifying a CSS stylesheet.
- Convert text and Markdown files to valid HTML5 documents.
- Automatically detect titles and format content into paragraphs.
- Parse Markdown syntax for Italics and convert it to HTML.
- Optionally include a CSS stylesheet in the HTML output.
- Process individual files or entire directories of text files.
- bash/zsh/wsl Terminal
- Python
- Clone this repository to your local machine:
git clone https://github.com/your-username/txtToWeb.git
- Navigate to the txtToWeb directory:
cd txtToWeb
- Make it executable
chmod +x txtToWeb.py
To convert a single text file to HTML:
./txtToWeb.py <filename>
To add a stylesheet to the file:
./txtToWeb.py -s https://example.com/style.css <filename>
To convert all .txt and .md files in a directory:
txtToWeb.py /path/to/directory
To convert all .txt and .md files in a directory and include a CSS stylesheet:
./txtToWeb.py -s https://example.com/style.css /path/to/directory
To use TOML config:
txtToWeb.py -c /path/to/config /path/to/directory or file
--version
or-v
: Display the tool's version.--stylesheet
or-s
: Specify a URL to a CSS stylesheet to include in the HTML files.--help
or-h
: Display usage information and available flags.--config
or-c
: URL to a TOML config file to be used as a config for the HTML files.
As of the latest update, txtToWeb
has incorporated support for converting Markdown .md
files in addition to plain text files. This introduces the capability to parse specific Markdown syntax and convert it to valid HTML5 format, allowing for enhanced content structuring and formatting.
The initial release of Markdown support focuses on the Italic syntax. Users can now write text in Italics in their Markdown files, and txtToWeb
will correctly convert it into HTML. The Italic text can be written by wrapping the desired text segment with either single asterisks *
or single underscores _
.
stylesheet = "../examples/txtToWeb/styles.css"
lang = "en-US"
Markdown Input:
This is an _italic_ example.
And this is another _italic_ example.
Generated HTML Output:
<p>This is an <i>italic</i> example.</p>
<p>And this is another <i>italic</i> example.</p>
By default, the tool generates HTML files in a txtToWeb directory in the current working directory. Each HTML file corresponds to a processed text file, with the original filename.
Command:
./txtToWeb.py -s https://cdnjs.cloudflare.com/ajax/libs/tufte-css/1.8.0/tufte.min.css test.txt
Sample Input: test.txt
Output: test.html
Output Hosted: https://txttoweb.netlify.app/
This project is licensed under the GNU General Public License v3.0 License - see the LICENSE file for details.