From 92bb8931c57c4d3069761348bfc5e9c75f61b19e Mon Sep 17 00:00:00 2001 From: Matthijs Berends Date: Fri, 30 Oct 2026 09:59:01 +0100 Subject: [PATCH] (v3.1.0.9009) Fix the misaligned arrows in the message on taxonomically renamed microorganisms in colour-supporting consoles, by padding on the visible width instead of using format() (fixes #336) --- DESCRIPTION | 4 ++-- NEWS.md | 6 +++++- R/mo.R | 5 ++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 56d2e453d..fe001a5b5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 3.1.0.9006 -Date: 2026-10-23 +Version: 3.1.0.9009 +Date: 2026-10-30 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) data analysis and to work with microbial and antimicrobial properties by diff --git a/NEWS.md b/NEWS.md index aa58e146e..04461bed3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,8 @@ -# AMR 3.1.0.9006 +# AMR 3.1.0.9009 + +### Changed +* Microorganism coercion (`as.mo()`) + * Fixed the misaligned arrows in the message on taxonomically renamed microorganisms in colour-supporting consoles, for old names whose author reference lacks "*et al.*" (#336) ### Other * The manual index on the website was rewritten to improve findability, with sections ordered by task and a filter field diff --git a/R/mo.R b/R/mo.R index 576f1d40d..b085591a4 100755 --- a/R/mo.R +++ b/R/mo.R @@ -1144,7 +1144,10 @@ print.mo_renamed <- function(x, extra_txt = "", n = 25, ...) { rows <- seq_len(min(NROW(x), n)) message_("The following microorganism", ifelse(NROW(x) > 1, "s were", " was"), " taxonomically renamed", extra_txt, ":") - old_format <- format(paste0(font_italic(x$old[rows], collapse = NULL), x$ref_old[rows])) # format() will set trailing spaces for textual alignment + old_format <- paste0(font_italic(x$old[rows], collapse = NULL), x$ref_old[rows]) + # pad based on the visible width, since format() counts ANSI codes as characters + visible_width <- nchar(font_stripstyle(old_format), type = "width") + old_format <- paste0(old_format, strrep(" ", max(visible_width) - visible_width)) old_format <- gsub(" ", "\u00a0", old_format, fixed = TRUE) for (old_tax in rows) { message_("\u00a0\u00a0", AMR_env$bullet_icon, " ", old_format[old_tax], " -> ", font_italic(x$new[old_tax]), x$ref_new[old_tax], as_note = FALSE)