DEV Community

Cover image for An Intro to Tiller, the Text to HTML Miller.
Namatuzio
Namatuzio

Posted on

An Intro to Tiller, the Text to HTML Miller.

Tiller

Tiller is a command line interface for transforming text files into HTML files. The repo can be found here and samples can be found here!

Features

  • Transform text files into HTML files
  • Easily transform multiple files at once
  • Customizable output directory

Installation

Ensure Python is installed

python --version

Install the required libraries

pip install "typer[all]"
pip install Markdown
Enter fullscreen mode Exit fullscreen mode

Optionally, the libraries can be installed via the requirements.txt file:

pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

Options:

--version, -v  Print the current version of Tiller.
--help, -h     Print the help message.
--output, -o   Specify the name of the folder which the generated files will appear.
Enter fullscreen mode Exit fullscreen mode

Usage:

.\main.py [OPTIONS] DIR
Enter fullscreen mode Exit fullscreen mode

Examples:

Transform a file through a relative path:

.\main.py .\example.txt
Converted example.txt to example.html
Enter fullscreen mode Exit fullscreen mode
.\example.txt

Hello

World\\

How are you?
Enter fullscreen mode Exit fullscreen mode
.\til\example.html
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Hello</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>
    <h1>Hello</h1>
    <body>
        <p>Hello</p>
        <p>World</p>
        <p>How are you?</p>
    </body>
</html>
Enter fullscreen mode Exit fullscreen mode

Transform all files in the current directory and output them to the output directory:

.\main.py --output output .
Converted example.txt to example.html
Converted example2.txt to example2.html
Enter fullscreen mode Exit fullscreen mode
.\example.txt

Hello

World

How are you?
Enter fullscreen mode Exit fullscreen mode
.\example2.txt

Hi

* How
* Are
* You
* ?
Enter fullscreen mode Exit fullscreen mode
.\output\example.html
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>example</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>
    <h1>example</h1>
    <body>
        <p>Hello</p>
        <p>World</p>
        <p>How are you?</p>
    </body>
</html>
Enter fullscreen mode Exit fullscreen mode
.\output\example2.html
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>example2</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>
    <h1>example2</h1>
    <body>
        <p>Hi</p>
        <ul>
        <li>How</li>
        <li>Are</li>
        <li>You</li>
        <li>?</li>
        </ul>
    </body>
</html>
Enter fullscreen mode Exit fullscreen mode

Display the help message:

.\main.py --help (or -h)

Usage: main.py [OPTIONS] DIR 
  Convert .txt files to .html files.
Arguments:
  DIR  [required]\n
Options:
  --version, -v  Print the current version of Tiller.
  --help, -h     Show this message and exit.
  --output, -o   Change the output directory of the .html files.
Enter fullscreen mode Exit fullscreen mode

Display the current version of Tiller:

.\main.py --version (or -v)

Tiller Version: 0.1.0 
Enter fullscreen mode Exit fullscreen mode

TIL

The creation of Tiller brought its own set of unique challenges that required me to perform a certain degree of research to solve them. Thankfully, Python made it reasonably easy due to the many built-in file functionalities. So, what did I learn from Tiller? well, I learned a whole lot about Python's file reader and the many useful functionalities that are inside of the os library. It taught me a lot about reviewing code and that having other hands on your project may not necessarily be a bad thing. If anything, it really has shown me - even if it's a super simple application and project as a whole - that open source is excellent for debugging, testing, and writing strong, readable code.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay