diff --git a/app.js b/app.js
index 7aab9b8..d749531 100755
--- a/app.js
+++ b/app.js
@@ -1,12 +1,13 @@
const express = require('express');
+const showdown = require('showdown')
const crypto = require('crypto'); // For encrypting passwords
const { fromUnixTime, format, getUnixTime } = require("date-fns")
const fs = require('fs');
const users = require('./users.js');
const posts = require('./posts.js');
const config = require('./config.js');
+let converter = new showdown.Converter({simpleLineBreaks: true, tables: true, strikethrough: true, tasklists: true, encodeEmails: true})
const app = express();
-const port = 8080;
let footer_div = config.site_wide_footer
footer_div = replace_format_indicators(footer_div)
@@ -53,7 +54,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", markdown_to_html(post_object["content"]))
+ .replaceAll("%C", converter.makeHtml(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 +66,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", markdown_to_html(post_object["title"]))
+ .replaceAll("%T", post_object["title"])
.replaceAll("%U", `/user/${users.users[post_object["userID"]]['username']}`)
.replaceAll("%Y", config.site_name)
.replaceAll("%W", config.site_description)
@@ -89,22 +90,6 @@ 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!")
@@ -122,7 +107,7 @@ app.get(config.rss_path, (req,res) => {
-
${posts.posts[i]["title"]}
${config.site_url}/post/${i}.${config.file_extension}
- ")}]]>
+
${config.site_url}/post/${i}
${unix_time_to_rss_date(posts.posts[i]['pubdate'])}`
for (let j = 0; j < posts.posts[i]['tags'].length; j++) {
@@ -197,8 +182,8 @@ app.get("/post", (req,res) => {
-
- * Markdown supported: *bold*, _italic_, (link)[url] and \`\`\`code block\`\`\`
+
+ * Markdown supported