-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `qto_link()` function * Fix arg parameter for check_src * Refactor `qto_fig()` to use `qto_src_span()` * Fix handling of multiple class values * Update qto_link to allow bare links * Fill missing param definitions
- Loading branch information
1 parent
e0a2b5e
commit 0c7b29a
Showing
15 changed files
with
348 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#' Create a Markdown link | ||
#' | ||
#' @param src Path or URL for link. Required. | ||
#' @param text Optional link text. If link text is not provided, a bare link, | ||
#' e.g. `<https://quarto.org>` is returned. | ||
#' @inheritParams check_src | ||
#' @inheritDotParams qto_attributes -.output -.drop_empty | ||
#' @examples | ||
#' qto_link("https://quarto.org") | ||
#' | ||
#' qto_link("https://quarto.org", "Quarto") | ||
#' | ||
#' qto_link("https://quarto.org", "Quarto", class = "smaller") | ||
#' | ||
#' @family span | ||
#' @export | ||
qto_link <- function(src, | ||
text = NULL, | ||
..., | ||
allow_empty = FALSE, | ||
call = caller_env()) { | ||
check_src( | ||
src, | ||
allow_empty = allow_empty, | ||
call = call | ||
) | ||
|
||
if (is.null(text)) { | ||
link <- qto_block( | ||
combine(src, before = "<", after = ">"), | ||
qto_attributes( | ||
..., | ||
.output = "span", | ||
call = call | ||
), | ||
call = call | ||
) | ||
|
||
return(link) | ||
} | ||
|
||
qto_src_span( | ||
src = src, | ||
text = text, | ||
..., | ||
allow_empty = allow_empty, | ||
call = call | ||
) | ||
} | ||
|
||
|
||
#' Simplified helper for `qto_link()` | ||
#' | ||
#' Also used by [qto_fig_span()] | ||
#' | ||
#' @param src Image source or URL. | ||
#' @param text Caption or link text. | ||
#' @inheritParams check_src | ||
#' @inheritDotParams qto_attributes | ||
#' @keywords internal | ||
qto_src_span <- function(src, | ||
text = NULL, | ||
.before = "", | ||
..., | ||
allow_missing = FALSE, | ||
allow_empty = FALSE, | ||
call = caller_env()) { | ||
qto_block( | ||
.before, | ||
bracket(text), | ||
parentheses(src), | ||
qto_attributes( | ||
..., | ||
.output = "span", | ||
call = call | ||
), | ||
call = call | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.