From 63f038eb6b38e64c2cb9d3b8fc3b051be6090592 Mon Sep 17 00:00:00 2001 From: Gae24 <96017547+Gae24@users.noreply.github.com> Date: Thu, 17 Oct 2024 10:24:18 +0200 Subject: [PATCH] macOS: extract html --- src/platform/osx.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/platform/osx.rs b/src/platform/osx.rs index 1df7222..2c1e945 100644 --- a/src/platform/osx.rs +++ b/src/platform/osx.rs @@ -207,7 +207,8 @@ impl<'clipboard> Get<'clipboard> { } pub(crate) fn html(self) -> Result { - unsafe { self.clipboard.string_from_type(NSPasteboardTypeHTML) } + let html = unsafe { self.clipboard.string_from_type(NSPasteboardTypeHTML) }?; + extract_html(html) } #[cfg(feature = "image-data")] @@ -352,6 +353,18 @@ fn add_clipboard_exclusions(clipboard: &mut Clipboard, exclude_from_history: boo } } +fn extract_html(html: String) -> Result { + let start_tag = ""; + let end_tag = ""; + + // Locate the start index of the tag + let start_index = html.find(start_tag)? + start_tag.len(); + // Locate the end index of the tag + let end_index = html.find(end_tag)?; + + Ok(html[start_index..end_index].to_string()) +} + /// Apple-specific extensions to the [`Set`](crate::Set) builder. pub trait SetExtApple: private::Sealed { /// Excludes the data which will be set on the clipboard from being added to