1

I am using angular application. I want to convert the bbcode into plain text. Is there any any plugin or library or any method for it. I am accepting following data.

$scope.Currentdata= "[justify][size=2]New testing.Hello World.[/size][/justify]";

and i want to remove the bbcode and show plain text on my div.

<div id="showdata" name="showdata"></div>
Bhushan Khaladkar
  • 420
  • 1
  • 7
  • 20

2 Answers2

2

You can use the following plugin to parse :

https://github.com/DasRed/js-bbcode-parser

Use the following command:

bower install bbcode-parser --save

// use to create a clean parser
var parser = new BBCode({}, {})

// use default parser
var parser = BBCode.default

// configure the default parser with
BBCode.setCodes({});

console.log(BBCode.default.parse('This is a text[br]with HTML Break.'));
0

If you want to parse a string to blank text (not html), you can use JavaScript Patterns to filter out the tags.

Since all tags are basically [(/)x=y] you can remove anything between the square brackets and the brackets themselves.