Skip to content

Commit 7a4a5dd

Browse files
author
smeyer
committed
experiment with alternative Rd2txt() conversions of \describe lists
git-svn-id: https://svn.r-project.org/R/trunk@88232 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent b6506d4 commit 7a4a5dd

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/library/tools/R/Rd2txt.R

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# File src/library/tools/R/Rd2txt.R
22
# Part of the R package, https://www.R-project.org
33
#
4-
# Copyright (C) 1995-2024 The R Core Team
4+
# Copyright (C) 1995-2025 The R Core Team
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -37,7 +37,8 @@ Rd2txt_options <- local({
3737
sectionExtra = 2L,
3838
itemBullet = "* ",
3939
enumFormat = function(n) sprintf("%d. ", n),
40-
showURLs = FALSE,
40+
## descStyle = "none",
41+
showURLs = FALSE,
4142
code_quote = TRUE,
4243
underline_titles = TRUE)
4344
function(...) {
@@ -516,6 +517,7 @@ Rd2txt <-
516517
strip
517518
}
518519
## Strip pending blank lines, then add n new ones.
520+
## (Currently not used with n > 1, which only works if not 'wrapping'.)
519521
blankLine <- function(n = 1L) {
520522
while (stripBlankLine()) NULL
521523
flushBuffer()
@@ -891,9 +893,12 @@ Rd2txt <-
891893
indent <<- max(opts$minIndent,
892894
indent + opts$extraIndent)
893895
keepFirstIndent <<- TRUE
894-
putw(strrep(" ", indent0),
895-
DLlab,
896-
" ")
896+
linebreak <- identical(opts$descStyle, "linebreak")
897+
suffix <- if (identical(opts$descStyle, "colon")
898+
&& !endsWith(DLlab, ":")) ": "
899+
else if (!linebreak) " "
900+
putw(strrep(" ", indent0), DLlab, suffix)
901+
if (linebreak) blankLine(0L)
897902
writeContent(block[[2L]], tag)
898903
blankLine(0L)
899904
indent <<- indent0

0 commit comments

Comments
 (0)