Skip to content

Commit

Permalink
Updated README and fixed small bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Namatuzio committed Sep 25, 2023
1 parent 6cbd7fb commit 358d1e4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Tiller is a command line interface for transforming text and markdown files into
- Transform markdown files into HTML files (Markdown heading1 will be transformed into html \<h1\>)
- Easily transform multiple files at once
- Customizable output directory
- Language support for generated HTML files

## Installation

Expand All @@ -27,6 +28,7 @@ pip install Markdown
--version, -v Print the current version of Tiller.
--help, -h Print the help message.
--output, -o Change the output directory of the .html files.
--lang, -l Specify the language of the generated HTML file.

## Usage:

Expand Down Expand Up @@ -179,6 +181,49 @@ Eum quos harum est rerum necessitatibus aut quae architecto. Non deleniti tempor
</html>
```

### Generate HTML file with a different language:
```
.\main.py --lang fr .\example.txt
Converted example.txt to example.html
```
```html
.\example.txt

Hello

World

How are you?
```
```html
.\til\example.html
<!DOCTYPE html>
<html lang="fr">
<style>
body {
background-color: rgb(0, 116, 145);
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
font-size: xx-large;
}
</style>
<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>
```


### Display the help message:
```
.\main.py --help (or -h)
Expand Down
2 changes: 2 additions & 0 deletions examples/example3.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Lorem ipsum dolor sit amet. Aut unde eligendi ut labore laboriosam et nihil commodi ut dolorem dolor qui tempora exercitationem qui quis error eum unde quaerat! Eum autem quam ut quae voluptates quo veritatis porro.


Ut nihil impedit in galisum assumenda cum incidunt nihil rem dolorem distinctio et doloremque maiores id labore ipsum quo suscipit saepe. Sed veniam debitis in natus repudiandae rem excepturi accusamus sit dolorem quia aut magni voluptatem id incidunt Quis aut voluptatibus quibusdam.


Eum quos harum est rerum necessitatibus aut quae architecto. Non deleniti tempore aut consectetur maiores in corrupti inventore eum veniam aliquam.
10 changes: 2 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ def main(dir: str, version: Optional[bool] = typer.Option(None, "--version", "-v
if(lang == None):
lang = "en-CA"
try:
for file in os.listdir(output):
if(os.path.splitext(file)[-1] == "html"):
os.remove(output + file)
if(os.listdir(output) == []):
os.rmdir(output)
os.mkdir(output)
os.makedirs(output, exist_ok=True)
except OSError as error:
print(error)
Expand All @@ -65,7 +59,7 @@ def main(dir: str, version: Optional[bool] = typer.Option(None, "--version", "-v
if(os.path.isdir(dir)):
for file in os.listdir(dir):
# Added a condition to check for markdown file
if(file.split(".")[-1] == "txt" or file.split(".")[-1] == "md"):
if(file.split(".")[-1] == ".txt" or file.split(".")[-1] == ".md"):
with open(dir + "/" + file, "r") as text_file:
text_file = text_file.read()
WriteHTML(text_file, file.split(".")[0], output, lang)
Expand All @@ -74,7 +68,7 @@ def main(dir: str, version: Optional[bool] = typer.Option(None, "--version", "-v
print(f"{file} is not a .txt file or a .md file. Skipping... \n")
elif(os.path.isfile(dir)):
with open(dir, "r") as text_file:
if (os.path.splitext(dir)[-1] == "html" or os.path.splitext(dir)[-1] == "md"):
if (os.path.splitext(dir)[1] == ".txt" or os.path.splitext(dir)[1] == ".md"):
text_file = text_file.read()
if dir.find("\\") != -1:
title = dir.split("\\")[-1]
Expand Down

0 comments on commit 358d1e4

Please sign in to comment.