Closed tobiasegli closed 4 years ago
Probably a parsing issue, I'll try to have a look on this if I can manage to get some free time.
Not only octicons, but also some icons from https://simpleicons.org/ e.g. jsfiddle
<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>JSFiddle icon</title><path d="M13.9 3.602c-2.749 0-5.103 1.544-6.35 3.779-.536-.317-1.139-.54-1.806-.54-1.981 0-3.6 1.606-3.6 3.579 0 .263.063.513.118.762C.912 12.09 0 13.602 0 15.344c0 2.763 2.241 5.012 5.008 5.054a.421.421 0 00.008 0h14c2.746.017 4.984-2.206 4.984-4.937 0-1.946-1.153-3.602-2.799-4.41.003-.062.01-.115.01-.184 0-4.008-3.28-7.265-7.31-7.265zm0 .843c3.58 0 6.47 2.872 6.47 6.422 0 .115-.012.242-.02.387a.421.421 0 00.26.414 4.104 4.104 0 012.546 3.793 4.094 4.094 0 01-4.135 4.096.421.421 0 00-.003 0H5.02C2.702 19.52.844 17.653.844 15.344c0-1.545.834-2.883 2.08-3.62a.421.421 0 00.187-.49 2.701 2.701 0 01-.125-.814 2.741 2.741 0 012.758-2.736 2.75 2.75 0 011.686.576.421.421 0 00.636-.15A6.462 6.462 0 0113.9 4.444zm-5.33 6.877c-1.586 0-2.91 1.213-2.91 2.737 0 1.523 1.324 2.736 2.91 2.736 1.411 0 2.182-.931 2.496-1.266a.421.421 0 10-.613-.578c-.378.402-.819 1.002-1.883 1.002-1.162 0-2.068-.86-2.068-1.894 0-1.035.906-1.895 2.068-1.895.533 0 1.105.297 1.686.77.372.303.737.668 1.098 1.043a.421.421 0 00.085.123c.533.552 1.122 1.205 1.774 1.736.652.531 1.386.959 2.217.959 1.586 0 2.91-1.213 2.91-2.736 0-1.524-1.324-2.737-2.91-2.737-1.411 0-2.182.931-2.496 1.266a.421.421 0 10.613.578c.378-.402.819-1.002 1.883-1.002 1.162 0 2.068.86 2.068 1.895 0 1.034-.906 1.894-2.068 1.894-.533 0-1.105-.297-1.686-.77-.372-.303-.737-.67-1.098-1.044a.421.421 0 00-.085-.121c-.533-.552-1.122-1.208-1.774-1.739-.652-.53-1.386-.957-2.217-.957Z"/></svg>
Expected a flag, got "000" at index "76"
It's not working with bootstrap icons.
<svg class="bi bi-alarm" width="1em" height="1em" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M10 17a6 6 0 100-12 6 6 0 000 12zm0 1a7 7 0 100-14 7 7 0 000 14z" clip-rule="evenodd"/>
<path fill-rule="evenodd" d="M10 6.5a.5.5 0 01.5.5v4a.5.5 0 01-.053.224l-1.5 3a.5.5 0 11-.894-.448L9.5 10.882V7a.5.5 0 01.5-.5z" clip-rule="evenodd"/>
<path d="M2.86 7.387A2.5 2.5 0 116.387 3.86 8.035 8.035 0 002.86 7.387zM13.613 3.86a2.5 2.5 0 113.527 3.527 8.035 8.035 0 00-3.527-3.527z"/>
<path fill-rule="evenodd" d="M13.646 16.146a.5.5 0 01.708 0l1 1a.5.5 0 01-.708.708l-1-1a.5.5 0 010-.708zm-7.292 0a.5.5 0 00-.708 0l-1 1a.5.5 0 00.708.708l1-1a.5.5 0 000-.708zM7.5 2.5A.5.5 0 018 2h4a.5.5 0 010 1H8a.5.5 0 01-.5-.5z" clip-rule="evenodd"/>
<path d="M9 3h2v2H9V3z"/>
</svg>
expected a flag, got "01.708" at index "28"
Also, it didn't works with ant design icons
<?xml version="1.0" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 1024 1024">
<path d="M880 184H712v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H384v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H144c-17.7 0-32 14.3-32 32v664c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V216c0-17.7-14.3-32-32-32zM648.3 426.8l-87.7 161.1h45.7c5.5 0 10 4.5 10 10v21.3c0 5.5-4.5 10-10 10h-63.4v29.7h63.4c5.5 0 10 4.5 10 10v21.3c0 5.5-4.5 10-10 10h-63.4V752c0 5.5-4.5 10-10 10h-41.3c-5.5 0-10-4.5-10-10v-51.8h-63.1c-5.5 0-10-4.5-10-10v-21.3c0-5.5 4.5-10 10-10h63.1v-29.7h-63.1c-5.5 0-10-4.5-10-10v-21.3c0-5.5 4.5-10 10-10h45.2l-88-161.1c-2.6-4.8-.9-10.9 4-13.6 1.5-.8 3.1-1.2 4.8-1.2h46c3.8 0 7.2 2.1 8.9 5.5l72.9 144.3 73.2-144.3a10 10 0 0 1 8.9-5.5h45c5.5 0 10 4.5 10 10 .1 1.7-.3 3.3-1.1 4.8z"/>
</svg>
Expected a flag, got "018.9" at index "634".
Another one with maki icons
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15"><path d="M13 5H8V2.6a1 1 0 00.42-.46l5.08-.64a.5.5 0 000-1l-5.22.65a1 1 0 00-.78-.4 1 1 0 00-.92.62L1.5 2a.5.5 0 000 1l5.22-.65c.077.1.172.185.28.25V5H2a1 1 0 00-1 1v7a1 1 0 001 1h11a1 1 0 001-1V6a1 1 0 00-1-1zm-6 6H3V7h4v4zm5 0H8V7h4v4z"/></svg>
Expected a flag, got "00.42" at index "23".
Another one with unicons
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18 5h1v1a1 1 0 002 0V5h1a1 1 0 000-2h-1V2a1 1 0 00-2 0v1h-1a1 1 0 000 2zm-5.5 1h-1a3 3 0 00-3 3v6a3 3 0 003 3h1a3 3 0 003-3V9a3 3 0 00-3-3zm1 9a1 1 0 01-1 1h-1a1 1 0 01-1-1V9a1 1 0 011-1h1a1 1 0 011 1zm8.1-6a1 1 0 00-.78 1.18 9 9 0 11-7-7 1 1 0 10.4-2A10.8 10.8 0 0012 1a11 11 0 1011 11 10.8 10.8 0 00-.22-2.2A1 1 0 0021.6 9z"/></svg>
Expected a flag, got "002" at index "19".
Hi folks, just gave it a quick try, looks like it is fine now, please provide feedback before we can merge. Sorry for the latency.
https://github.com/nfroidure/svg-pathdata/pull/37
This lib need a refacto of its toolings and probably its core features but not that much time to help, I created a GH Sponsors profile, let's wait n' see.
Hi @nfroidure, Thanks for the quick fix!!!!! It do fix some svgs. But there still have some icons's path not parsing correctly.
I write some tests, maybe it will help you.
it('of kaptinlin bug report bootstrap-icons box-arrow-up-right', () => {
assert.equal(new SVGPathData('M3.5 15A1.5 1.5 0 005 16.5h8a1.5 1.5 0 001.5-1.5v-4a.5.5 0 00-1 0v4a.5.5 0 01-.5.5H5a.5.5 0 01-.5-.5V7a.5.5 0 01.5-.5h4a.5.5 0 000-1H5A1.5 1.5 0 003.5 7v8zm7-11a.5.5 0 01.5-.5h5a.5.5 0 01.5.5v5a.5.5 0 01-1 0V4.5H11a.5.5 0 01-.5-.5z').toAbs().round(1000).encode(), 'M3.5 15A1.5 1.5 0 005 16.5h8a1.5 1.5 0 001.5-1.5v-4a.5.5 0 00-1 0v4a.5.5 0 01-.5.5H5a.5.5 0 01-.5-.5V7a.5.5 0 01.5-.5h4a.5.5 0 000-1H5A1.5 1.5 0 003.5 7v8zm7-11a.5.5 0 01.5-.5h5a.5.5 0 01.5.5v5a.5.5 0 01-1 0V4.5H11a.5.5 0 01-.5-.5z');
});
it('of kaptinlin bug report bootstrap-icons bootstrap', () => {
assert.equal(new SVGPathData('M14 3H6a3 3 0 00-3 3v8a3 3 0 003 3h8a3 3 0 003-3V6a3 3 0 00-3-3zM6 2a4 4 0 00-4 4v8a4 4 0 004 4h8a4 4 0 004-4V6a4 4 0 00-4-4H6z').toAbs().round(1000).encode(), 'M14 3H6a3 3 0 00-3 3v8a3 3 0 003 3h8a3 3 0 003-3V6a3 3 0 00-3-3zM6 2a4 4 0 00-4 4v8a4 4 0 004 4h8a4 4 0 004-4V6a4 4 0 00-4-4H6z');
});
it('of kaptinlin bug report bootstrap-icons camera', () => {
assert.equal(new SVGPathData('M16.333 5h-2.015A5.97 5.97 0 0011 4a5.972 5.972 0 00-3.318 1H3.667C2.747 5 2 5.746 2 6.667v6.666C2 14.253 2.746 15 3.667 15h4.015c.95.632 2.091 1 3.318 1a5.973 5.973 0 003.318-1h2.015c.92 0 1.667-.746 1.667-1.667V6.667C18 5.747 17.254 5 16.333 5zM3.5 7a.5.5 0 100-1 .5.5 0 000 1zm7.5 8a5 5 0 100-10 5 5 0 000 10z').toAbs().round(1000).encode(), 'M16.333 5h-2.015A5.97 5.97 0 0011 4a5.972 5.972 0 00-3.318 1H3.667C2.747 5 2 5.746 2 6.667v6.666C2 14.253 2.746 15 3.667 15h4.015c.95.632 2.091 1 3.318 1a5.973 5.973 0 003.318-1h2.015c.92 0 1.667-.746 1.667-1.667V6.667C18 5.747 17.254 5 16.333 5zM3.5 7a.5.5 0 100-1 .5.5 0 000 1zm7.5 8a5 5 0 100-10 5 5 0 000 10z');
});
it('of kaptinlin bug report bootstrap-icons bucket', () => {
assert.equal(new SVGPathData('M10 3.5A4.5 4.5 0 005.5 8h-1a5.5 5.5 0 1111 0h-1A4.5 4.5 0 0010 3.5z" clip-rule="evenodd').toAbs().round(1000).encode(), 'M10 3.5A4.5 4.5 0 005.5 8h-1a5.5 5.5 0 1111 0h-1A4.5 4.5 0 0010 3.5z" clip-rule="evenodd');
});
it('of kaptinlin bug report bootstrap-icons check-box', () => {
assert.equal(new SVGPathData('M3.5 15A1.5 1.5 0 005 16.5h10a1.5 1.5 0 001.5-1.5v-5a.5.5 0 00-1 0v5a.5.5 0 01-.5.5H5a.5.5 0 01-.5-.5V5a.5.5 0 01.5-.5h8a.5.5 0 000-1H5A1.5 1.5 0 003.5 5v10z').toAbs().round(1000).encode(), 'M3.5 15A1.5 1.5 0 005 16.5h10a1.5 1.5 0 001.5-1.5v-5a.5.5 0 00-1 0v5a.5.5 0 01-.5.5H5a.5.5 0 01-.5-.5V5a.5.5 0 01.5-.5h8a.5.5 0 000-1H5A1.5 1.5 0 003.5 5v10z');
});
it('of kaptinlin bug report bootstrap-icons diamond-half', () => {
assert.equal(new SVGPathData('M8.94 2.354a1.5 1.5 0 012.12 0l6.586 6.585a1.5 1.5 0 010 2.122l-6.585 6.585a1.5 1.5 0 01-2.122 0l-6.585-6.585a1.5 1.5 0 010-2.122l6.585-6.585zm1.06.56a.498.498 0 00-.354.147L3.061 9.646a.5.5 0 000 .707l6.585 6.586a.499.499 0 00.354.147V2.914z').toAbs().round(1000).encode(), 'M8.94 2.354a1.5 1.5 0 012.12 0l6.586 6.585a1.5 1.5 0 010 2.122l-6.585 6.585a1.5 1.5 0 01-2.122 0l-6.585-6.585a1.5 1.5 0 010-2.122l6.585-6.585zm1.06.56a.498.498 0 00-.354.147L3.061 9.646a.5.5 0 000 .707l6.585 6.586a.499.499 0 00.354.147V2.914z');
});
it('of kaptinlin bug report bootstrap-icons document', () => {
assert.equal(new SVGPathData('M6 3h8a2 2 0 012 2v10a2 2 0 01-2 2H6a2 2 0 01-2-2V5a2 2 0 012-2zm0 1a1 1 0 00-1 1v10a1 1 0 001 1h8a1 1 0 001-1V5a1 1 0 00-1-1H6z').toAbs().round(1000).encode(), 'M6 3h8a2 2 0 012 2v10a2 2 0 01-2 2H6a2 2 0 01-2-2V5a2 2 0 012-2zm0 1a1 1 0 00-1 1v10a1 1 0 001 1h8a1 1 0 001-1V5a1 1 0 00-1-1H6z');
});
it('of kaptinlin bug report bootstrap-icons trash', () => {
assert.equal(new SVGPathData('M7.5 7.5A.5.5 0 018 8v6a.5.5 0 01-1 0V8a.5.5 0 01.5-.5zm2.5 0a.5.5 0 01.5.5v6a.5.5 0 01-1 0V8a.5.5 0 01.5-.5zm3 .5a.5.5 0 00-1 0v6a.5.5 0 001 0V8z').toAbs().round(1000).encode(), 'M7.5 7.5A.5.5 0 018 8v6a.5.5 0 01-1 0V8a.5.5 0 01.5-.5zm2.5 0a.5.5 0 01.5.5v6a.5.5 0 01-1 0V8a.5.5 0 01.5-.5zm3 .5a.5.5 0 00-1 0v6a.5.5 0 001 0V8z');
});
it('of kaptinlin bug report bootstrap-icons tv-fill', () => {
assert.equal(new SVGPathData('M4.5 15.5A.5.5 0 015 15h10a.5.5 0 010 1H5a.5.5 0 01-.5-.5zM4 4h12s2 0 2 2v6s0 2-2 2H4s-2 0-2-2V6s0-2 2-2z').toAbs().round(1000).encode(), 'M4.5 15.5A.5.5 0 015 15h10a.5.5 0 010 1H5a.5.5 0 01-.5-.5zM4 4h12s2 0 2 2v6s0 2-2 2H4s-2 0-2-2V6s0-2 2-2z');
});
it('of kaptinlin bug report bootstrap-icons unlock-fill', () => {
assert.equal(new SVGPathData('M2.5 10a2 2 0 012-2h7a2 2 0 012 2v5a2 2 0 01-2 2h-7a2 2 0 01-2-2v-5z').toAbs().round(1000).encode(), 'M2.5 10a2 2 0 012-2h7a2 2 0 012 2v5a2 2 0 01-2 2h-7a2 2 0 01-2-2v-5z');
});
it('of kaptinlin bug report bootstrap-icons watch', () => {
assert.equal(new SVGPathData('M6 16.333v-1.86A5.985 5.985 0 014 10c0-1.777.772-3.374 2-4.472V3.667C6 2.747 6.746 2 7.667 2h4.666C13.253 2 14 2.746 14 3.667v1.86A5.985 5.985 0 0116 10a5.985 5.985 0 01-2 4.472v1.861c0 .92-.746 1.667-1.667 1.667H7.667C6.747 18 6 17.254 6 16.333zM15 10a5 5 0 10-10 0 5 5 0 0010 0z').toAbs().round(1000).encode(), 'M6 16.333v-1.86A5.985 5.985 0 014 10c0-1.777.772-3.374 2-4.472V3.667C6 2.747 6.746 2 7.667 2h4.666C13.253 2 14 2.746 14 3.667v1.86A5.985 5.985 0 0116 10a5.985 5.985 0 01-2 4.472v1.861c0 .92-.746 1.667-1.667 1.667H7.667C6.747 18 6 17.254 6 16.333zM15 10a5 5 0 10-10 0 5 5 0 0010 0z');
});
it('of kaptinlin bug report bootstrap-icons wrench', () => {
assert.equal(new SVGPathData('M2.102 4.223A3.004 3.004 0 005 8c.27 0 .532-.036.78-.103l6.342 6.252A3.003 3.003 0 0015 18a3 3 0 10-.851-5.878L7.897 5.781A3.004 3.004 0 004.223 2.1l2.141 2.142L6 6l-1.757.364-2.141-2.141zm13.37 9.019L15 13l-.471.242-.529.026-.287.445-.445.287-.026.529L13 15l.242.471.026.529.445.287.287.445.529.026L15 17l.471-.242.529-.026.287-.445.445-.287.026-.529L17 15l-.242-.471-.026-.529-.445-.287-.287-.445-.529-.026z').toAbs().round(1000).encode(), 'M2.102 4.223A3.004 3.004 0 005 8c.27 0 .532-.036.78-.103l6.342 6.252A3.003 3.003 0 0015 18a3 3 0 10-.851-5.878L7.897 5.781A3.004 3.004 0 004.223 2.1l2.141 2.142L6 6l-1.757.364-2.141-2.141zm13.37 9.019L15 13l-.471.242-.529.026-.287.445-.445.287-.026.529L13 15l.242.471.026.529.445.287.287.445.529.026L15 17l.471-.242.529-.026.287-.445.445-.287.026-.529L17 15l-.242-.471-.026-.529-.445-.287-.287-.445-.529-.026z');
});
it('of kaptinlin bug report bootstrap-icons x-octagon', () => {
assert.equal(new SVGPathData('M6.54 2.146A.5.5 0 016.893 2h6.214a.5.5 0 01.353.146l4.394 4.394a.5.5 0 01.146.353v6.214a.5.5 0 01-.146.353l-4.394 4.394a.5.5 0 01-.353.146H6.893a.5.5 0 01-.353-.146L2.146 13.46A.5.5 0 012 13.107V6.893a.5.5 0 01.146-.353L6.54 2.146zM7.1 3L3 7.1v5.8L7.1 17h5.8l4.1-4.1V7.1L12.9 3H7.1z').toAbs().round(1000).encode(), 'M6.54 2.146A.5.5 0 016.893 2h6.214a.5.5 0 01.353.146l4.394 4.394a.5.5 0 01.146.353v6.214a.5.5 0 01-.146.353l-4.394 4.394a.5.5 0 01-.353.146H6.893a.5.5 0 01-.353-.146L2.146 13.46A.5.5 0 012 13.107V6.893a.5.5 0 01.146-.353L6.54 2.146zM7.1 3L3 7.1v5.8L7.1 17h5.8l4.1-4.1V7.1L12.9 3H7.1z');
});
it('of kaptinlin bug report bootstrap-icons x-square-fill', () => {
assert.equal(new SVGPathData('M4 2a2 2 0 00-2 2v12a2 2 0 002 2h12a2 2 0 002-2V4a2 2 0 00-2-2H4zm3.354 4.646L10 9.293l2.646-2.647a.5.5 0 01.708.708L10.707 10l2.647 2.646a.5.5 0 01-.708.708L10 10.707l-2.646 2.647a.5.5 0 01-.708-.708L9.293 10 6.646 7.354a.5.5 0 11.708-.708z').toAbs().round(1000).encode(), 'M4 2a2 2 0 00-2 2v12a2 2 0 002 2h12a2 2 0 002-2V4a2 2 0 00-2-2H4zm3.354 4.646L10 9.293l2.646-2.647a.5.5 0 01.708.708L10.707 10l2.647 2.646a.5.5 0 01-.708.708L10 10.707l-2.646 2.647a.5.5 0 01-.708-.708L9.293 10 6.646 7.354a.5.5 0 11.708-.708z');
});
it('of kaptinlin bug report maki-icons alcohol-shop', () => {
assert.equal(new SVGPathData('M14 4h-4v3.5a2 2 0 001.5 1.93V13H11a.5.5 0 000 1h2a.5.5 0 000-1h-.5V9.43A2 2 0 0014 7.5V4zm-1 3.5a1 1 0 11-2 0V5h2v2.5zm-7.5-5V2a.5.5 0 000-1V.5A.5.5 0 005 0H4a.5.5 0 00-.5.5V1a.5.5 0 000 1v.5C3.5 3.93 1 5.57 1 7v6a1 1 0 001 1h5a1.1 1.1 0 001-1V7c0-1.35-2.5-3.15-2.5-4.5zm-1 9.5a2.5 2.5 0 110-5 2.5 2.5 0 010 5z').toAbs().round(1000).encode(), 'M14 4h-4v3.5a2 2 0 001.5 1.93V13H11a.5.5 0 000 1h2a.5.5 0 000-1h-.5V9.43A2 2 0 0014 7.5V4zm-1 3.5a1 1 0 11-2 0V5h2v2.5zm-7.5-5V2a.5.5 0 000-1V.5A.5.5 0 005 0H4a.5.5 0 00-.5.5V1a.5.5 0 000 1v.5C3.5 3.93 1 5.57 1 7v6a1 1 0 001 1h5a1.1 1.1 0 001-1V7c0-1.35-2.5-3.15-2.5-4.5zm-1 9.5a2.5 2.5 0 110-5 2.5 2.5 0 010 5z');
});
it('of kaptinlin bug report maki-icons baseball', () => {
assert.equal(new SVGPathData('M10 3.5a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0zM7 .28A.28.28 0 006.72 0a.49.49 0 00-.25.16L4 4.59a.48.48 0 000 .13c0 .155.125.28.28.28a.49.49 0 00.26-.16L7 .41a.472.472 0 000-.13zm5.9 13.92L10 6.39A.49.49 0 009.52 6h-5a.5.5 0 000 1H7l1.45 2.51-4.27 4.61a.49.49 0 00-.18.38.5.5 0 00.5.5.49.49 0 00.33-.13l4.45-4.15 2.76 4a.51.51 0 00.44.26c.28 0 .51-.22.52-.5a.5.5 0 00-.1-.28z').toAbs().round(1000).encode(), 'M10 3.5a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0zM7 .28A.28.28 0 006.72 0a.49.49 0 00-.25.16L4 4.59a.48.48 0 000 .13c0 .155.125.28.28.28a.49.49 0 00.26-.16L7 .41a.472.472 0 000-.13zm5.9 13.92L10 6.39A.49.49 0 009.52 6h-5a.5.5 0 000 1H7l1.45 2.51-4.27 4.61a.49.49 0 00-.18.38.5.5 0 00.5.5.49.49 0 00.33-.13l4.45-4.15 2.76 4a.51.51 0 00.44.26c.28 0 .51-.22.52-.5a.5.5 0 00-.1-.28z');
});
it('of kaptinlin bug report maki-icons beach', () => {
assert.equal(new SVGPathData('M5.36 1.67l-.01 4.02a4.452 4.452 0 00-1.1-.11c-.37.1-.74.63-1.1.76a4.202 4.202 0 012.21-4.67zm2.41-.64L9.8 4.48a3.183 3.183 0 01.84-.61c.36-.1.94.17 1.34.11a4.202 4.202 0 00-4.21-2.95zM1 13h13c-.66-.66-2.64-1.11-4.34-1.33l-1.87-7c.52-.05 1.15.03 1.53 0l-2.11-3.6H7.2a6.174 6.174 0 00-.7.14 4.38 4.38 0 00-.64.22l-.01 4.15c.35-.17.84-.54 1.3-.74l1.8 6.74c-.58-.05-1.09-.08-1.45-.08C6.03 11.5 2 12 1 13z').toAbs().round(1000).encode(), 'M5.36 1.67l-.01 4.02a4.452 4.452 0 00-1.1-.11c-.37.1-.74.63-1.1.76a4.202 4.202 0 012.21-4.67zm2.41-.64L9.8 4.48a3.183 3.183 0 01.84-.61c.36-.1.94.17 1.34.11a4.202 4.202 0 00-4.21-2.95zM1 13h13c-.66-.66-2.64-1.11-4.34-1.33l-1.87-7c.52-.05 1.15.03 1.53 0l-2.11-3.6H7.2a6.174 6.174 0 00-.7.14 4.38 4.38 0 00-.64.22l-.01 4.15c.35-.17.84-.54 1.3-.74l1.8 6.74c-.58-.05-1.09-.08-1.45-.08C6.03 11.5 2 12 1 13z');
});
it('of kaptinlin bug report maki-icons cafe', () => {
assert.equal(new SVGPathData('M12 5h-2V3H2v4a4 4 0 007.45 2H12a2 2 0 100-4zm0 3H9.86A4 4 0 0010 7V6h2a1 1 0 110 2zm-2 4.5a.5.5 0 01-.5.5h-7a.5.5 0 010-1h7a.5.5 0 01.5.5z').toAbs().round(1000).encode(), 'M12 5h-2V3H2v4a4 4 0 007.45 2H12a2 2 0 100-4zm0 3H9.86A4 4 0 0010 7V6h2a1 1 0 110 2zm-2 4.5a.5.5 0 01-.5.5h-7a.5.5 0 010-1h7a.5.5 0 01.5.5z');
});
it('of kaptinlin bug report maki-icons car', () => {
assert.equal(new SVGPathData('M14 7a1.5 1.5 0 00-1.15-1.45l-1.39-3.24A.5.5 0 0011 2H4a.5.5 0 00-.44.28L2.15 5.54A1.5 1.5 0 001 7v3.5h1v1a1 1 0 102 0v-1h7v1a1 1 0 102 0v-1h1V7zM4.3 3h6.4l1.05 2.5h-8.5L4.3 3zM3 9a1 1 0 110-2 1 1 0 010 2zm9 0a1 1 0 110-2 1 1 0 010 2z').toAbs().round(1000).encode(), 'M14 7a1.5 1.5 0 00-1.15-1.45l-1.39-3.24A.5.5 0 0011 2H4a.5.5 0 00-.44.28L2.15 5.54A1.5 1.5 0 001 7v3.5h1v1a1 1 0 102 0v-1h7v1a1 1 0 102 0v-1h1V7zM4.3 3h6.4l1.05 2.5h-8.5L4.3 3zM3 9a1 1 0 110-2 1 1 0 010 2zm9 0a1 1 0 110-2 1 1 0 010 2z');
});
it('of kaptinlin bug report maki-icons casino', () => {
assert.equal(new SVGPathData('M8.5 10A2.5 2.5 0 0013 8.5c0-.564-.194-1.079-.509-1.497L12.5 7l-5-6-5 6 .009.003A2.478 2.478 0 002 8.5 2.5 2.5 0 006.5 10l.5-.666V11.5C7 13 4.5 13 4.5 13a.5.5 0 100 1h6a.5.5 0 000-1S8 13 8 11.5V9.334l.5.666z').toAbs().round(1000).encode(), 'M8.5 10A2.5 2.5 0 0013 8.5c0-.564-.194-1.079-.509-1.497L12.5 7l-5-6-5 6 .009.003A2.478 2.478 0 002 8.5 2.5 2.5 0 006.5 10l.5-.666V11.5C7 13 4.5 13 4.5 13a.5.5 0 100 1h6a.5.5 0 000-1S8 13 8 11.5V9.334l.5.666z');
});
it('of kaptinlin bug report maki-icons cross', () => {
assert.equal(new SVGPathData('M2.64 1.27L7.5 6.13l4.84-4.84A.92.92 0 0113 1a1 1 0 011 1 .9.9 0 01-.27.66L8.84 7.5l4.89 4.89A.9.9 0 0114 13a1 1 0 01-1 1 .92.92 0 01-.69-.27L7.5 8.87l-4.85 4.85A.92.92 0 012 14a1 1 0 01-1-1 .9.9 0 01.27-.66L6.16 7.5 1.27 2.61A.9.9 0 011 2a1 1 0 011-1c.24.003.47.1.64.27z').toAbs().round(1000).encode(), 'M2.64 1.27L7.5 6.13l4.84-4.84A.92.92 0 0113 1a1 1 0 011 1 .9.9 0 01-.27.66L8.84 7.5l4.89 4.89A.9.9 0 0114 13a1 1 0 01-1 1 .92.92 0 01-.69-.27L7.5 8.87l-4.85 4.85A.92.92 0 012 14a1 1 0 01-1-1 .9.9 0 01.27-.66L6.16 7.5 1.27 2.61A.9.9 0 011 2a1 1 0 011-1c.24.003.47.1.64.27z');
});
it('of kaptinlin bug report octicons broadcast', () => {
assert.equal(new SVGPathData('"M9 9H8c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1H7c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1H6c-.55 0-1 .45-1 1v2h1v3c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-3h1v-2c0-.55-.45-1-1-1zM7 7h1v1H7V7zm2 4H8v4H7v-4H6v-1h3v1zm2.09-3.5c0-1.98-1.61-3.59-3.59-3.59A3.593 3.593 0 004 8.31v1.98c-.61-.77-1-1.73-1-2.8 0-2.48 2.02-4.5 4.5-4.5S12 5.01 12 7.49c0 1.06-.39 2.03-1 2.8V8.31c.06-.27.09-.53.09-.81zm3.91 0c0 2.88-1.63 5.38-4 6.63v-1.05a6.553 6.553 0 003.09-5.58A6.59 6.59 0 007.5.91 6.59 6.59 0 00.91 7.5c0 2.36 1.23 4.42 3.09 5.58v1.05A7.497 7.497 0 017.5 0C11.64 0 15 3.36 15 7.5z"').toAbs().round(1000).encode(), '"M9 9H8c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1H7c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1H6c-.55 0-1 .45-1 1v2h1v3c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-3h1v-2c0-.55-.45-1-1-1zM7 7h1v1H7V7zm2 4H8v4H7v-4H6v-1h3v1zm2.09-3.5c0-1.98-1.61-3.59-3.59-3.59A3.593 3.593 0 004 8.31v1.98c-.61-.77-1-1.73-1-2.8 0-2.48 2.02-4.5 4.5-4.5S12 5.01 12 7.49c0 1.06-.39 2.03-1 2.8V8.31c.06-.27.09-.53.09-.81zm3.91 0c0 2.88-1.63 5.38-4 6.63v-1.05a6.553 6.553 0 003.09-5.58A6.59 6.59 0 007.5.91 6.59 6.59 0 00.91 7.5c0 2.36 1.23 4.42 3.09 5.58v1.05A7.497 7.497 0 017.5 0C11.64 0 15 3.36 15 7.5z"');
});
it('of kaptinlin bug report octicons dashboard', () => {
assert.equal(new SVGPathData('M9 5H8V4h1v1zm4 3h-1v1h1V8zM6 5H5v1h1V5zM5 8H4v1h1V8zm11-5.5l-.5-.5L9 7c-.06-.02-1 0-1 0-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-.92l6-5.58zm-1.59 4.09c.19.61.3 1.25.3 1.91 0 3.42-2.78 6.2-6.2 6.2-3.42 0-6.21-2.78-6.21-6.2 0-3.42 2.78-6.2 6.2-6.2 1.2 0 2.31.34 3.27.94l.94-.94A7.459 7.459 0 008.51 1C4.36 1 1 4.36 1 8.5 1 12.64 4.36 16 8.5 16c4.14 0 7.5-3.36 7.5-7.5 0-1.03-.2-2.02-.59-2.91l-1 1z').toAbs().round(1000).encode(), 'M9 5H8V4h1v1zm4 3h-1v1h1V8zM6 5H5v1h1V5zM5 8H4v1h1V8zm11-5.5l-.5-.5L9 7c-.06-.02-1 0-1 0-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-.92l6-5.58zm-1.59 4.09c.19.61.3 1.25.3 1.91 0 3.42-2.78 6.2-6.2 6.2-3.42 0-6.21-2.78-6.21-6.2 0-3.42 2.78-6.2 6.2-6.2 1.2 0 2.31.34 3.27.94l.94-.94A7.459 7.459 0 008.51 1C4.36 1 1 4.36 1 8.5 1 12.64 4.36 16 8.5 16c4.14 0 7.5-3.36 7.5-7.5 0-1.03-.2-2.02-.59-2.91l-1 1z');
});
it('of kaptinlin bug report octicons dependent', () => {
assert.equal(new SVGPathData('M1 1h7.5l2 2H9L8 2H1v12h10v-1h1v1c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1zm9 6h3v1h-3V7zm2 2h-2v1h2V9zM8.583 4h4.375L15 6v5.429a.58.58 0 01-.583.571H8.583A.58.58 0 018 11.429V10h1v1h5V6.5L12.5 5H9v1H8V4.571A.58.58 0 018.583 4zM9.5 7H6.667V5l-4 3 4 3V9H9.5V7z').toAbs().round(1000).encode(), 'M1 1h7.5l2 2H9L8 2H1v12h10v-1h1v1c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1zm9 6h3v1h-3V7zm2 2h-2v1h2V9zM8.583 4h4.375L15 6v5.429a.58.58 0 01-.583.571H8.583A.58.58 0 018 11.429V10h1v1h5V6.5L12.5 5H9v1H8V4.571A.58.58 0 018.583 4zM9.5 7H6.667V5l-4 3 4 3V9H9.5V7z');
});
it('of kaptinlin bug report octicons kebab-vertical', () => {
assert.equal(new SVGPathData('M0 2.5a1.5 1.5 0 103 0 1.5 1.5 0 00-3 0zm0 5a1.5 1.5 0 103 0 1.5 1.5 0 00-3 0zM1.5 14a1.5 1.5 0 110-3 1.5 1.5 0 010 3z').toAbs().round(1000).encode(), 'M0 2.5a1.5 1.5 0 103 0 1.5 1.5 0 00-3 0zm0 5a1.5 1.5 0 103 0 1.5 1.5 0 00-3 0zM1.5 14a1.5 1.5 0 110-3 1.5 1.5 0 010 3z');
});
it('of kaptinlin bug report unicons voicemail-rectangle', () => {
assert.equal(new SVGPathData('M20 4H4a3 3 0 00-3 3v10a3 3 0 003 3h16a3 3 0 003-3V7a3 3 0 00-3-3zm1 13a1 1 0 01-1 1H4a1 1 0 01-1-1V7a1 1 0 011-1h16a1 1 0 011 1zm-5-8a3 3 0 00-2.82 4h-2.36A3 3 0 108 15h8a3 3 0 000-6zm-8 4a1 1 0 111-1 1 1 0 01-1 1zm8 0a1 1 0 111-1 1 1 0 01-1 1z').toAbs().round(1000).encode(), 'M20 4H4a3 3 0 00-3 3v10a3 3 0 003 3h16a3 3 0 003-3V7a3 3 0 00-3-3zm1 13a1 1 0 01-1 1H4a1 1 0 01-1-1V7a1 1 0 011-1h16a1 1 0 011 1zm-5-8a3 3 0 00-2.82 4h-2.36A3 3 0 108 15h8a3 3 0 000-6zm-8 4a1 1 0 111-1 1 1 0 01-1 1zm8 0a1 1 0 111-1 1 1 0 01-1 1z');
});
it('of kaptinlin bug report unicons venus', () => {
assert.equal(new SVGPathData('M19 9a7 7 0 10-8 6.92V18h-1a1 1 0 000 2h1v1a1 1 0 002 0v-1h1a1 1 0 000-2h-1v-2.08A7 7 0 0019 9zm-7 5a5 5 0 115-5 5 5 0 01-5 5z').toAbs().round(1000).encode(), 'M19 9a7 7 0 10-8 6.92V18h-1a1 1 0 000 2h1v1a1 1 0 002 0v-1h1a1 1 0 000-2h-1v-2.08A7 7 0 0019 9zm-7 5a5 5 0 115-5 5 5 0 01-5 5z');
});
it('of kaptinlin bug report unicons vector-square', () => {
assert.equal(new SVGPathData('M20 16.18V7.82A3 3 0 1016.18 4H7.82A3 3 0 104 7.82v8.36A3 3 0 107.82 20h8.36A3 3 0 1020 16.18zM19 4a1 1 0 11-1 1 1 1 0 011-1zM5 4a1 1 0 11-1 1 1 1 0 011-1zm0 16a1 1 0 111-1 1 1 0 01-1 1zm11.18-2H7.82A3 3 0 006 16.18V7.82A3 3 0 007.82 6h8.36A3 3 0 0018 7.82v8.36A3 3 0 0016.18 18zM19 20a1 1 0 111-1 1 1 0 01-1 1z').toAbs().round(1000).encode(), 'M20 16.18V7.82A3 3 0 1016.18 4H7.82A3 3 0 104 7.82v8.36A3 3 0 107.82 20h8.36A3 3 0 1020 16.18zM19 4a1 1 0 11-1 1 1 1 0 011-1zM5 4a1 1 0 11-1 1 1 1 0 011-1zm0 16a1 1 0 111-1 1 1 0 01-1 1zm11.18-2H7.82A3 3 0 006 16.18V7.82A3 3 0 007.82 6h8.36A3 3 0 0018 7.82v8.36A3 3 0 0016.18 18zM19 20a1 1 0 111-1 1 1 0 01-1 1z');
});
it('of kaptinlin bug report unicons user', () => {
assert.equal(new SVGPathData('M15.71 12.71a6 6 0 10-7.42 0 10 10 0 00-6.22 8.18 1 1 0 002 .22 8 8 0 0115.9 0 1 1 0 001 .89h.11a1 1 0 00.88-1.1 10 10 0 00-6.25-8.19zM12 12a4 4 0 114-4 4 4 0 01-4 4z').toAbs().round(1000).encode(), 'M15.71 12.71a6 6 0 10-7.42 0 10 10 0 00-6.22 8.18 1 1 0 002 .22 8 8 0 0115.9 0 1 1 0 001 .89h.11a1 1 0 00.88-1.1 10 10 0 00-6.25-8.19zM12 12a4 4 0 114-4 4 4 0 01-4 4z');
});
it('of kaptinlin bug report unicons user-plus', () => {
assert.equal(new SVGPathData('M21 10.5h-1v-1a1 1 0 00-2 0v1h-1a1 1 0 000 2h1v1a1 1 0 002 0v-1h1a1 1 0 000-2zm-7.7 1.72A4.92 4.92 0 0015 8.5a5 5 0 00-10 0 4.92 4.92 0 001.7 3.72A8 8 0 002 19.5a1 1 0 002 0 6 6 0 0112 0 1 1 0 002 0 8 8 0 00-4.7-7.28zM10 11.5a3 3 0 113-3 3 3 0 01-3 3z').toAbs().round(1000).encode(), 'M21 10.5h-1v-1a1 1 0 00-2 0v1h-1a1 1 0 000 2h1v1a1 1 0 002 0v-1h1a1 1 0 000-2zm-7.7 1.72A4.92 4.92 0 0015 8.5a5 5 0 00-10 0 4.92 4.92 0 001.7 3.72A8 8 0 002 19.5a1 1 0 002 0 6 6 0 0112 0 1 1 0 002 0 8 8 0 00-4.7-7.28zM10 11.5a3 3 0 113-3 3 3 0 01-3 3z');
});
Gave another try, should be good now, let me know if it fixes all your parsing failures.
It's working fine! Thank you! @nfroidure
Please update the svg-pathdata version for svgicons2svgfont btw. Thanks.
Sorry I closed the ticket/PR before I realized that I don't have the permission to publish the npm package. @nfroidure, can you publish the update and/or give me the permissions to do so (https://www.npmjs.com/~pioug) 🙏
I gave you the access
Hey @nfroidure, thanks for fixing the parsing issues and thanks to @pioug for helping and publishing svg-pathdata on the current version 5.0.4. As @KaptinLin also mentioned, it's working fine now. The issues I mentioned in the initial post are all gone now! 🙌
Context
I tried generating an iconfont as an automated process. I'm using the node packages webfont and webfont-webpack-plugin, which are using svgicons2svgfont, which on the otherhand uses svg-pathdata to apply transformation to svg paths like this. I tried the process with different sources. But with the icons from the octions package the path parser seems to run into issues.
Issue
When parsing icons generated from @primer/octicons svg-pathdata runs into issues. It happens for 51 icons of the whole iconset, so sure not for every svg path inside octicons.
Example
When parsing path data from file '@primer/octicons/build/svg/alert.svg'
M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 000 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 00.01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z
svg-pathdata throws a SyntaxError with the message
SyntaxError: Expected a flag, got "000" at index "76"
Expected behavior
svg-pathdata should be able to parse path data coming from GitHub's iconset
Actual behavior
Ends up in a parsing error.
Summary
What is the problem with this specific path data coming from the icon 'alert'? Is this a known issue? Is there a workaround for this? And thanks :)