Development > Web

Markdown to HTML and BBCode!

(1/1)

_iPhoenix_:
note, the converter currently is not 100% compatible with CW's BBCode, but compatibility will come eventually! For demonstration purposes, I made no modifications to the output of my program, even though it doesn't work entirely.



A few weeks ago, I had the not-so-crazy idea to write a Markdown renderer in JavaScript. This isn't that hard, Markdown is designed to be easily converted into HTML.


Last night, I realized that BBCode is also designed to be turned into HTML and formatting in Markdown is much more concise than BBCode. Maybe I can write posts faster in Markdown!


This is the result of about a hour of work. The converter uses Regular Expressions to match the Markdown formatting in the input text and replace it with the appropriate BBCode and HTML tags. Here's what I have so far:


[size=20]Headings[/size]
[size=16]Subheadings[/size]
(The Markdown to HTML lets you how down to h4, but I'm too lazy to add this to the BBCode version) 
[strike]strikethrough[/strike] 
bold 
italics 
Inline [mono]code[/mono] 

--- Code: ---Code
blocks

--- End code ---
[*]lists
[*]more list (it joins adjacent list elements appropriately) 
[/list]


Links 
Horizontal bars:
Images: 



This post was converted from Markdown into BBCode using the Markdown -> BBCode converter! You can see the source code for this post here


You can find the converter at https://legend-of-iphoenix.github.io/markdown-bbcode-html/.


To-do
[*]Block quotes
[*]Somehow, colors???
[*]Code cleanup
[*]Bugfixing, particularly bugs with italics using asterisks.
[*]Escaping? Somehow?
[*]Nested lists? Somehow?
[*]Ordered lists.
[*]Make generated HTML a bit nicer-looking. (Apply formatting rules)
[*]Clean up the actual website (I think jcgter777 is going to help with this)
[*]Add support for more advanced Markdown.
[*]Potentially convert BBCode to Markdown?
[/list]

gameblabla:
I personally would like to see the exact opposite (From BBcode to Markdown) so i can use it on discord because Markdown has some strange symbols

_iPhoenix_:

--- Quote from: gameblabla on June 04, 2018, 11:09:59 am ---I personally would like to see the exact opposite (From BBcode to Markdown) so i can use it on discord because Markdown has some strange symbols

--- End quote ---

Yeah, that's the eventual idea. I personally prefer Markdown over BBCode because, as I noted in my post, it is more concise.

Navigation

[0] Message Index

Go to full version