Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gradiation 36 posts 21 karma points
    Feb 20, 2009 @ 23:55
    Gradiation
    0

    Markdown Data Type (Help please)

    Hi Guys,

    I'd like to make a Markdown data type and was wondering how to change the data types output at render only on the front end.

    I've seen the tutorials on nibble for creating custom data types, but the problem is, i need to change what is output at the point it is rendered on the front end, but maintain it's raw state during editing.

    Anbody got any advice on the best way to do this?

    Many thanks

    Matt

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Feb 21, 2009 @ 13:32
    Niels Hartvig
    0

    The easiest way would be to
    - add post parsing in the Save method to store the data that's supposed to be used on the front end (ie so it's html and not markdown that's saved)
    - Convert the html 2 markdown before the render method in your control

    The optimal way would be to
    - leave the control to use and store markdown
    - override the ToXml() method on the IData class in your control to convert markdown to html when it's published (look at the related links data type in the editorControls project for inspiration)

    Hope this helps! I'd love to see a markdown data type in the core, so if you're willing to add this to the core distribution I'd be happy to help you move on :-)

    /n

  • Simon Justesen 436 posts 203 karma points
    Feb 21, 2009 @ 13:58
    Simon Justesen
    0

    Just throwing in a link for thread readers who wonders what Markdown is:
    http://en.wikipedia.org/wiki/Markdown

  • Gradiation 36 posts 21 karma points
    Feb 22, 2009 @ 15:07
    Gradiation
    0

    Cool,

    Thanks for the help hartvig, thats exactly the starting point I needed.

    I'd be more than happy for anything I develop to be added to the core. I'll keep you posted of my progress.

    Many thanks

    Matt

  • Gradiation 36 posts 21 karma points
    Feb 22, 2009 @ 21:07
    Gradiation
    0

    Ok, here it is, let me know what you think.

    http://www.mattbrailsford.com/downloads/mbumbracodatatypes_markdown.zip

    In terms the markdown tranformer, I've used the Markdown.NET library as written by Milan Negovan which you can find here

    The zip should include all of the source code as well as all assemblies referenced so it should be everything you need, aswell as compiled binaries ready for you to install.

    All the best

    Matt

  • Dan Okkels Brendstrup 101 posts 197 karma points
    Nov 09, 2011 @ 14:52
    Dan Okkels Brendstrup
    2

    In case anyone stumbles on this thread, I think Matt's code ended up forming the basis of Lee Kelleher's Markdown Editor package:

    http://our.umbraco.org/projects/backoffice-extensions/markdown-editor

    TinyMCE is living hell, so I vote with Niels to add Markdown to the core! :)

Please Sign in or register to post replies

Write your reply to:

Draft