ovh-iconlib-provider-svg-cleaner

0.1.2 • Public • Published

Icon Library - SVG cleaner

Build Status Coverage Status

NPM

SVG Cleaner Provider used to define a contract for all svg cleaning process in the Icon Library project.

SvgCleanerBaseProvider

Methods to implement

  • abstract class SvgCleanerBaseProvider
    • abstract function clean(string svg)

Implementations

  • Svgo (ovh-iconlib-provider-svg-cleaner-svgo)

License

See LICENSE file


Svgo example

Installation

npm install --save "ovh-iconlib-provider-svg-cleaner" "ovh-iconlib-provider-svg-cleaner-svgo"

Configuration

#config.yml 
---
 svg-cleaner:
   default: svgo
   providers:
     -
       name: svgo
       type: ovh-iconlib-provider-svg-cleaner-svgo
       plugins:
         - ovh-iconlib-provider-svg-cleaner-svgo/lib/plugins/agressiveCollapseGroups
         - ovh-iconlib-provider-svg-cleaner-svgo/lib/plugins/removeClipPaths
         - ovh-iconlib-provider-svg-cleaner-svgo/lib/plugins/cleanStyles

Usage

// default instance loaded according to the configuration
const svg = require('ovh-iconlib-provider-svg-cleaner').getInstance();
 
const dirty = '<svg xmlns="http://www.w3.org/2000/svg">...</svg>';
const pristine = '<svg xmlns="http://www.w3.org/2000/svg">...</svg>';
 
svg.clean(dirty)
    .then(result => {
        if (result !== pristine) {
            throw new Error('something went wrong');
        }
 
        ...
    });

Package Sidebar

Install

npm i ovh-iconlib-provider-svg-cleaner

Weekly Downloads

0

Version

0.1.2

License

BSD-3-Clause

Last publish

Collaborators

  • jisay
  • blary_jp
  • antleblanc
  • cbourgois
  • ovh-ux-cds
  • lizardk
  • ovh
  • marie-j