nx-html-parser
v0.0.1
Published
# Authors
Readme
NxHtmlParser
Authors
- Name - Parag Kulkarni
- Email - [email protected]
✨ Your new, shiny Nx workspace is almost ready ✨.
Learn more about this workspace setup and its capabilities or run npx nx graph to visually explore what was created. Now, let's get you up to speed!
Finish your CI setup
Click here to finish setting up your workspace!
Run tasks
To run the dev server for your app, use:
npx nx serve app/app-html-parserTo create a production bundle:
npx nx build app/app-html-parserTo see all available targets to run for a project, run:
npx nx show project app/app-html-parserThese targets are either inferred automatically or defined in the project.json or package.json files.
More about running tasks in the docs »
Add new projects
While you could add new projects to your workspace manually, you might want to leverage Nx plugins and their code generation feature.
Use the plugin's generator to create new projects.
To generate a new application, use:
npx nx g @nx/angular:app demoTo generate a new library, use:
npx nx g @nx/angular:lib mylibYou can use npx nx list to get a list of installed plugins. Then, run npx nx list <plugin-name> to learn about more specific capabilities of a particular plugin. Alternatively, install Nx Console to browse plugins and generators in your IDE.
Learn more about Nx plugins » | Browse the plugin registry »
Install Nx Console
Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ.
Useful links
Learn more:
- Learn more about this workspace setup
- Learn about Nx on CI
- Releasing Packages with Nx release
- What are Nx plugins?
And join the Nx community:
nx-html-parser A security-focused utility library for Angular/Nx workspaces designed to validate HTML strings against XSS vulnerabilities. It uses a strict blacklist approach based on OWASP guidelines to ensure malicious tags are never rendered.
🚀 Installation & Download Option 1: Via NPM (Recommended)
npm install nx-html-parser
⚙️ CompatibilityLibrary VersionAngular VersionNx Versionv1.x.x^14.0.0 - ^16.0.0^14.0.0+v2.x.x^17.0.0 - ^18.0.0^18.0.0+
📖 Usage The library provides an InjectionToken called HtmlParser which provides the securedHTML logic.
- Component Logic Inject the token into your Angular component to access the validation function.
import { Component, Inject } from '@angular/core'; import { HtmlParser } from 'nx-html-parser';
@Component({ selector: 'app-parser-demo', templateUrl: './app.component.html' }) export class AppParserComponent { htmlContent = 'Safe Content';
constructor( @Inject(HtmlParser) public htmlParser: (input: string) => string ) {} }
- UI Implementation (HTML) The following structure demonstrates how the parser interacts with your view:
⚠️ Security Behavior The HtmlParser is fail-fast.
Safe Input: Returns the string exactly as provided.
Unsafe Input: Throws an Error: XSS : Insecure HTML tags detected as per OWASP guidelines.
Note: Always wrap calls to htmlParser in a try...catch block in your component to handle security violations gracefully without breaking the UI.
