Search code examples
.netasp.netwmd

How to capture the markdown from a WMD-Editor server side in a ASP.NET website?


I'm using an asp:TextBox as the wmd-input. As the user clicks the submit button I wan't to capture the markdown at server side as the Text property of my asp:TextBox control.

However, instead of the expected markdown, my TextBox at server-side contains the HTML formatted version of the markdown:

<h1>testing</h1>

How do I get the pure markdown?

PS: At client side I see markdown on the asp:TextBox. It's not clear for me when it's getting converted to HTML before post-back.


Solution

  • Figured it out myself.

    WMD-Editor supports a configuration that determines the output of the editor. Check out the file optionsExample.html that comes with the downloadable version.

    In my case I just needed to add this before the showdown.js reference:

    <script type="text/javascript">
            window['wmd_options'] = {
                output: "Markdown",
                buttons: "bold italic | link blockquote image | ol ul heading hr"
            };
        </script>