Как добавить редактор ОМУ - wmd_options = {"output": "Markdown"}; - PullRequest
0 голосов
/ 28 января 2011

Я использую WMD Editor и хочу добавить wmd_options = {"output": "Markdown"};

У меня есть следующая строка перед тегом.

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

Я хочу понять, как я могу добавить эту строку.

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

Я не очень хорош в использовании javascript, пожалуйста, помогите мне использовать это.

Спасибо

Ответы [ 2 ]

4 голосов
/ 28 января 2011
<script type="text/javascript">
wmd_options = {"output": "Markdown"}; 
</script>
<script type="text/javascript" src="../wmd/wmd.js"></script>

Javascript выполняет код в том порядке, в котором он включен на странице (сверху вниз). Поэтому вам нужно сначала установить wmd_options перед выполнением кода в файле wmd.js.

0 голосов
/ 05 июля 2011

Откройте 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.

...