0

我正在使用 WMD 编辑器,我想添加wmd_options = {"output": "Markdown"};

我在标签之前有以下行。

<script type="text/javascript" src="../wmd/wmd.js"></script>

我想了解如何添加此行。

wmd_options = {"output": "Markdown"}; 

我不太擅长使用 javascript,请帮助我使用它。

谢谢

4

2 回答 2

4
<script type="text/javascript">
wmd_options = {"output": "Markdown"}; 
</script>
<script type="text/javascript" src="../wmd/wmd.js"></script>

Javascript 按照页面中包含的顺序(从上到下)执行代码。所以在执行 wmd.js 文件中的代码之前,需要先设置 wmd_options。

于 2011-01-28T19:51:30.827 回答
0

打开 wmd.js。

查找此部分:

// -------------------------------------------------------------------
//  YOUR CHANGES GO HERE
//
// I've tried to localize the things you are likely to change to 
// this area.
// -------------------------------------------------------------------

// The text that appears on the upper part of the dialog box when
// entering links.
var imageDialogText = "<p style='margin-top: 0px'><b>Enter the image URL.</b></p><p>You can also add a title, which will be displayed as a tool tip.</p><p>Example:<br />http://wmd-editor.com/images/cloud1.jpg   \"Optional title\"</p>";
var linkDialogText = "<p style='margin-top: 0px'><b>Enter the web address.</b></p><p>You can also add a title, which will be displayed as a tool tip.</p><p>Example:<br />http://wmd-editor.com/   \"Optional title\"</p>";

// The default text that appears in the dialog input box when entering
// links.
var imageDefaultText = "http://";
var linkDefaultText = "http://";

// The location of your button images relative to the base directory.
var imageDirectory = "images/";

// Some intervals in ms.  These can be adjusted to reduce the control's load.
var previewPollInterval = 500;
var pastePollInterval = 100;

// The link and title for the help button
var helpLink = "http://wmd-editor.com/";
var helpHoverTitle = "WMD website";
var helpTarget = "_blank";

var wmd_options = {"output": "Markdown"};  //ADD IT HERE
// -------------------------------------------------------------------
//  END OF YOUR CHANGES
// -------------------------------------------------------------------

这会将您的所有输出作为 Markdown 文本发送到数据库。

如果您想将 HTML 转换为 Markdown 文本进行编辑,因为您将输入存储在 HTML 表单中,那么您将需要这样的内容:http: //milianw.de/projects/markdownify/

因此,当您的用户单击他们的“编辑”按钮时。您像往常一样运行查询,但通过 Markdownify 运行显示文本。

于 2011-07-05T16:06:46.470 回答