Skip to content

Commit

Permalink
Merge pull request #54 from ndmitchell/fix-53
Browse files Browse the repository at this point in the history
Remove parsing of __ in title strings, fixes #53
  • Loading branch information
zbraniecki authored Oct 26, 2023
2 parents a620165 + ee4687b commit 160ef45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
21 changes: 5 additions & 16 deletions src/display_list/from_snippet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,11 @@ fn format_label(
) -> Vec<DisplayTextFragment<'_>> {
let mut result = vec![];
if let Some(label) = label {
for (idx, element) in label.split("__").enumerate() {
let element_style = match style {
Some(s) => s,
None => {
if idx % 2 == 0 {
DisplayTextStyle::Regular
} else {
DisplayTextStyle::Emphasis
}
}
};
result.push(DisplayTextFragment {
content: element,
style: element_style,
});
}
let element_style = style.unwrap_or(DisplayTextStyle::Regular);
result.push(DisplayTextFragment {
content: label,
style: element_style,
});
}
result
}
Expand Down
18 changes: 4 additions & 14 deletions tests/dl_from_snippet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,20 +262,10 @@ fn test_format_label() {
annotation: dl::Annotation {
annotation_type: dl::DisplayAnnotationType::Error,
id: None,
label: vec![
dl::DisplayTextFragment {
content: "This ",
style: dl::DisplayTextStyle::Regular,
},
dl::DisplayTextFragment {
content: "is",
style: dl::DisplayTextStyle::Emphasis,
},
dl::DisplayTextFragment {
content: " a title",
style: dl::DisplayTextStyle::Regular,
},
],
label: vec![dl::DisplayTextFragment {
content: "This __is__ a title",
style: dl::DisplayTextStyle::Regular,
}],
},
source_aligned: true,
continuation: false,
Expand Down

0 comments on commit 160ef45

Please sign in to comment.