serving markdown directly : any suggestions?

mofo syne mofosyne at gmail.com
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.

Cheers,

==============


<?php
/*
Coder: Brian Khuu briankhuu.com
Purpose: To allow for displaying of .md file transparently to visitors via
http://parsedown.org 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]
</IfModule>

*/
$file = "./".$_GET["file"]; // 'file' => /md/test.md
$css = ( $_GET['css']!="" ) ? htmlspecialchars($_GET['css']) :
"/css/style.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 ?>"
/></head>
<body>
<?php parsedownInclude($file) ?>
</body>
</html>

On Wed, Feb 4, 2015 at 8:29 PM, Mayuresh Kathe <mayuresh at kathe.in> 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 index.md [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 six.pairlist.net
>>  https://pairlist6.pair.net/mailman/listinfo/markdown-discuss [2]
>>
>>
>> Links:
>> ------
>> [1] http://index.md
>> [2] https://pairlist6.pair.net/mailman/listinfo/markdown-discuss
>>
> _______________________________________________
> Markdown-Discuss mailing list
> Markdown-Discuss at six.pairlist.net
> https://pairlist6.pair.net/mailman/listinfo/markdown-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist6.pair.net/pipermail/markdown-discuss/attachments/20150204/e0d9e63d/attachment.html>


More information about the Markdown-Discuss mailing list