diff --git a/examples/set_html.rs b/examples/set_get_html.rs
similarity index 78%
rename from examples/set_html.rs
rename to examples/set_get_html.rs
index 125f6b1..96ab58a 100644
--- a/examples/set_html.rs
+++ b/examples/set_get_html.rs
@@ -15,4 +15,7 @@ consectetur adipiscing elit."#;
ctx.set_html(html, Some(alt_text)).unwrap();
thread::sleep(Duration::from_secs(5));
+
+ let success = ctx.get().html().unwrap() == html;
+ println!("Set and Get html operations were successful: {success}");
}
diff --git a/src/lib.rs b/src/lib.rs
index 01eac45..c002bdc 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -192,6 +192,11 @@ impl Get<'_> {
pub fn image(self) -> Result, Error> {
self.platform.image()
}
+
+ /// Completes the "get" operation by fetching HTML from the clipboard.
+ pub fn html(self) -> Result {
+ self.platform.html()
+ }
}
/// A builder for an operation that sets a value to the clipboard.
@@ -322,6 +327,24 @@ mod tests {
ctx.set_html(html, Some(alt_text)).unwrap();
assert_eq!(ctx.get_text().unwrap(), alt_text);
}
+ {
+ let mut ctx = Clipboard::new().unwrap();
+
+ let html = "hello world!";
+
+ ctx.set().html(html, None).unwrap();
+
+ if cfg!(target_os = "macos") {
+ // Copying HTML on macOS adds wrapper content to work around
+ // historical platform bugs. We control this wrapper, so we are
+ // able to check that the full user data still appears and at what
+ // position in the final copy contents.
+ let content = ctx.get().html().unwrap();
+ assert!(content.ends_with(&format!("{html}