online-markdown-editor icon indicating copy to clipboard operation
online-markdown-editor copied to clipboard

Saving Preview to HTML

Open coommark opened this issue 11 years ago • 7 comments

Is it possible to save the preview to HTML? How could that be done?

coommark avatar Jul 13 '13 19:07 coommark

The rendered HTML—at least when it's not syntax-highlighted—is pretty basic, so you could just write a JavaScript function that copies the HTML code from the preview and replaces it. If I have the time I'll do that, should be a matter of minutes.

slhck avatar Jul 13 '13 20:07 slhck

I have been trying for days without success. My problem is how to bind the #preview DOM element to a hidden field so that I will use the hidden field to get the data in the preview div element and save it to database.

coommark avatar Jul 13 '13 21:07 coommark

I have attempted everything I could in JQuery. From appending to a hidden form element, to cloning the #preview div to the hidden from element with no success. See sample below:

$("#ArticleBody").append($("div#preview").clone());

coommark avatar Jul 13 '13 23:07 coommark

Maybe I need to ask this question differently. When I submit my form, data submitted from the textarea shows the other markdown characters, eg "Article\r\n-------\r\n\r\nThis is sample C# \r\n\r\n if(user.identity.name = mark)\r\n {\r\n _reposity.save()\r\n }"

However, as you can see above, the C# code is not marked down, as such, the code is saved into the database without the pre delimiters. Is this the normal behaviour?

coommark avatar Jul 13 '13 23:07 coommark

How to parse tables well?

title des remark
test test2 nothing

baigao2015 avatar Mar 08 '16 06:03 baigao2015

@baigao2015 Tables do not seem to be enabled by default in the version of showdown.js that is used here. It'd need an update of showdown and the flag to be enabled.

slhck avatar Mar 08 '16 12:03 slhck

OK, thanks.

baigao2015 avatar Mar 09 '16 05:03 baigao2015