DEV Community

Eakam
Eakam

Posted on • Updated on

rost_gen - A simple static site generator

This is a project that I created as part of my course in open-source development. rost_gen is a basic static site generator made using Rust that generates html files from text files.

Usage

Detailed installation and usage instructions can be found in the Readme.md file on github here.

./rost_gen [OPTION]

Available options:
[-i, --input] [PATH]
Specify a path to the input file or folder containing files.
The file or files must be .txt files to be converted. By default, this will output generated html files to the ./dist directory. Any existing content will be deleted.

[-i, --input] [INPUT PATH] [-o, --output] [OUTPUT PATH]
Specify an output directory. This will create a directory if it doesn't exist but keep existing content.

[-h, --help]
Display help message

[-v, --version]
Display name and version of tool

Usage examples:

  • Generate html from a single text file

    ./rost_gen --input file_to_convert.txt

  • Generate html from a folder containing text files

    ./rost_gen -i folder_with_text_files

  • Specify an output directory

    ./rost_gen --input file_to_convert.txt --output output_dir

Features

  • Seperate paragraphs with blank lines
    The tool will parse paragraphs and enclose them in <p> tags. Just separate paragraphs in the text file with blank lines:

    This is the first paragraph
    
    This is the second paragraph
    This is the second line of the second paragraph
    
  • Specify a file title with two blank lines
    If the first line is followed with two blank lines, it will be used as the title of the generated html file. The tool will also add a <h1> tag in the generated html body containing this title:

    Title of the document
    
    Start of content
    

    Generated html body will look like this:

    <h1>
      Title of the document
    </h1>
    <p>
      Start of content>
    </p>
    

About the name

I based the name on a scene from one of one of the episodes from "The Mentalist" where one of the characters uses "Roth" (which comes from the German word "rot" meaning "Red) as part of one of their aliases.
So, I decided to use Google Translate to translate Rust into German and ended up with rost, and gen for generator. Also, st_gen can be short for static_generator.

Top comments (0)