Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Archive

Markdown Extra - HTML <a>-block?

Started by Muut Archive 9 years ago · 9 replies · 1173 views
9 years ago

I am currently trying to solve an issue I have with some markdown HTML.
What I try to achieve is a <a>-block. The code I want to use in the markdown file is as follow:

HTML
<a href="#" markdown="1"><div class="left">
## Title 1
![Description](test.png)
</div></a>

Now the problem is that the output of this is really unusable:

HTML
<p><a href="#" markdown="1"><div class="left"></p>
<h2>Title 1</h2>
<p><img alt="Description" src="/path/grav-admin/user/pages/03.de/01.home/_home1/test.png" />
</div></a></p>

I tried also other variants using <a> without <div>, but the output is also bad.

How can I get clean code?

9 years ago

Try to put the <a> within the <div>:)

9 years ago

The result is even worse then:

--- html
<div div class="left">
<p><a href="#"></p>
<h2>Title 1</h2>
<p><img alt="Description" src="/path/grav-admin/user/pages/03.de/01.home/_home1/test.png" />
</a></p>
</div>

9 years ago

what if you try this?

HTML

<a href="#"><div class="left" markdown="1">
## Title 1
![Description](test.png)
</div></a>
---
9 years ago

This seems to be the best solution, as I get only one <p></p> block which isn't that much in the way (I hope at least).

--- html
<div markdown="1" div="" class="left"><p></p><a href="#">
<h2>Title 1</h2>
<p><img alt="Description" src="/path/grav-admin/user/pages/03.de/01.home/_home1/test.png">
</p></a></div>

9 years ago

EDIT:
My answer above is wrong, as I didn't see that the link will appear 2x.

--- html
<p><a href="#"></a></p>
<div markdown="1" div="" class="left"><p></p><a href="#">
<h2>Title 1</h2>
<p><img alt="Description" src="/path/grav-admin/user/pages/03.de/01.home/_home1/test.png">
</p></a></div>

TXT

So I can also not use this solution...

Any other ideas?
9 years ago

Hello,
Could you use a span instead of a div ?

9 years ago

Sorry, I hadn't seen the h2 wich is also a block element...

9 years ago

This is really a limitation of Markdown Extra. it's not very well supported and doesn't get updated often (last commit was 2 years ago - https://github.com/erusev/parsedown-extra), so i suggest not using markdown inside HTML, better to just use pure HTML with some Twig if you want to get the output you desire.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1318 9 years ago
Archive · by Muut Archive, 9 years ago
2 915 9 years ago
Archive · by Muut Archive, 9 years ago
2 4044 9 years ago
Archive · by Muut Archive, 9 years ago
1 2920 9 years ago
Archive · by Muut Archive, 9 years ago
3 1104 9 years ago