Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a custom markItUp preview page in PHP?

I have a question about markItUp!'s preview function.

Inside jquery.markitup.js i have these settings:

previewTemplatePath:'~/templates/preview.php',
previewParserPath:'~/templates/preview.php',
previewParserVar:'data'

I'm not sure what to do with previewParserPath and previewParserVar. Is it possible to grab the content sent by markItUp in preview.php with PHP?

// preview.php
<body>
<!-- content -->
</body>
like image 678
horgen Avatar asked Jun 04 '10 20:06

horgen


1 Answers

You only need to set the previewParserPath and optionally the previewParserVar.

If you use this:

previewParserPath: '~/preview.php'

then markitup will look for a preview.php script to run in the same directory as the markitup jquery script--that's what the ~ character means.

If instead you set the preview path to something like this:

previewParserPath: '/preview.php'

then it will be relative to your web server root directory, as usual.

The implementation of the script it up to you; this is perhaps the most basic example:

echo htmlentities($_POST['data']);

The "data" there corresponds to the value of the previewParserVar setting; the default is "data".

In your app, you're probably going to want to do something useful with $_POST['data'] before you display it.

like image 184
Wez Furlong Avatar answered Oct 15 '22 21:10

Wez Furlong