Giter VIP home page Giter VIP logo

md2bbc's Introduction

md2bbc

a simple Markdown to BBCode parser. based coreyti/showdown

Stable live is on niggazwithattitu.de, alpha live is available at http://alfateam123.github.io/md2bbc

Usage

var text = "Markdown *rocks*."; //the text you want to convert
var converter = new Showdown.converter(converter_options); //create the converter
var bbcode = converter.makeBBCode(text); //converting your text
alert(bbcode);

You can read more in the @Tutorial, or read the @Reference

Dependencies and browser support

Fortunately, md2bbc does not need any external library to work. The tests may require to use QUnit.js, the testing library built for the jquery project.

Talking about browser support... John Fraser (the original developer of the library) supported a lot of old browsers.
We try to support them too, you can just try to run the tests and see it something becomes red.

notes

some things (like @user and #project features) were done for nerdz.eu. It's n-not I like t-this site or a-anything! @nerdzeu no baka! Feel free to modify them in order to support twitter or your favourite social network/website.

obligatory excited Charlotte

obligatory excited Charlotte

md2bbc's People

Contributors

robertof avatar winterthediplomat avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

md2bbc's Issues

# into md urls breaks it all.

[test #22](http://lol.asd)
->
[url=http://lol.asd]test [project]22[/url[/project]]
I'd expect it would be [url=http://lol.asd]test #22[/url]: the # and the @ inside the "title" of an url should not be parsed.

Dangerous heading conversion

When headings are parsed, an id attribute is set for the heading tag. The id value is the same as the text within the tag.

# Heading 1    -> <h1 id="heading1">Heading 1</h1>
### Heading 3  -> <h3 id="heading3">Heading 3</h3>

Heading 1
=========  -> <h1 id="heading1">Heading 1</h1>

Heading 2
---------  -> <h2 id="heading2">Heading 2</h2>

This behavior may cause conflicts if the new id generated matches an id already existing and in use, resulting in the website not working properly.

New and deprecated BBCode tags on nerdz

as seen on https://www.nerdz.eu/Nerdz:198

Deprecated

[youtube]http://www.youtube.com/watch?v=_ynuMmB91qM[/youtube]
[yt]http://www.youtube.com/watch?v=_ynuMmB91qM[/yt]

These tags will be dropped.

New tags

[video]http://www.youtube.com/watch?v=XXXXXXXXXXX[/video] { it works on dailymotion.com - vimeo.com - facebook.com }
[twitter] https://twitter.com/PTKDev/status/290091113484808192 [/twitter] { even 290091113484808192 (the Tweet ID) is enough }
[spotify] track:artist:< id > [/spotify] { more on https://developer.spotify.com/technologies/widgets/spotify-play-button/ - or https://play.spotify.com/track/< id > }

Remove blank line after closing bbcode tag

It's not a bug, just a matter of appearance.
While empty lines in Markdown are used with the sole purpose of dividing "blocks", during the conversion from BBCode to HTML each new line feed in BBCode is converted into a new line HTML tag (<br/>). This means that blocks like quotes which usually have already a bottom margin of their own will see this margin increased (and there's no way at the moment to avoid this since you need to leave a line empty for a block to be recognized by the parser).

Extensions and single backticks shouldn't be parsed inside code sections

```perl
use Data::Dumper;
print '@lol';
print "#md2bbc";
print "~~deleted~~";
print Dumper($val);
print "do you wanna use `lol` ?"; 
\```

in md2bbc, this snippet generates

[code=perl]
use Data::Dumper;
print '[lol](https://nerdz.eu/lol.)';
print "[md2bbc](https://nerdz.eu/md2bbc:)";
print "[del]deleted[/del]";
print Dumper($val);
print "do you wanna use [code]lol[/code] ?"; 
[/code]

This means that extensions applied before the parsing are (incorrectly, in this case) applied into the code sections. The single backtick (that's not an extension) is incorrectly parsed too.

The syntax reference on code tags specifies

Regular Markdown syntax is not processed within code blocks. E.g., asterisks are just literal asterisks within a code block. This means it’s also easy to use Markdown to write about Markdown’s own syntax.

md into BBCode [code] is converted

[code=md]
![](http://google.com/save_it_bro.pl)
<http://google.com/save_it_bro.pl>
[/code]

\```md
![](http://google.com/save_it_bro.pl)
<http://google.com/save_it_bro.pl>
\```

is parsed to

[code=md]
[img]http://google.com/save_it_bro.pl[/img]
[url]http://google.com/save_it_bro.pl[/url]
[/code]
[code=md]
![](http://google.com/save_it_bro.pl)
<http://google.com/save_it_bro.pl>
[/code]

Probably, other "special" tags (e.g. [url]) are not recognized.
We don't have any test regarding these bbc/md mixes

"Clever" multi-line quoting

When quoting text using '>' at the beginning of each line, make the empty line optional.

Usually, you need to leave an empty line after the last line you quoted, like this:

> quoted text
> quoted text

not quoted text

Make that empty line optional, so that it works even like this:

> quoted text
> quoted text
not quoted text

The main reason is that when people quote multiple lines like this, they highlight each quoted line with '>' at the beginning, so it's already clear what has to be included in the quote bbcode and what has not to be included.
It's also the way some people (including me) are used to, and everybody knows that habits die hard (<3).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.