
Security News
npm Introduces minimumReleaseAge and Bulk OIDC Configuration
npm rolls out a package release cooldown and scalable trusted publishing updates as ecosystem adoption of install safeguards grows.
ibs-format
Advanced tools
Detect the user-defined identifiers in the text and convert them into HTML tags like bold, italic, strike, and many more having XSS (Cross-site scripting) security with escaping functionality, also detect the links like URLs, email, and IP addresses and w
Text formatting in Javascript. Detect the user-defined identifiers in the text and convert them into HTML tags like bold, italic, strike, and many more having XSS (Cross-site scripting) security with escaping functionality, also detect the links like URLs, email, and IP addresses and wrap them into Anchor tag <a> with also other user define formatting.
Fully supported and tested, over Google Chrome, Microsoft Edge, Mozilla Firefox and Internet Explorer 11.
npm i ibs-format --save
import { ibsFormat } from 'ibs-format';
For formatting the function 'ibsFormat' needs two arguments.
var myText = "Once upon a time, there was a *thristy* ~_crow_~."
In the array, the tag symbols in the first index and their identifier in the second index.
var tagArray = [['b','*'],['i','_'],['strike','~'],["mark","!"]];
myText = ibsFormat(myText, tagArray);
Once upon a time, there was a <b>thristy</b> <strike><i>crow</i></strike>.
<p [innerHTML]="myText"></p>
Once upon a time, there was a thristy crow.
For auto detecting links in to the text and converting them to HTML <a> tags, the function 'ibsFormat' needs three arguments
var myText = "The *best* website for learning _JS_ is https://www.w3schools.com/ and my email is info@myemail.com."
var tagArray = [['b','*'],['i','_'],['strike','~'],["mark","!"]];
var obj = {detectLinks: true, target: '_blank'};
myText = ibsFormat(myText, tagArray, obj);
The <b>best</b> website for learning <i>JS</i> is <a href='https://www.w3schools.com/' target='_blank'>https://www.w3schools.com/</a>
and my email is <a href='mailto:info@myemail.com' target='_blank'>info@myemail.com</a>.
The best website for learning JS is https://www.w3schools.com/ and my email is info@myemail.com.
myText = ibsFormat(myText, null, obj);
XSS attacks enable attackers to inject client-side scripts into web pages viewed by other users. In order to prevent those scripts, the client side tags are converted into nonexecutable through escaping. These security checks are enabled by default and it is recommended to keep them enabled, but in order to bypass these security checks place a forth argument in the function.
Place a JSON object in the forth argument and set it's value to false, if the forth argument is missing then it's value will be true by default.
myText = ibsFormat(myText, tagArray, obj, { allowXssEscaping : false });
In order to format the text at run time in HTML, create a custom pipe and use the function there.
import { Pipe, PipeTransform } from '@angular/core';
import { ibsFormat } from "ibs-format";
@Pipe({ name: 'ibsformat' })
export class ibsformatPipe implements PipeTransform {
transform(value: any, args?: any): any {
value = ibsFormat(value, [["b", "*"], ["i", "_"], ["strike", "~"],["mark","!"]],{ detectLinks: true, target: "_blank" });
return value;
}
}
import { ibsformatPipe } from './custom-pipe.pipe';
// also add in declarations array
@NgModule({
declarations: [ AppComponent, ibsformatPipe ],
})
<p [innerHTML]="myText | ibsformat"></p>
If you do not want to use the built-in 'detectLinks' functionality and want to use any other library for detecting the links, like 'ngx-linkifyjs', so after installing and configuring the 'ngx-linkifyjs' you can use the 'linkify' pipe before the 'ibsFormat' pipe, and set the library's 'detectLinks' and 'allowXssEscaping' properties to false.
<p [innerHTML]="myText | linkify | ibsformat"></p>
value = ibsFormat(
value,
[["b", "*"], ["i", "_"], ["strike", "~"], ["mark", "!"]],
{ detectLinks: false, target: "_blank" },
{ allowXssEscaping: false }
)
For full example of custom pipe, see the live demo mention above.
FAQs
Detect the user-defined identifiers in the text and convert them into HTML tags like bold, italic, strike, and many more having XSS (Cross-site scripting) security with escaping functionality, also detect the links like URLs, email, and IP addresses and w
The npm package ibs-format receives a total of 27 weekly downloads. As such, ibs-format popularity was classified as not popular.
We found that ibs-format demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
npm rolls out a package release cooldown and scalable trusted publishing updates as ecosystem adoption of install safeguards grows.

Security News
AI agents are writing more code than ever, and that's creating new supply chain risks. Feross joins the Risky Business Podcast to break down what that means for open source security.

Research
/Security News
Socket uncovered four malicious NuGet packages targeting ASP.NET apps, using a typosquatted dropper and localhost proxy to steal Identity data and backdoor apps.