【问题标题】:How to add WMD Editor - wmd_options = {"output": "Markdown"};如何添加 WMD 编辑器 - wmd_options = {"output": "Markdown"};
【发布时间】:2011-06-17 11:20:17
【问题描述】:

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

我在标记前有以下行。

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

我想了解如何添加此行。

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

我不太擅长使用javascript,请帮我用这个。

谢谢

【问题讨论】:

    标签: javascript wmd-editor


    【解决方案1】:
    <script type="text/javascript">
    wmd_options = {"output": "Markdown"}; 
    </script>
    <script type="text/javascript" src="../wmd/wmd.js"></script>
    

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

    【讨论】:

    • 我已经尝试过了,但不幸的是它不起作用。我指的是这个线程解决方案stackoverflow.com/questions/122108/…,其中想要将html标签转换为markdown标签以便编辑内容
    • 那么你想把 HTML 转换成 Markdown 吗? WMD 编辑器不是这样工作的。它只将 Markdown 转换为 HTML。您提到的选项允许您选择在提交表单时将什么格式发送回服务器。您可能希望将表单的内容作为 Markdown 保存在数据库中,以便再次对其进行编辑。使用此michelf.com/projects/php-markdown 将 Markdown 转换为服务器上的 HTML。
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2010-11-14
      • 2011-04-18
      • 2011-06-11
      • 2010-12-13
      • 1970-01-01
      • 2011-08-04
      • 1970-01-01
      • 2011-05-09
      • 2010-10-12
      相关资源
      最近更新 更多