diff --git a/README.md b/README.md
index 920c60f..4c7b9e5 100644
--- a/README.md
+++ b/README.md
@@ -11,10 +11,10 @@ In action on my website: [deadvey.com](https://deadvey.com)
* edit/delete posts
* probably insecure as hell
* hitcount
+* Markdown syntax in posts
# planned features
* atom
* federation
* sign up
-* Markdown syntax in posts
* All strings (including in edit and post page) customisable
diff --git a/app.js b/app.js
index 8e41170..7aab9b8 100755
--- a/app.js
+++ b/app.js
@@ -53,7 +53,7 @@ function replace_format_indicators(input_string, post_index=0, tag_name="tag") {
.replaceAll("%%", "%")
.replaceAll("%A", (post_object["tags"]))
.replaceAll("%B", (hyperlink_tags(post_object["tags"])))
- .replaceAll("%C", post_object["content"].replaceAll("\n","
"))
+ .replaceAll("%C", markdown_to_html(post_object["content"]))
.replaceAll("%D", unix_time_to_date_format(post_object["pubdate"]))
.replaceAll("%E", unix_time_to_date_format(post_object["editdate"]))
.replaceAll("%F", users.users[post_object["userID"]]['prettyname'])
@@ -65,7 +65,7 @@ function replace_format_indicators(input_string, post_index=0, tag_name="tag") {
.replaceAll("%O", `/edit/${post_index}`)
.replaceAll("%R", "/rss")
.replaceAll("%S", config.seperator)
- .replaceAll("%T", post_object["title"])
+ .replaceAll("%T", markdown_to_html(post_object["title"]))
.replaceAll("%U", `/user/${users.users[post_object["userID"]]['username']}`)
.replaceAll("%Y", config.site_name)
.replaceAll("%W", config.site_description)
@@ -89,6 +89,22 @@ function escape_input(input) {
return output
}
+// Markdown supported:
+// *text* = bold
+// _text_ = italic
+// [page](url) = hyperlink
+// ```code``` = code
+function markdown_to_html(input) {
+ // FIXME backticks before these should negate stuff
+ let output = input
+ .replaceAll(/\[(.*)\]\((https:\/\/|http:\/\/)(.*)\)/g, "$1")
+ .replaceAll(/\*(.*)\*/g,"$1")
+ .replaceAll(/_(.*)_/g,"$1")
+ .replaceAll(/```(.*)```/gms,"$1
")
+ .replaceAll("\n","
")
+ return output
+}
+
app.get(config.rss_path, (req,res) => {
if (config.rss == false) {
res.send("Sorry, RSS is disabled!")
@@ -142,40 +158,6 @@ app.get("/", (req,res) => {
}
res.send(`