OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Error: peg$SyntaxError: Expected Character but "&" Found While Parsing SVG Path Data in JavaScript

  • Thread starter Thread starter HEMAL
  • Start date Start date
H

HEMAL

Guest
I am working with an SVG file and converting it to JSON using svgson library. Additionally, I am using the svg-path-to-polygons library to decode the d attribute in the path element. However, I am encountering the following error:

Code:
peg$SyntaxError: Expected ",", ".", [ \t\n\r], [+\-], [0-9], [Aa], [Cc], [Hh], [Ll], [Mm], [Qq], [Ss], [Tt], [Vv], [Zz], [eE], or end of input but "&" found.

Here is a snippet of the SVG JSON data I am working with:

Code:
{
    "name": "g",
    "type": "element",
    "value": "",
    "attributes": {
        "id": "nopointer-base"
    },
    "children": [
        {
            "name": "path",
            "type": "element",
            "value": "",
            "attributes": {
                "fill": "#F2F2F2",
                "d": "M1737.5,678.8h-811c-11,0-20,9-20,20V1138h-137v291.5h184.1v245H1117v265.1h232.9l68.6-65.9l0.1-780.4
\t\t\th75.9V932.5h232.4l30.6-31.8V698.8C1757.5,687.7,1748.5,678.8,1737.5,678.8z"
            },
            "children": []
        }
    ]
}

Environment:

  • Libraries: svgson, svg-path-to-polygons

Steps to Reproduce:

  1. Parse the SVG file to JSON using svgson.
  2. Attempt to decode the d attribute using svg-path-to-polygons.

Expected Behavior: The d attribute should be decoded without syntax errors.

Actual Behavior: The following error is thrown: peg$SyntaxError: Expected ",", ".", [ \t\n\r], [+\-], [0-9], [Aa], [Cc], [Hh], [Ll], [Mm], [Qq], [Ss], [Tt], [Vv], [Zz], [eE], or end of input but "&" found.

Question: How can I resolve this syntax error? Is there an issue with the format of the d attribute string, or is there something I am missing in the usage of the svgson or svg-path-to-polygons libraries?

Any help or guidance would be appreciated.

<p>I am working with an SVG file and converting it to JSON using <code>svgson</code> library. Additionally, I am using the <code>svg-path-to-polygons</code> library to decode the <code>d</code> attribute in the path element. However, I am encountering the following error:</p>
<pre><code>peg$SyntaxError: Expected ",", ".", [ \t\n\r], [+\-], [0-9], [Aa], [Cc], [Hh], [Ll], [Mm], [Qq], [Ss], [Tt], [Vv], [Zz], [eE], or end of input but "&" found.
</code></pre>
<p>Here is a snippet of the SVG JSON data I am working with:</p>
<pre class="lang-json prettyprint-override"><code>{
"name": "g",
"type": "element",
"value": "",
"attributes": {
"id": "nopointer-base"
},
"children": [
{
"name": "path",
"type": "element",
"value": "",
"attributes": {
"fill": "#F2F2F2",
"d": "M1737.5,678.8h-811c-11,0-20,9-20,20V1138h-137v291.5h184.1v245H1117v265.1h232.9l68.6-65.9l0.1-780.4&#xA;\t\t\th75.9V932.5h232.4l30.6-31.8V698.8C1757.5,687.7,1748.5,678.8,1737.5,678.8z"
},
"children": []
}
]
}
</code></pre>
<p><strong>Environment:</strong></p>
<ul>
<li>Libraries: <code>svgson</code>, <code>svg-path-to-polygons</code></li>
</ul>
<p><strong>Steps to Reproduce:</strong></p>
<ol>
<li>Parse the SVG file to JSON using <code>svgson</code>.</li>
<li>Attempt to decode the <code>d</code> attribute using <code>svg-path-to-polygons</code>.</li>
</ol>
<p><strong>Expected Behavior:</strong>
The <code>d</code> attribute should be decoded without syntax errors.</p>
<p><strong>Actual Behavior:</strong>
The following error is thrown: <code>peg$SyntaxError: Expected ",", ".", [ \t\n\r], [+\-], [0-9], [Aa], [Cc], [Hh], [Ll], [Mm], [Qq], [Ss], [Tt], [Vv], [Zz], [eE], or end of input but "&" found.</code></p>
<p><strong>Question:</strong>
How can I resolve this syntax error? Is there an issue with the format of the <code>d</code> attribute string, or is there something I am missing in the usage of the <code>svgson</code> or <code>svg-path-to-polygons</code> libraries?</p>
<p>Any help or guidance would be appreciated.</p>
 

Latest posts

O
Replies
0
Views
1
OrangeRind
O
D
Replies
0
Views
2
Domantas Giedraitis
D
Top