serving markdown directly : any suggestions?

mofo syne mofosyne at
Wed Feb 4 04:36:41 EST 2015

Okay then, well if you are running in php, and you got the parsedown.php
file as well, then you can give this a shot.

Just modify the .htaccess file rewrite rule from "RewriteCond
 %{REQUEST_URI} ^(.*)\.md" to "RewriteCond  %{REQUEST_URI} ^(.*)\.html"

See if that works for you.



Coder: Brian Khuu
Purpose: To allow for displaying of .md file transparently to visitors via and mod_rewrite
Usage: Place this file (parsedownRender.php) in your root directory and add
these lines below to your .htaccess file

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond  %{REQUEST_URI} ^(.*)\.md
RewriteRule .
/parsedownRender.php?css=/css/markdown1.css&file=%{REQUEST_URI} [L]

$file = "./".$_GET["file"]; // 'file' => /md/
$css = ( $_GET['css']!="" ) ? htmlspecialchars($_GET['css']) :

function parsedownInclude($f){
require_once 'Parsedown.php';
$Parsedown = new Parsedown();
echo is_readable($f) ? $Parsedown->text(file_get_contents($f)) : "File Not
Found: ".htmlspecialchars($f);
<!DOCTYPE html>
<head><link rel="stylesheet" type="text/css" href="<?php echo $css ?>"
<?php parsedownInclude($file) ?>

On Wed, Feb 4, 2015 at 8:29 PM, Mayuresh Kathe <mayuresh at> wrote:

> i did muse around with that approach, but, that's not what is expected for
> my use case.
> i need the markdown content to be dynamically transformed to (x)html on
> the server.
> this is to allow collaborators on the documentation to send in only diff
> files for corrections, additions, etc. which would be plain-text, which is
> easier to understand for non web (html + css) developers.
> i guess i missed mentioning the project for which i am doing this, it is
> for the "openbsd faq".
> this is just a test run, once i succeed, i intend to convert the entire
> "faq" to markdown, probably by hand, set up a server for the demo, before
> submitting it to the openbsd crowd for consideration.
> ~mayuresh
> On 2015-02-04 14:50, mofo syne wrote:
>> Have you considered compiling the website on your computer first then
>> uploading it as a static website?
>> E.g. via  Jekyll?
>> hi,
>>  have been tinkering with markdown for a few hours now, so am still a
>> noob.
>>  would like to use it for a documentation project which will be served
>> over the web.
>>  need to know if there's any way to transform markdown content to
>> (x)html on the fly at the web server level?
>>  use case:
>>  a web server with the above capabilities would have the document root
>> folder holding a bunch of markdown files and a 'css' file.
>>  on visiting that web server's address over 'http', the [1]
>> file would get transformed into (x)html, pick-up the 'css' and show a
>> beautiful page to the visitor.
>>  all this, while i would be busy writing plain old markdown.
>>  i am sorry if this has been asked out here before, but i couldn't
>> find any such queries, perhaps my googling skills are bad.  :)
>>  thanks,
>>  ~mayuresh
>>  _______________________________________________
>>  Markdown-Discuss mailing list
>>  Markdown-Discuss at
>> [2]
>> Links:
>> ------
>> [1]
>> [2]
> _______________________________________________
> Markdown-Discuss mailing list
> Markdown-Discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Markdown-Discuss mailing list