Reputation: 293
I'm trying to use a bunch of text files + vim + Markdown.pl as an efficient note taking platform. I've been happy with the Markdown.pl parser so far. But a line like,
<link href="style.css" rel="stylesheet"></link>
gets converted into:
<p><link href="style.css" rel="stylesheet"></link></p>
Is there something that I am missing?
Upvotes: 7
Views: 32305
Reputation: 1112
If markdown.pl
complies with the specification it should be possible.
The "Inline HTML" section of the documentation, markdown syntax, states that your html "must be separated from surrounding content by blank lines, and the start and end tags of the block should not be indented with tabs or spaces".
Upvotes: 4
Reputation: 768
One simple workaround is to insert a </p>
before and <p>
after your HTML tag:
</p><link href="style.css" rel="stylesheet"></link><p>
This will get converted to:
<p></p><link href="style.css" rel="stylesheet"></link><p></p>
It still adds paragraphs, but helps your tags to get into the right hierarchy. Some browsers may need it. One thing to take care is not to use double newlines or any markdown-specific punctuators.
Upvotes: 1
Reputation: 1678
The main thing you're missing is that Markdown is not really designed as a templating system, but a plain text formatting syntax. If you want to include HTML stuff like stylesheets, you're better off using something like Haml.
Another solution would be to create a plain HTML template around your Markdown formatted content like so (PHP example, but could be in any language ofcourse).
<html>
<head>
<title>My Notes</title>
<link href="style.css" rel="stylesheet">
</head>
<body>
<h1>My notes</h1>
<?php markdown(file_get_contents('your_content.md')); ?>
</body>
Upvotes: 6
Reputation: 31
Markdown.pl, in its most recent version, does not accept link tags as block tags, and so it tries to wrap them in <p>
tags.
To correct this, add the word 'link' into the block tag regex lists on line 323, so they end up looking like this:
my $block_tags_a = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del|link/;
my $block_tags_b = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|link/;
You may not have to do both of them, but the result is working link tags.
Upvotes: 2
Reputation: 28588
Markdown wraps everything it considers a paragraph into <p></p>
. Try it here:
Try this markdown:
hello **this is going to be bold**<link href="style.css" rel="stylesheet"></link>
This will get converted to:
<p>hello
<strong>this is going to be bold</strong><link href="style.css" rel="stylesheet"></link></p>
If you can make everything be one block, you'll get one <p></p>
. I'm not sure you can avoid this with markdown.
Upvotes: 2