remove unused svgo.js

This commit is contained in:
Patrick Low
2019-12-16 10:43:03 +08:00
parent 1660161188
commit f4bc59c65a
6 changed files with 0 additions and 208 deletions

View File

@@ -1,28 +0,0 @@
const shell = require('shelljs');
const cheerio = require('cheerio');
shell.ls('*.svg').forEach(svg => {
const fileName = svg.slice(0, -4);
const $ = cheerio.load(shell.cat(svg).toString(), {decodeEntities: false});
$('[id]').each((i, element) => {
const id = $(element).attr('id');
if (new RegExp(`^${fileName}-animejs`, 'i').test(id)) {
return;
}
if (!/^animejs/i.test(id)) {
$(element).attr('id', null);
} else {
$(element).attr('id', `${fileName}-${id}`);
}
});
$('svg').attr('width', null);
$('svg').attr('height', null);
$('svg').attr('id', fileName);
$('[font-family="Arial-BoldMT, Arial"]').each(updateFonts);
$('[font-family="ArialMT, Arial"]').each(updateFonts);
shell.ShellString($('body').html()).to(svg);
function updateFonts(index, element) {
$(element).attr('font-family', `-apple-system, BlinkMacSystemFont, 'avenir next', avenir, 'helvetica neue', helvetica, ubuntu, roboto, noto, 'segoe ui', arial, sans-serif`)
}
});

View File

@@ -1,36 +0,0 @@
const shell = require('shelljs');
const cheerio = require('cheerio');
shell.ls('*.svg').forEach(svg => {
const fileName = svg.slice(0, -4);
const $ = cheerio.load(shell.cat(svg).toString(), {decodeEntities: false});
const skipIds = []
$('[fill]').each((index, element) => {
const fill = $(element).attr('fill');
if (fill.startsWith('url(#')) {
skipIds.push(fill.substring(5, fill.length - 1))
}
});
$('[id]').each((i, element) => {
const id = $(element).attr('id');
if (skipIds.includes(id)) {
return;
}
if (new RegExp(`^${fileName}-animejs`, 'i').test(id)) {
return;
}
if (!/^animejs/i.test(id)) {
$(element).attr('id', null);
} else {
$(element).attr('id', `${fileName}-${id}`);
}
});
$('svg').attr('width', null);
$('svg').attr('height', null);
$('svg').attr('id', fileName);
$('[font-family]').each((index, element) => {
$(element).attr('font-family', null)
$(element).addClass('sans-serif')
});
shell.ShellString($('body').html()).to(svg);
});

View File

@@ -1,36 +0,0 @@
const shell = require('shelljs');
const cheerio = require('cheerio');
shell.ls('*.svg').forEach(svg => {
const fileName = svg.slice(0, -4);
const $ = cheerio.load(shell.cat(svg).toString(), {decodeEntities: false});
const skipIds = []
$('[fill]').each((index, element) => {
const fill = $(element).attr('fill');
if (fill.startsWith('url(#')) {
skipIds.push(fill.substring(5, fill.length - 1))
}
});
$('[id]').each((i, element) => {
const id = $(element).attr('id');
if (skipIds.includes(id)) {
return;
}
if (new RegExp(`^${fileName}-animejs`, 'i').test(id)) {
return;
}
if (!/^animejs/i.test(id)) {
$(element).attr('id', null);
} else {
$(element).attr('id', `${fileName}-${id}`);
}
});
$('svg').attr('width', null);
$('svg').attr('height', null);
$('svg').attr('id', fileName);
$('[font-family]').each((index, element) => {
$(element).attr('font-family', null)
$(element).addClass('sans-serif')
});
shell.ShellString($('body').html()).to(svg);
});

View File

@@ -1,36 +0,0 @@
const shell = require('shelljs');
const cheerio = require('cheerio');
shell.ls('*.svg').forEach(svg => {
const fileName = svg.slice(0, -4);
const $ = cheerio.load(shell.cat(svg).toString(), {decodeEntities: false});
const skipIds = []
$('[fill]').each((index, element) => {
const fill = $(element).attr('fill');
if (fill.startsWith('url(#')) {
skipIds.push(fill.substring(5, fill.length - 1))
}
});
$('[id]').each((i, element) => {
const id = $(element).attr('id');
if (skipIds.includes(id)) {
return;
}
if (new RegExp(`^${fileName}-animejs`, 'i').test(id)) {
return;
}
if (!/^animejs/i.test(id)) {
$(element).attr('id', null);
} else {
$(element).attr('id', `${fileName}-${id}`);
}
});
$('svg').attr('width', null);
$('svg').attr('height', null);
$('svg').attr('id', fileName);
$('[font-family]').each((index, element) => {
$(element).attr('font-family', null)
$(element).addClass('sans-serif')
});
shell.ShellString($('body').html()).to(svg);
});

View File

@@ -1,36 +0,0 @@
const shell = require('shelljs');
const cheerio = require('cheerio');
shell.ls('*.svg').forEach(svg => {
const fileName = svg.slice(0, -4);
const $ = cheerio.load(shell.cat(svg).toString(), {decodeEntities: false});
const skipIds = []
$('[fill]').each((index, element) => {
const fill = $(element).attr('fill');
if (fill.startsWith('url(#')) {
skipIds.push(fill.substring(5, fill.length - 1))
}
});
$('[id]').each((i, element) => {
const id = $(element).attr('id');
if (skipIds.includes(id)) {
return;
}
if (new RegExp(`^${fileName}-animejs`, 'i').test(id)) {
return;
}
if (!/^animejs/i.test(id)) {
$(element).attr('id', null);
} else {
$(element).attr('id', `${fileName}-${id}`);
}
});
$('svg').attr('width', null);
$('svg').attr('height', null);
$('svg').attr('id', fileName);
$('[font-family]').each((index, element) => {
$(element).attr('font-family', null)
$(element).addClass('sans-serif')
});
shell.ShellString($('body').html()).to(svg);
});

View File

@@ -1,36 +0,0 @@
const shell = require('shelljs');
const cheerio = require('cheerio');
shell.ls('*.svg').forEach(svg => {
const fileName = svg.slice(0, -4);
const $ = cheerio.load(shell.cat(svg).toString(), {decodeEntities: false});
const skipIds = []
$('[fill]').each((index, element) => {
const fill = $(element).attr('fill');
if (fill.startsWith('url(#')) {
skipIds.push(fill.substring(5, fill.length - 1))
}
});
$('[id]').each((i, element) => {
const id = $(element).attr('id');
if (skipIds.includes(id)) {
return;
}
if (new RegExp(`^${fileName}-animejs`, 'i').test(id)) {
return;
}
if (!/^animejs/i.test(id)) {
$(element).attr('id', null);
} else {
$(element).attr('id', `${fileName}-${id}`);
}
});
$('svg').attr('width', null);
$('svg').attr('height', null);
$('svg').attr('id', fileName);
$('[font-family]').each((index, element) => {
$(element).attr('font-family', null)
$(element).addClass('sans-serif')
});
shell.ShellString($('body').html()).to(svg);
});