tablo_test/protocol/
detail.rs1use super::dom::{attr_value, strip_text, tags_where};
5
6#[derive(Debug, Clone, PartialEq, Eq)]
8pub struct DetailEntry {
9 pub column: String,
11 pub text: String,
13}
14
15pub fn detail_entries(html: &str) -> Vec<DetailEntry> {
17 tags_where(html, |_, attrs| attr_value(attrs, "data-entry").is_some())
18 .into_iter()
19 .map(|(_, attrs, inner)| DetailEntry {
20 column: attr_value(&attrs, "data-entry").unwrap_or_default(),
21 text: strip_text(&inner),
22 })
23 .collect()
24}
25
26#[derive(Debug, Clone, PartialEq, Eq)]
28pub struct RecordNavLink {
29 pub href: String,
31 pub current: bool,
33}
34
35pub fn record_navigation(html: &str) -> Vec<RecordNavLink> {
38 tags_where(html, |_, attrs| {
39 attr_value(attrs, "data-record-nav").is_some()
40 })
41 .into_iter()
42 .map(|(_, attrs, _)| RecordNavLink {
43 href: attr_value(&attrs, "data-record-nav").unwrap_or_default(),
44 current: attr_value(&attrs, "aria-current").as_deref() == Some("page"),
45 })
46 .collect()
47}