carpentries / sandpaper

User Interface for The Carpentries Workbench
https://carpentries.github.io/sandpaper
Other
41 stars 24 forks source link

Bug: XML Parsing error if instructor notes are empty #505

Closed apirogov closed 1 year ago

apirogov commented 1 year ago

As far as I understand, the instructors/instructor-notes.md provide the information at the top, while the rest of the notes is auto-generated.

Currently you HAVE to write something there, i.e.

---
title: Instructor notes
---

will fail with an error:

Fehler in UseMethod("xml_find_all") : 
  nicht anwendbare Methode für 'xml_find_all' auf Objekt der Klasse "xml_document" angewendet

using sandpaper (0.12.4), pegboard (0.5.3), and varnish (0.2.18).

zkamvar commented 1 year ago

This is similar to https://github.com/carpentries/sandpaper/issues/441 and I agree that it should be fixed.

The fix for this particular issue is to add an else statment to these lines:

https://github.com/carpentries/sandpaper/blob/6394079102282be6da8d952aee6de7489a0d993e/R/build_instructor_notes.R#L17-L20

     if (html != '') {
       html  <- xml2::read_html(html)
       fix_nodes(html)
+    } else {
+      html  <- xml2::read_html("<p></p>")
     }

I think this is a good first issue for one of the @carpentries/workbench-maintainers to tackle if they have time.

klbarnes20 commented 1 year ago

I can give it a try