Skip to main content
Markdown in posts Started by NetFlag · · Read 1317 times 0 Members and 1 Guest are viewing this topic. previous topic - next topic

Markdown in posts

I have noticed that the 2.0 dev supports markdown in posts. So I started to search if there is a simple solution to make this available for the 1.1.8 as well. Found this Markdown support  Reply #3, but no luck. Well, it's been 9 years, so things must have changed a lot. I am grateful for the right hint. :)

Re: Markdown in posts

Reply #1

Its quite a bit different than that old post, however I don't see any reason why it could not be backported to 1.1 as the BBC parsing engine is mostly the same.

In 2.0 the specific parser is in the BBC directory, called MarkdownParser.php  and if you look at that it only supports a handful of tags (more could be added).

~~strike~~ strike
**bold** bold
__bold__ bold
*italic* italic
_italic_ italic
> quote this --> must be at start of a line
Quotequote this
--- for a hr/rule --> must be start of line 

And the last one supported is 
Code: [Select]
`` place your inline code between tic makrs
for code tags  these can occur anywhere you like

You would use the above file, and then make several edits to BBCParser.php so it makes the calls in the right spots.  You could start by trying these edits plus the above file and see where that gets you ;)

Re: Markdown in posts

Reply #2

Almost forgot ... those inline code tags, like code tags themselves, are complicated.  There are two other areas to look for edits.

The first is in Codes.php  (which holds all the BBC definitions) in that file you will see a new BBC code called [ icode] for inline code.  You will need to grab that new definition

Next there are edits in PreparseCode.php which works to prevent rendering tags inside of code blocks (or icode blocks)  Search around in there for icode, there will be a new function _validateICodeBlocks(); and updates in the tokenizeCodeBlocks which is used to hide code blocks from the BBC parser and later restore them.

I'm sure there are some other areas I've forgotten about, but that should be enough to get one started.