@@ -29,10 +29,9 @@ get_link <- function(arg, tag, Rdfile) {
2929 # # \link[pkg:bar]{foo} means show foo and link to topic/file bar in package pkg.
3030 # # As from 2.10.0, look for topic 'bar' if file not found.
3131 # # As from 4.1.0, prefer topic 'bar' over file 'bar' (in which case 'targetfile' is a misnomer)
32+ # # As from 4.5.0, allow markup in link text for variants 2 and 4.
3233
33- if (! all(RdTags(arg ) == " TEXT" ))
34- stopRd(arg , Rdfile , " Bad \\ link text" )
35-
34+ isTEXT <- all(RdTags(arg ) == " TEXT" )
3635 option <- attr(arg , " Rd_option" )
3736
3837 topic <- dest <- paste(unlist(arg ), collapse = " " )
@@ -41,16 +40,21 @@ get_link <- function(arg, tag, Rdfile) {
4140 if (! is.null(option )) {
4241 if (! identical(attr(option , " Rd_tag" ), " TEXT" ))
4342 stopRd(option , Rdfile , " Bad \\ link option -- must be text" )
44- if (grepl(" ^=" , option , perl = TRUE , useBytes = TRUE ))
43+ option <- as.character(option )
44+ if (startsWith(option , " =" ))
4545 dest <- psub1(" ^=" , " " , option )
46- else if (grepl(" :" , option , perl = TRUE , useBytes = TRUE )) {
46+ else if (grepl(" :" , option , fixed = TRUE )) {
4747 targetfile <- psub1(" ^[^:]*:" , " " , option )
4848 pkg <- psub1(" :.*" , " " , option )
4949 } else {
50+ if (! isTEXT )
51+ stopRd(arg , Rdfile , " Bad \\ link[pkg]{topic} -- argument must be text" )
5052 targetfile <- dest
51- pkg <- as.character( option )
53+ pkg <- option
5254 }
53- }
55+ } else if (! isTEXT )
56+ stopRd(arg , Rdfile , " Bad \\ link topic -- must be text" )
57+
5458 if (tag == " \\ linkS4class" ) dest <- paste0(dest , " -class" )
5559 list (topic = topic , dest = dest , pkg = pkg , targetfile = targetfile )
5660}
0 commit comments