We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 09d7f47 commit 3970f79Copy full SHA for 3970f79
extruct/jsonld.py
@@ -11,6 +11,7 @@
11
12
from extruct.utils import parse_html
13
14
+HTML_OR_JS_COMMENTLINE = re.compile(r'^\s*(//.*|<!--.*-->)')
15
16
17
class JsonLdExtractor(object):
@@ -34,7 +35,7 @@ def _extract_items(self, node):
34
35
data = json.loads(script, strict=False)
36
except ValueError:
37
# sometimes JSON-decoding errors are due to leading HTML or JavaScript comments
- data = jstyleson.loads(script, strict=False)
38
+ data = jstyleson.loads(HTML_OR_JS_COMMENTLINE.sub('', script),strict=False)
39
if isinstance(data, list):
40
return data
41
elif isinstance(data, dict):
0 commit comments