From ca921b47b92e13fc2ee3eabc1ac1fb484e03da81 Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Fri, 10 Jan 2025 15:50:07 -0600 Subject: [PATCH] also support the attributes from record_print.xfun_raw_string() in format.xfun_record_results() --- DESCRIPTION | 2 +- R/record.R | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 65f4bb4..2e07b46 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: xfun Type: Package Title: Supporting Functions for Packages Maintained by 'Yihui Xie' -Version: 0.50.2 +Version: 0.50.3 Authors@R: c( person("Yihui", "Xie", role = c("aut", "cre", "cph"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666", URL = "https://yihui.org")), person("Wush", "Wu", role = "ctb"), diff --git a/R/record.R b/R/record.R index cbff535..6174deb 100644 --- a/R/record.R +++ b/R/record.R @@ -375,14 +375,15 @@ format.xfun_record_results = function( if (is_md && cls == 'plot') { z = sprintf('![%s](<%s>)', alt, z) } else { + o = attr(z, 'opts') z = gsub('^(\\s*\n)+|\n\\s*$', '', one_string(z)) # trim blank lines - if (cls != 'source') z = paste('#>', split_lines(z)) + if (cls != 'source') z = paste0(o$comment %||% '#> ', split_lines(z)) if (is_md) { cls_all = if (any(c('message', 'warning', 'error') %in% cls_all)) { c('plain', cls_all) } else if (cls == 'source') { replace(cls_all, cls_all == 'source', 'r') - } else setdiff(cls_all, 'output') + } else setdiff(c(o$attr, cls_all), 'output') z = fenced_block(z, sprintf('.%s', cls_all)) } }