I built a website for launching a small blog using Tailwind, Node.js, Express, and Mongoose. The problem I am experiencing is with the Markdown that I've coded. The Markdown I have written that does not include any spaces inside of its syntax works perfectly, just as I anticipate it too, however; when the markdown does include spaces inside of the syntax, my code no longer works I expect it too.
An good example of this is when I use a syntax like the top-level header tag #. When I implement the snippet bellow it doesn't work write:
# HEADER 1
So here is the deal -- If I remove the Tailwind Script from the main Handlebars layout, all Markdown starts working as expected.
What is Tailwind doing to cause the Markdown to not render when spaces are included in its syntax?
Below is the schema I am currently working with:
const mongoose = require("mongoose");
const createdompurify = require("dompurify");
const marked = require("marked");
const { JSDOM } = require("jsdom");
const dompurify = createdompurify(new JSDOM().window);
const Schema = mongoose.Schema;
const postschema = new Schema({
title: {
type: String,
required: true
},
description: {
type: String,
required: true
},
content: {
type: String,
required: true
},
createdAt: {
type: Date,
default: Date.now()
},
sanitizedHtml: {
type: String,
required: true
},
file: {
type: String,
default: ""
}
})
postschema.pre("validate", function (next) {
if (this.content) {
// it converts our markdown to html
// purifies that html to get rid of malicious code and escapes all html characters
this.sanitizedHtml = dompurify.sanitize(marked(this.content));
}
next();
});
module.exports = mongoose.model("posts", postschema);