如何添加WMD编辑器 - wmd_options = {“output”: “Markdown”};

发布于 2024-10-14 23:28:13 字数 328 浏览 6 评论 0原文

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

我在标记之前有以下行。

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

我想了解如何添加这一行。

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

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

谢谢

I am using WMD Editor and I want to add wmd_options = {"output": "Markdown"};

I have following line before tag.

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

I want to understand how can i add this line.

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

I am not very good at using javascript please help me to use this.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

锦欢 2024-10-21 23:28:13
<script type="text/javascript">
wmd_options = {"output": "Markdown"}; 
</script>
<script type="text/javascript" src="../wmd/wmd.js"></script>

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

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

Javascript executes code in the order it is included on the page (from top to bottom). So you need to set the wmd_options first before the code in the wmd.js file is executed.

太阳公公是暖光 2024-10-21 23:28:13

打开 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 运行显示文本。

Open up wmd.js.

Look for this section:

// -------------------------------------------------------------------
//  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
// -------------------------------------------------------------------

This will send all of your output to the database as Markdown text.

If you want to convert HTML to Markdown text for editing, because you are storing your input in HTML form, then you will need something like this:
http://milianw.de/projects/markdownify/

So when your user clicks on their 'edit' button. You run the query as you normally would, but you run the display text through Markdownify.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文