Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion svg-join.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const argv = require('yargs')
describe: 'file name (with ext.) for CSS bundle (if different)' },
'p': { alias: 'prefix', type: 'string', default: 'svg_',
describe: 'prefix for CSS selectors' },
'symbolPrefix': { type: 'string', describe: 'prefix for SVG symbol IDs' },
'm': { alias: 'mono', type: 'boolean', default: false,
describe: 'extract presentation attributes from single-styled SVG to CSS' },
'calcSide': { type: 'boolean', default: false,
Expand All @@ -80,6 +81,8 @@ const argv = require('yargs')
'Will create mybundle.svg and mybundle.css in public folder.')
.example('svg-join -s "/your/path/**/*.svg"',
'Find SVG files in subfolders.')
.example('svg-join -s "/your/path/**/*.svg" --symbolPrefix icon-',
'Find SVG files in subfolders and prefix all SVG symbol IDs with icon-.')
.strict()
.argv

Expand Down Expand Up @@ -149,7 +152,7 @@ glob.globAsync(argv.source, { nocase: true }).filter(x => x !== svgout).map(fnam
Object.keys(doc.attr).forEach(x => {
if (!preserve.has(x.toLowerCase())) delete doc.attr[x]
})
doc.attr.id = path.basename(fname, path.extname(fname)).replace(/\s/g, '_').replace(/['"]/g, '')
doc.attr.id = argv.symbolPrefix + path.basename(fname, path.extname(fname)).replace(/\s/g, '_').replace(/['"]/g, '')
rule.name = argv.prefix + CSS_escape(doc.attr.id)

if (argv.mono) {
Expand Down