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?
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>
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".
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With