Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Is processing of markdown editor correct?

+3 votes
675 views
asked Oct 23, 2014 in Plugins by sama55

I tried using the mark-down editor of Scott. Post data seems to be displayed by this plugin correctly.

However, I have a big question.

Markdown code is stored in the "content" of qa_posts table directly. Is this process correct? Because, Q2A and other plugins treat content as HTML or plain text.

Right processing is as follows?
  1. Store: Convert from markdown to HTML
  2. Output: Just display HTML
  3. Edit: Convert from HTML to markdown

What do you think about this?

Q2A version: 1.6.3
commented Oct 23, 2014 by Ami
I agree with this .. +1

2 Answers

0 votes
answered Oct 23, 2014 by QA-Themes
"format" field in ^posts determines which format it's using.

now two things can make problem for developers:

1. the Editor modul does not check(and convert) format if necessary. it should be happening in get_field() function in editor's modul class.

2. the plugin does not get editor modul and use it's get_field() function to get standard post content.

 

so, dispite what editor you are using, if it's converting the conten(rule 1) and you get editor calss using qa_load_module() function and call it's get_field() function to get post data(rule 2) you should be fine.
+1 vote
answered Oct 23, 2014 by Scott

Yes it is correct. There is no such thing as "conversion from HTML to Markdown", it's a one-way system.

Technically it is possible but since MD allows HTML inside it too it's incredibly messy. I've used a MD plugin for Wordpress that stores as HTML and converts back to MD for editing and it's a complete nightmare.

Q2A and other plugins treat content as HTML or plain text.

Yes, and Markdown is pretty much treated as plain text. You can change the format to 'text' in your database and it will work fine.

commented Oct 26, 2014 by sama55
Mark down editor is made according to the specifications of Q2A. This is particularly qa-markdown-viewer.php.
http://www.question2answer.org/modules.php?module=viewer

However, this specification is a little unreasonable. Many plugins will refer to the database directly, and output content as HTML or plain text.
commented Jun 16, 2016 by donshakespeare
Markdown is typically for people who don't want to see HTML, in the clientside fields or in the database, period. So the idea of editing in Markdown but storing in HTML is fictitious for Markdown users.

If the user is consistently serious, he'll only use other plugins that can handle Markdown plaintext from database.
...