Skip to content

A simple a command-line tool for authoring "Today I Learned" posts in Markdown, which can be converted to HTML

License

Notifications You must be signed in to change notification settings

Vishnudas2003/Text2Page

Repository files navigation

Text2page

Text2page is a Python command-line tool that simplifies the process of converting plain text files (.txt) and markdown (.md) into well-structured HTML documents. It intelligently parses your text, identifies paragraphs, and generates valid HTML5 files, making it easy to turn your text-based content into web-ready pages.

Table of Contents

Installation

Before using Text2page, make sure you have Python 3 installed on your system. You can download Python from the official website.

Prerequisites

Before using Text2page, make sure you have Python 3 installed on your system. You can download Python from the official website.

Getting Started

  1. Clone the Repository:

    git clone https://github.com/Vishnudas2003/Text2Page.git
    
  2. Navigate to the project directory

    cd text2page
    
  3. Create a folder named textFiles in the project directory and place your .txt files inside it. This is where your input files will be located.

Usage

Basic Usage

To convert a single .txt file to HTML, use the following command:

python text2page.py /path/to/your/file.txt

Replace /path/to/your/file.txt with the actual path to your .txt file. To convert all .txt files within a directory, use:

python text2page.py /path/to/your/directory

This command will process all .txt files within the specified directory.

Markdown Feature

Text2page includes support for Markdown. It can convert Markdown (.md) files to HTML. Simply provide a Markdown file as input, and Text2page will generate an HTML file with the same content.

python text2page.py /path/to/your/file.md

Replace /path/to/your/file.md with the actual path to your .md file.

Specifying Output Directory

By default, Text2page will create an output directory named til in the project directory. You can specify a different output directory using the --output or -o flag. For example:

python text2page.py /path/to/your/directory -o /path/to/output

This command will store the generated HTML files in the /path/to/output directory.

Version Information

To check the version of Text2page, use the --version or -v flag:

python text2page.py --version

TOML Feature

Text2page includes support for TOML files. Meaning that you can create a TOML file to bypass entering a long list of optional arguments into your command line. In your TOML file, you are able to specify both the output directory and stylesheet you like to use and Text2page will apply those arguments to the program. You can specify that you want to use a TOML config file by using the --config or -c flag. For example:

python text2page.py /path/to/your/file or directory --config /path/to/your/toml.config

Replace /path/to/your/file with your .txt or .md file or replace it with a directory containing the .txt or .md files.

Features

Horizontal Rules

Text2page now supports horizontal rules in Markdown. To create a horizontal rule, use three or more hyphens, asterisks, or underscores, separated by spaces (e.g., ---, ***, or ___) in your Markdown content. When Text2page encounters a horizontal rule in the Markdown content, it will replace it with an HTML


tag.

Example

Input Markdown:


This is some text below the horizontal rule.


And this is some text below the horizontal rule.

Inline Code Blocks

Text2page now supports inline blocks in Markdown. You can enclose text in single backticks () to render it as <code>...text...</code> in the HTML output. For example, code` will become code in the generated HTML.

Here is an example of inline code: `code`.

To convert a .md file with inline code to HTML, use the following command:

code: hello world

python text2page.py /path/to/your/file.md

Help and Usage Information

To view the help and usage information, use the --help or -h flag:

python text2page.py --help

Credits

  • Inspiration: This tool was inspired by the need to convert text documents to web-friendly HTML.
  • Python Community: Thanks to the Python community for creating argparse and other helpful libraries.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions to Text2page are welcome! If you'd like to contribute, please fork the repository and create a pull request.

About

A simple a command-line tool for authoring "Today I Learned" posts in Markdown, which can be converted to HTML

Resources

License

Stars

Watchers

Forks

Packages

No packages published