You can help CodeWalrus stay online by donating here. | New CodeWalrus | Old (dark mode) | Old (light) | Discord server

Markdown to HTML and BBCode!

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

0
b/Web publicado por u/_iPhoenix_ June 04, 2018, 05:59:15 AM
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
blocks


  • lists
  • more list (it joins adjacent list elements appropriately) 

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?
Inicia sesión o crea una cuenta para dejar un comentario
u/gameblabla 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
u/_iPhoenix_ June 04, 2018, 07:05:56 PM
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

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

b/Web

Website developement and scripting

68
Topics
Explore Board
Website statistics


MyCalcs | Ticalc.org | Cemetech | Omnimaga | TI-Basic Developer | MaxCoderz | TI-Story | Casiocalc.org | Casiopeia | The Museum of HP Calculators | HPCalc.org | CnCalc.org | Music 2000 Community | TI Education | Casio Education | HP Calcs | NumWorks | SwissMicros | Sharp Calculators
Powered by EzPortal