Forum
Using html and Markdown with classes
Is it possible to add a class to html when using Markdown on my template? The html seems to be processed correctly (ie it creates html rather than outputting it onto the page) but whenever I try to add a class it does this:
<ul class="myclass"> <!-- removed semicolons so I can post it here -->
<li>item1</li>
<li>item2</li>
<li>item3</li>
</ul>
Instead of:
<ul class="myclass">
<li>item1</li>
<li>item2</li>
<li>item3</li>
</ul>
My template is:
<perch:content id="text" type="textarea" label="Text" markdown="true" editor="markitup" />
I've tried adding html="true"
to my template but all posts get saved as drafts (I assume you can't use html and Markdown at the same time). I've also tried encode="false"
which allows me to save the page, but the quotes still get encoded.
I feel like there should be an easy solution but I don't know how to go about it. I would add the normal {.class}
using Markdown but it doesn't seem to be support on lists in parsedown. Any help would be greatly appreciated!
What am I missing here? Those look the same.
Whoops sorry should've checked my post - in the top example myclass is surrounded by " (plus a semicolon - it keeps transforming it here, haha) rather than actual quote marks. I'll edit the original post so you can see it better.
You should be able to. Can you turn on debug and look to see if you get any errors when this happens?
Yes no problem, this is the output:
I noticed it mixes up back and forward slashes for my templates, wonder if it's something to do with hosting in a Windows environment.
Tried changing them to backslashes and the same thing happens so it doesn't appear to be related.
Is that after clicking Save or before?
This is before clicking save:
This is after clicking save with no html on the page:
And this is after clicking save after I add html to the page:
This is the html I'm adding:
As you can see, it's hard work being a content management system.
I can't see anything in that that should be throwing it into Draft mode.
Haha yes, it's a strange one. I'll see if I can figure something out on my end - if html and markdown should work at the same time I'll try doing that on a page that has less content on it (the one above is on a live site). I'll post back if I find anything, but if you work it out it'd be great to find out what's causing the problem
In case anyone else has the same problem: it was being caused by not having the php mbstring extension enabled - added it to my php.ini and it works perfectly.