>,
}
@@ -26,7 +26,17 @@ impl<'a> Message<'a> {
///
///
pub fn id(mut self, id: &'a str) -> Self {
- self.id = Some(id);
+ self.id.get_or_insert(Id::default()).id = Some(id);
+ self
+ }
+
+ ///
+ ///
+ /// This is only relevant if the `id` present
+ ///
+ ///
+ pub fn id_url(mut self, url: &'a str) -> Self {
+ self.id.get_or_insert(Id::default()).url = Some(url);
self
}
@@ -75,6 +85,12 @@ impl<'a> Message<'a> {
}
}
+#[derive(Clone, Debug, Default)]
+pub(crate) struct Id<'a> {
+ pub(crate) id: Option<&'a str>,
+ pub(crate) url: Option<&'a str>,
+}
+
/// An [`Element`] container
#[derive(Clone, Debug)]
pub struct Group<'a> {
diff --git a/tests/examples.rs b/tests/examples.rs
index 02e961c8..ec2643e9 100644
--- a/tests/examples.rs
+++ b/tests/examples.rs
@@ -49,6 +49,13 @@ fn highlight_title() {
assert_example(target, expected);
}
+#[test]
+fn id_hyperlink() {
+ let target = "id_hyperlink";
+ let expected = snapbox::file!["../examples/id_hyperlink.svg": TermSvg];
+ assert_example(target, expected);
+}
+
#[test]
fn multislice() {
let target = "multislice";