- Converting Markdown into BBCode and HTML
- 03 Jun 2018 07:00:49 pm
- Last edited by iPhoenix on 05 Jun 2018 05:45:00 pm; edited 2 times in total
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:
Headings
Subheadings
(The Markdown to HTML lets you how down to h4, but I'm too lazy to add this to the BBCode version)
strikethrough
bold
italics
Inline code
Code:
quote
more quote
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
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:
Headings
Subheadings
(The Markdown to HTML lets you how down to h4, but I'm too lazy to add this to the BBCode version)
bold
italics
Inline code
Code:
Code
blocks
- lists
- more list (it joins adjacent list elements appropriately)
1. numbered list (html generation for this is in the works)
65536. oddly ordered numbered list (github doesn't like it but it's a markdown feature)
Quote:
quote
more quote
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
- Somehow, colors???
- Code cleanup
- Bugfixing
- Escaping? Somehow?
- Nested lists? Somehow?
- 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?