diff --git a/README.md b/README.md
index 3fde65c4a50ac13256743bea9431ec3ad3aaf4c0..7adc1fb72f5466aec19c84e00937d56aa0955029 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,45 @@
# Boop! – a simple "low-tech" static site generator, for fun.
+## Installation
+
+In this guide, we assume you are using Linux.
+
+First, you should clone the Boop! repository and install its dependencies.
+Boop! requires Python 3.6 to work (mainly because of our use of the `f-strings`).
+
+```console
+$ git clone https://framagit.org/marien.fressinaud/boop.git
+$ cd boop
+$ pip3 install -r requirements.txt
+$ cd ..
+```
+
+Then, add the path to your `.bashrc`:
+
+```console
+$ echo export PATH="$(pwd)/boop:\$PATH" >> ~/.bashrc
+```
+
+And source it so it considers the change:
+
+```console
+$ source ~/.bashrc
+```
+
## Usage
-In this section, we assume you are using Linux.
+First, create a project directory:
+
+```console
+$ mkdir my-website && cd my-website
+```
-Create your website in a `./content` folder and execute the Boop! command:
+Create a `./content` folder and execute the Boop! command:
```console
$ mkdir content
$ echo '
Welcome!
' > content/index.html
-$ ./boop.py
+$ boop.py
Boop!
```
@@ -23,13 +53,19 @@ $ tree
.
├── content
│ └── index.html
-├── output
-│ └── index.html
-└── boop.py
+└── output
+ └── index.html
```
-Yeah, it's kinda too simple for the moment (it only copies the files from
-`./content` to `./output`), but new features are coming soon!
+Boop! basically just copied `content` files under a `output` directory. But it
+can convert Markdown files in HTML too:
+
+```console
+$ echo '# Welcome!' > content/markdown-index.md
+$ boop.py
+$ echo output/markdown-index.html
+Welcome!
+```
## Tests
diff --git a/boop.py b/boop.py
index cf77a21f2c5ee98b061357c6a23f932c9a544f18..2a25f419ded2371dcf9d159eb7745d8c08ec6ad5 100755
--- a/boop.py
+++ b/boop.py
@@ -4,6 +4,8 @@ import os
import sys
import shutil
+import markdown
+
class ProgramError(Exception):
"""Exception raised during the program execution.
@@ -54,16 +56,30 @@ def main():
# ... but it also can be a simple file if user created it manually!
os.remove(output_path)
+ md = markdown.Markdown()
+
# And copy the files from ./content to ./output
for filepath in dir_tree(content_path):
+ base, ext = os.path.splitext(filepath)
content_filepath = os.path.join(content_path, filepath)
output_filepath = os.path.join(output_path, filepath)
+ if ext == ".md":
+ output_filepath = os.path.join(output_path, f"{base}.html")
# First we need to create all the parent directories for our file
mkdirs_for_file(output_filepath)
- # Then, we copy content file to its output destination
- shutil.copyfile(content_filepath, output_filepath)
+ if ext == ".md":
+ # Then, if it is a Markdown file, we convert it
+ with open(content_filepath, "r") as content_file:
+ html = md.convert(content_file.read())
+
+ # And we write it as a HTML file
+ with open(output_filepath, "w") as output_file:
+ output_file.write(html)
+ else:
+ # ... else, we simply copy the file to the output directory
+ shutil.copyfile(content_filepath, output_filepath)
if __name__ == "__main__":
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000000000000000000000000000000000000..0918c9768895c23af5ecf35282391d7b12ed301a
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1 @@
+markdown