如何在PHP中定制markItUp预览页面?

时间:2022-11-04 16:03:31

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

我有个关于markItUp的问题!预览功能。

Inside jquery.markitup.js i have these settings:

jquery.markitup内部。我有以下设置:

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?

我不知道如何处理previewParserPath和previewParserVar。是否可以获取markItUp在预览中发送的内容。php使用php吗?

// preview.php
<body>
<!-- content -->
</body>

1 个解决方案

#1


7  

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

您只需要设置previewParserPath和可选的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.

然后,markitup将寻找预览。在与markitup jquery脚本相同的目录中运行的php脚本——这就是~字符的含义。

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.

然后它将像往常一样相对于您的web服务器根目录。

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".

“数据”对应的是previewParserVar设置的值;缺省值是“数据”。

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

在你的应用程序中,你可能会想在显示之前用$_POST['data']做一些有用的东西。

#1


7  

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

您只需要设置previewParserPath和可选的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.

然后,markitup将寻找预览。在与markitup jquery脚本相同的目录中运行的php脚本——这就是~字符的含义。

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.

然后它将像往常一样相对于您的web服务器根目录。

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".

“数据”对应的是previewParserVar设置的值;缺省值是“数据”。

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

在你的应用程序中,你可能会想在显示之前用$_POST['data']做一些有用的东西。