ElkArte Community

Elk Development => Feature Discussion => Topic started by: forumsearch0r on September 10, 2014, 01:00:48 pm

Title: Markdown support
Post by: forumsearch0r on September 10, 2014, 01:00:48 pm
I'd like to have a built-in BBcode or - even better - a switch to use Markdown for formatting my postings.
Title: Re: Markdown support
Post by: emanuele on September 10, 2014, 01:04:58 pm
/me looks @Spuds and his idea (http://www.elkarte.net/community/index.php?topic=219.msg5018#msg5018) O:-)
Title: Re: Markdown support
Post by: forumsearch0r on September 10, 2014, 01:43:57 pm
If there already is a parser, it should be easy to just use it?
Title: Re: Markdown support
Post by: emanuele on September 10, 2014, 02:21:39 pm
	require_once(EXTDIR . '/markdown/markdown.php');
$message = Markdown($message);

You can use the hook integrate_pre_parsebbc so a function like:
Code: [Select]
function parse_markdown(&$message, &$smileys, &$cache_id, &$parse_tags)
{
require_once(EXTDIR . '/markdown/markdown.php');
$message = Markdown($message);
}
attached to that hook should do the trick.
Title: Re: Markdown support
Post by: Adrek on September 10, 2014, 02:48:58 pm
Why markdown is better? I find it harder to use.
Title: Re: Markdown support
Post by: emanuele on September 10, 2014, 03:09:33 pm
It's different.
I find it easier to do bold or underline rather than have to use square brackets and letters, for example. Also lists are usually easier.
Links and images... meh, both a bit difficult (I always forget what comes first in markdown).

Then bbcode is much more for formatting, while "Markdown is a writing format (http://daringfireball.net/projects/markdown/syntax#html)", so two different things. ;)
Title: Re: Markdown support
Post by: Spuds on September 10, 2014, 03:39:39 pm
Today we have:

MD to HTML = Markdown in the ext dir
BBC to HTML = our buddy parse_bbc
HTML to BBC = Html2BBC.class in subs
HTML to MD = Html2Md.class in subs

I had intended to write a BBC to MD or was that  MD to BBC? now I can't remember which direction I wanted now LOL ...

Today to do those swaps you need to to  BBC to HTML then HTML to MD or MD to HTML and HTML to BBC  and each time you swap the language, indeed something is lost plus its 2x the overhead.

For a simple MD post to work, what emanuele said should work AFAIK, the issue of course is overhead, none of those functions are lite weight, and chaining them could be an issue.   Providing a very lite weight MD to html (or really bbc) for basic bold, itailic, etc md text may be the best option.
Title: Re: Markdown support
Post by: forumsearch0r2 on September 10, 2014, 04:23:06 pm
Quote from: phantom – Why markdown is better? I find it harder to use.

Not on smartphone keyboards.