Skip to content

Commit

Permalink
html-manifest te007 is now working
Browse files Browse the repository at this point in the history
  • Loading branch information
anatoly-scherbakov committed Jan 17, 2024
1 parent 15b2530 commit 3fa95f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ def test_invalid_yaml():
)
with pytest.raises(LoadingDocumentFailed):
yaml_ld.parse(document)


def test_html():
document_path = specifications_root / 'json-ld-api/tests/html/e007-in.html'
assert yaml_ld.parse(document_path) == []
9 changes: 8 additions & 1 deletion yaml_ld/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _parse_html(
))

if not html_yaml_scripts:
return {}
return []

if extract_all_scripts:
return [parse(script) for script in html_yaml_scripts]
Expand Down Expand Up @@ -84,6 +84,13 @@ def parse( # noqa: WPS238, WPS231, C901
except UnicodeDecodeError as err:
raise InvalidEncoding() from err

if document_type == DocumentType.HTML:
return _parse_html(
raw_document,
fragment=fragment,
extract_all_scripts=extract_all_scripts,
)

try:
document: Document = yaml.load( # noqa: S506
stream=raw_document,
Expand Down

0 comments on commit 3fa95f5

Please sign in to comment.