Changelog
Source:NEWS.md
CHANGES IN xfun VERSION 0.59
CRAN release: 2026-06-19
protect_math()now correctly handles nested LaTeX environments (e.g.,\begin{cases}inside\begin{equation}). Previously, inner environments were individually wrapped in backticks, which broke MathJax rendering (thanks, @N0rbert, #57).Match favicon.ico request by basename in
resolve_path()(thanks, @remlapmot, #120).Added a new function
post_release()to perform post-CRAN-release routine tasks (e.g., tag the release, bump the version, push to the remote repository, and create a GitHub release).system3()now errors on non-zero exit codes.Removed the outdated note about Chrome’s 2MB file size limit from the
embed_file()documentation, since modern browsers (Chrome, Firefox, Safari) all support data URIs well over 100MB now (thanks, @grst, #23).Fixed a regex bug in the internal
yaml_bool()function where the pattern'^true|false|na$'was incorrectly parsed as(^true)|(false)|(na$), causing values like'extrafalse'or'trueblue'to be treated as booleans intaml_load().
CHANGES IN xfun VERSION 0.58
CRAN release: 2026-06-01
md_table()gained a new argumentescapeto backslash-escape special Markdown characters in table cells, which prevents content like<foo:bar>from being interpreted as links (thanks, @tdhock, yihui/litedown#131). It can beTRUE(all columns), a vector of column names/indices (selective), or set globally viaoptions(xfun.md_table.escape = TRUE).Fixed
taml_load()failing on YAML with non-uniform indentation (e.g., child items indented by a different number of spaces than the minimum unit).taml_load()now ignores block sequence items (lines starting with-) and their indented children, since arrays written in this YAML block syntax are not supported bytaml_load().new_app()now uses a lightweight proxy in front of R’s internal httpd:new_app(name = '')serves one proxy-backed app per port athttp://127.0.0.1:PORT/,new_app(name != '')keeps legacy direct httpd routing via/custom/name/for compatibility. The internal functionxfun:::help_proxy()can proxy the full help server for LAN access, since the proxy starts at0.0.0.0by default.Renamed
new_app()’s argumentportstoport.Added
random_port()to find a random available TCP port (e.g., it can be used for theportargument ofnew_app()).html_view()should join the input character vector by\n, otherwise only the first element of the vector will be passed to the browser (thanks, @XiangyunHuang, yihui/gglite#15).html_view()gained a new argumentnameto customize the app name passed tonew_app()(defaults to'xfun-html').Added a new function
serve_dir()to serve a static directory of files vianew_app(), similar toservr::httd()and Python’shttp.servermodule. Ifindex.htmlis found under the directory, it will be served; otherwise a directory listing is shown.tojson()will convert length 1 columns to arrays, too. Previously, such columns were converted to scalars, e.g.,data.frame(x = 1)would be converted to{"x": 1}instead of{"x": [1]}. This makes sure data frame columns are always arrays in JSON.
CHANGES IN xfun VERSION 0.57
CRAN release: 2026-03-20
Added a new function
js()to mark a character string as literal JavaScript code so thattojson()will not quote it.Added a new function
tab_contentto create custom tab content from a character vector fortabset().Fixed a bottleneck in
xfun::record()when the code prints a huge amount of output (thanks, @idavydov, quarto-dev/quarto-cli#14156).Added an argument
synctosubmit_cran()to prevent package authors from forgetting to pull from remote before submitting a package.
CHANGES IN xfun VERSION 0.56
CRAN release: 2026-01-18
Removed the deprecated
xfun::attr(). Please usexfun::attr2()instead.github_releases(tag = 'latest')is more accurate now.Renamed the argument
urltoinputinbrowser_print().Removed support for qs (which has been removed from CRAN) in
cache_exec(),cache_rds(),lazy_save(), andlazy_load().rev_check()can download reverse dependency tarballs in parallel viaoptions(xfun.rev_check.download_cores = n)(defaultparallel::detectCores()).
CHANGES IN xfun VERSION 0.55
CRAN release: 2025-12-16
record(error = TRUE)will trim the error message by removing the uninformative partin eval(expr, envir)in the message (thanks, @ThomasSoeiro, yihui/litedown#109).record()will capture error messages generated fromtry()(thanks, @ThomasSoeiro, yihui/litedown#110).Added support for the qs2 package in
cache_exec()andcache_rds()since the qs package will be deprecated.Added
browser_print()as a simple wrapper function to call a headless browser to print a web page to PDF/PNG/JPEG.
CHANGES IN xfun VERSION 0.54
CRAN release: 2025-10-30
-
record()tries not to records empty plots triggered as side-effects by functions likegrid::convertUnit()(thanks, @yjunechoe, yihui/litedown#96). However, the underlying technique is not robust enough to deal with all cases. In case certain undesired plots still get recorded, you can filter them out via the new argument ofrecord(),dev.keep, which can take indices to determine which plots to keep. For example,dev.keep = -1means to remove the first plot.
CHANGES IN xfun VERSION 0.53
CRAN release: 2025-08-19
Error messages captured by
record()include the calls that triggered the errors now. Error messages fromrlang::abort()are also better formatted.ANSI sequences are disabled via
options(cli.num_colors = 1)inrecord()to make sure pure text output is captured.Skip printing data.table objects in
record()ifdata.table::shouldPrint()returnsFALSE(thanks, @TimTaylor, #105).cache_rds()supports reading/writing cache with the qs package now (thanks, @cheny36, #104).
CHANGES IN xfun VERSION 0.52
CRAN release: 2025-04-02
xfun::attr()is deprecated (to avoid maskingbase::attr()). Please usexfun::attr2()orbase::attr(exact = TRUE)instead.Added an argument
datetopkg_bib()to optionally include the date of retrieval in the bib entries (thanks, @HedvigS, #99).Added a new function
url_destination()to get the destination of a redirected URL.Added a new function
rand_unit()to generate pseudo-random numbers on[0, 1)based on a linear congruential generator.Fixed a bug in
taml_load()that would convert character values in arrays to lowercase.Added arguments
strictand...todivide_chunk()(thanks, @cderv, yihui/knitr#2225).The function
cache_rds()is no longer recommended. Please consider usingcache_exec()instead (thanks, @lenz99, #100).Removed the
solarisargument fromupload_win_builder().
CHANGES IN xfun VERSION 0.51
CRAN release: 2025-02-19
tojson()supports more types of data now, and will indent sub-elements for lists. See the help page?xfun::tojsonfor details.Updated the default API key for
upload_imgur()since the previous default key stopped working for some reason (thanks, @camille-s @jennybc, #97).upload_imgur()shows the error message instead of the error code when it fails to upload the image, which is more informative.download_file()returns the path of the file downloaded instead of the command status code now.
CHANGES IN xfun VERSION 0.50
CRAN release: 2025-01-07
The function
isFALSE()has been removed from this package. The deprecation notice was given two years ago: https://yihui.org/en/2023/02/xfun-isfalse/Added a new function
tabset()to represent a list with a tabset. The representation is similar tostr(), but uses a visual form.Factored out the function
taml_load()and exported it (TAML is a tiny subset of YAML). Also added a new functiontaml_save()to convert simple lists to YAML.The
printargument ofrecord()can accept non-function values now, in which caseprint()(orshow()for S4 objects) will be used as the print function.The
record()results can also be formatted to Markdown viaformat(record(), to = 'markdown').Moved
knitr::combine_words()into this package asxfun::join_words(). The former has become a simple wrapper of the latter.Similarly, moved
knitr::write_bib()into this package asxfun::pkg_bib().Moved the internal function
str_wrap()from knitr and exported it asxfun::str_wrap().Exported the internal
find_globals()andfind_locals()functions.md_table()escapes|in the table to\|instead of|now.yaml_load(use_yaml = FALSE)allows for indenting sub-fields by any number of spaces now (thanks, @J-Moravec, #95). Previously, one level of indentation must use exactly 2 spaces.-
divide_chunk()no longer requires every line of chunk options to be commented out when the engine uses a pair of comment delimiters (such as/*and*/for CSS) instead of a single comment character. It suffices to use the opening delimiter at the beginning and closing delimiter at the end, e.g.,Previously, every line must be commented out like:
CHANGES IN xfun VERSION 0.49
CRAN release: 2024-10-31
Added an argument
use_block = FALSEtoprotect_math(). Whenuse_block = TRUE, a$$ $$expression that spans across multiple lines will be protected in a code block.protect_math()will ignore$ $if there are backticks after the opening$or before the closing$, e.g.,$`this is not math`$.protect_math()allows for parentheses()around math expressions now, e.g.,($x$)was previously not recognized but is recognized now (thanks, @AlbertLei, yihui/litedown#34).record()works withquote()now (thanks, @ben-schwen, yihui/litedown#38).html_escape()will not escape double quotes (i.e., convert"” to") by default, and the conversion will be done only forhtml_escape(attr = TRUE).The arguments
beforeandafterofread_all()can take functions of two arguments now, with the second argument being the content of each file.Added an argument
starttomake_fence().
CHANGES IN xfun VERSION 0.48
CRAN release: 2024-10-03
Added utilities for HTML tags:
html_tag(),html_escape(),html_escape(), andhtml_view(). Removed the soft dependency on the htmltools package accordingly.base_pkgs()is faster now: it callstools::standard_package_names()if the function exists (R >= 4.4.0), otherwise it just returns a constant vector of base package names (thanks, @arnaudgallou, #91).Added a function
mime_type()to obtain the MIME types of files viamime::guess_type()if mime is installed, otherwise it will calltools:::mime_type(), and fall back to using a system command (e.g.,file --mime-type) to obtain the types.Added a function
file_rename()to deal withfile.rename()failures by callingfile.copy()(thanks, @Giqles @katrinabrock, rstudio/bookdown#804).new_app()will useutils::browseURL()to open the app ifoptions('viewer')is not configured (thanks, @AlbertLei, yihui/litedown#29).Added a method
record_print.record_asis()to return the object as is.
CHANGES IN xfun VERSION 0.47
CRAN release: 2024-08-17
Added functions
lazy_save()andlazy_load()to save objects to files and lazy-load them.Fixed a bug in
record(dev = svglite::svglite)that misplaced plots when low-level plot functions are used (thanks, @liao961120, yihui/litedown#17).Specified the lowest R version required (v3.2.0) for this package.
CHANGES IN xfun VERSION 0.46
CRAN release: 2024-07-18
md_table()should add a vertical ellipsis to row names when rows are truncated by thelimitargument.session_info()recognizes Positron now (thanks, @chuxinyuan, #89).
CHANGES IN xfun VERSION 0.45
CRAN release: 2024-06-16
For
record()withverbose = 1or2, invisibleNULLis no longer printed.Rscript_call()will show the actual error message (if an error occurred) during calling the function in a new R session.
CHANGES IN xfun VERSION 0.44
CRAN release: 2024-05-15
Added a function
cache_exec()to cache the execution of an expression either in memory or on disk. It is much more general and flexible thancache_rds(). For example, it supports custom reading/writing methods for cache files, and can load locally created variables in the expression while loading cache.Added an argument
cachetorecord()to make it possible to enable caching.Added arguments
messageandwarningtorecord()to decide whether messages and warnings should be recorded.Changed the default value of the argument
errorofrecord()fromFALSEtoNA. NowFALSEmeans to suppress error messages, andNAmeans to throw errors normally. This is for consistency with themessageandwarningarguments.Added an S3 generic function
record_print(), which is similar toknitr::knit_print()but for the purpose of printing visible values inrecord().The
record()function gained new argumentsprintandprint.argsto support custom printing functions and arguments.Added a function
md_table(), which is a minimal Markdown table generator.Exported the internal function
md5()to calculate the MD5 checksums of R objects. The function is essentially a workaround fortools::md5sum()(see HenrikBengtsson/Wishlist-for-R#21).For
fenced_block(), a space is added between the backticks and the language name, e.g.,```rhas become``` rnow. This will affect snapshot tests based on Markdown (an example).Added a shorthand
fenced_div()forfenced_block(char = ':').write_utf8()returns theconargument (typically a file path) now. Previously, it returnsNULL.Added an experimental function
new_app()to create a local web application.The returned value of
yaml_body()contains a new elementlinesin the list indicating the line numbers of YAML metadata if exists.Removed the
skipargument fromsplit_source().For
split_source(line_number = TRUE), the attribute name for line numbers in the returned value was changed fromline_start(a single starting line number) tolines(both the starting and ending numbers).Fixed an edge case in
prose_index(), in which inline code was incorrectly recognized as a code block fence.
CHANGES IN xfun VERSION 0.43
CRAN release: 2024-03-25
Added a function
upload_imgur(), which was adapted fromknitr::imgur_upload(). The latter will call the former in the future.xfun::upload_imgur()allows users to choose whether to use the system commandcurlor the R package curl to upload the image. It also has a new argumentinclude_xmlto specify whether the XML response needs to be included in the returned value.Added a function
fenced_block()to create a fenced block in Markdown (thanks, @cderv, yihui/knitr#2331). The block can be either a code block or a fenced Div.Fixed a bug in
xfun::record()when the argumentverbose = 1or2.
CHANGES IN xfun VERSION 0.42
CRAN release: 2024-02-08
isFALSE()has been fully deprecated for R >= 3.5.0, and will be completely removed from this package in the future (https://yihui.org/en/2023/02/xfun-isfalse/).Added a function
record()to run R code and record the results, which is similar toevaluate::evaluate()but less sophisticated and technically simpler. One major difference is thatxfun::record()records plots directly to files instead of saving them as display lists.yaml_load()gained anenvirargument, which can be used to specify the environment to evaluate R expressions in YAML (i.e., expressions written after!expror!r). This is not straightforward in the upstream yaml package (thanks, @viking, vubiostat/r-yaml#54).yaml_body()gained the...argument to pass more arguments toyaml_load().split_source()gained amerge_commentsargument to merge consecutive lines of comments into the next code block, aline_numberargument to store the line number of each expression in the returned value, and askipargument to skip the rest of the code when the skip token is found.check_old_package()has been vectorized, i.e., the argumentsnameandversioncan take vectors now.Factored out the code for parsing chunk options and dividing a chunk into chunk options and chunk body from knitr to this package as functions
csv_options()anddivide_chunk(), respectively. They will be used by knitr and other packages in future.Added a function
decimal_dot()to evaluate an expression after forcingoptions(OutDec = '.')andSys.setlocale(LC_NUMERIC = 'C')(for rstudio/rmarkdown#2525).
CHANGES IN xfun VERSION 0.41
CRAN release: 2023-11-01
process_file()will write to the file only if the processed text is different with the input text. This is to avoid writing files unnecessarily.session_info()will remove extra blank lines (thanks, @chuxinyuan, #82) and also omit the time zone info.
CHANGES IN xfun VERSION 0.40
CRAN release: 2023-08-09
number_to_words()supports decimal numbers now (thanks, @harshvardhaniimi, #80).is_ascii()is more robust now (thanks, @bastistician, #81).
CHANGES IN xfun VERSION 0.39
CRAN release: 2023-04-20
Fixed a bug that
protect_math()fails to protect the starting$$that has leading white spaces.Added a function
strip_html()to remove HTML tags and comments from text.The function
alnum_id()will remove HTML tags and comments from text (usingstrip_html()) before converting it to an ID string.Added a function
env_option()to retrieve an option value fromoptions(). If the option does not exist there, check the environment variables. This provides a way for users to set an option via eitheroptions()or an environment variable.
CHANGES IN xfun VERSION 0.38
CRAN release: 2023-03-24
Added an object
download_cache, which is a list of methods to download a URL, cache the result, retrieve the result from the cache, and clear the cache.Added an argument
defaulttourl_filename()to provide a default filename when it cannot be determined from the URL.Added a function
yaml_load()to read YAML data when the yaml package is not available. It only supports a limited number of data types and is supposed to be used as a fallback method. See the help page?xfun::yaml_loadfor details.Added a function
yaml_body()to split a document into YAML metadata and the body.is_arm64()also supports Linux now (thanks, @eitsupi, #74).is_blank()returns a logical vector of the same length as the input vector now, indicating if each element of the input is blank. Previously it returns a logical scalar indicating whether all elements are blank. If you want the old behavior, you can useall(is_blank()).
CHANGES IN xfun VERSION 0.37
CRAN release: 2023-01-31
Added a function
is_arm64()to test the CPU type (thanks, @AlbanSagouis, #72).Started deprecating
xfun::isFALSE()in favor ofbase::isFALSE()for R >= 3.5.0 (thanks, @mmaechler, #66);isFALSE()will eventually be removed from xfun when we do not need to support R < 3.5.0.
CHANGES IN xfun VERSION 0.36
CRAN release: 2022-12-21
- Added a new argument
resolve_symlinktonormalize_path()to get the absolute paths of symlinks without resolving them (withresolve_symlink = FALSE).
CHANGES IN xfun VERSION 0.35
CRAN release: 2022-11-16
Added a new argument
tokentoprotect_math()to optionally include a token around math expressions.base64_uri()relies less on the mime package now. For some common file extensions (e.g.,.jpg/.png), this function knows their MIME types.stringsAsStrings()has been removed from this package.
CHANGES IN xfun VERSION 0.34
CRAN release: 2022-10-18
Added a new function
alnum_id()to generate ID strings from a character vector.The function
stringsAsStrings()has been deprecated.
CHANGES IN xfun VERSION 0.33
CRAN release: 2022-09-12
Reverted the change for #68: the characters
-+!_#are no longer accepted by default in filename extensions, since they are relatively rare and caused a breakage in rstudio/bookdown#1369. If you wish to allow for these characters, you may use the newextraargument infile_ext()and related functions, e.g.,xfun::file_ext(x, extra = '-+!_#').The function
stringsAsStrings()will be deprecated in a future release of xfun, because the global optionstringsAsFactors = FALSEhas become the default in base R since 4.0.0.
CHANGES IN xfun VERSION 0.32
CRAN release: 2022-08-10
Added a function
shrink_images()to shrink images to a maximum width using the magick package (thanks, @apreshill, rstudio/blogdown#614).Added a function
tinify_dir()as a wrapper oftinify()to compress images under a directory.file_ext()supports more file extensions now, such as.c++,.FB2K-COMPONENT, and so on (thanks, @tentacles-from-outer-space, #68).Fixed the issue that
xfun::base_pkgs()could hang R (thanks, @mmaechler, #66).The
...argument indir_create()was not passed todir.create().
CHANGES IN xfun VERSION 0.31
CRAN release: 2022-05-10
github_releases(use_jsonlite = FALSE)supports R versions below 4.1.0 now.session_info()silently drops empty package names now (thanks, @phargarten2, #65).
CHANGES IN xfun VERSION 0.30
CRAN release: 2022-03-02
Added a new function
is_blank()(previously existed in knitr) to test if all elements of a character vector are blank (white spaces or empty strings).Added a new argument
error = TRUEtoexisting_files().
CHANGES IN xfun VERSION 0.29
CRAN release: 2021-12-14
github_releases()can fetch all releases (tags) of a Github repo now.Added an argument
.errortodownload_file()so that users can customize the error message when the download fails.Added functions
rest_api_raw()andrest_api()to get data from a REST API; also added the functiongithub_api()to get data from the Github API based onrest_api_raw().Added a wrapper function
system3()based onsystem2()to mark the character output ofsystem2()as UTF-8 if appropriate.Added a function
existing_files()to return file paths that exist (a shorthand ofx[file.exists(x)]).Added a function
read_all()to read multiple files and concatenate the content into a character vector.url_accessible()usescurlGetHeaders()by default (instead ofdownload_file()) to test if a URL is accessible when the curl package is not available.When
options(xfun.rev_check.compare = FALSE),rev_check()will runR CMD checkon reverse dependencies against a source package but not the CRAN version of this package. By default, this option isTRUE, meaning thatR CMD checkwill run against both versions of the package.
CHANGES IN xfun VERSION 0.28
CRAN release: 2021-11-04
Added a new function
url_accessible()to test if a URL can be downloaded.Added a new function
try_error()to try an expression and see if it throws an error.
CHANGES IN xfun VERSION 0.27
CRAN release: 2021-10-18
Exported and documented the function
xfun::base_pkgs()(to return base R package names).Changed the default value of the
status_onlyargument ofcompare_Rcheck()fromFALSEtoTRUE.Added new functions
crandalf_check()andcrandalf_results()for checking (especially large numbers of) reverse dependencies of packages via crandalf.Added new functions
append_utf8()andappend_unique()based onread_utf8()andwrite_utf8()to append content to files or connections.
CHANGES IN xfun VERSION 0.26
CRAN release: 2021-09-14
The
windows_onlyargument ofnative_encode()has been removed. Nownative_encode()only tries the conversion to native encoding on platforms wherel10n_info()[['UTF-8']]does not returnTRUE.Added a
solarisargument toupload_win_builder().
CHANGES IN xfun VERSION 0.25
CRAN release: 2021-08-06
Fixed a bug in
broken_packages()(thanks, @PythonCoderUnicorn, rstudio/rmarkdown#1990).Added a
filesargument tooptipng()so that users can specify the list of PNG files instead of runningoptipngon a whole directory.
CHANGES IN xfun VERSION 0.24
CRAN release: 2021-06-15
Exported the internal function
broken_packages()to reinstall broken R packages.Fixed the bug in
proj_root()#54 (thanks, @clarkliming).
CHANGES IN xfun VERSION 0.23
CRAN release: 2021-05-15
NEW FEATURES
Added a
tinify()function to compress PNG/JPEG images via the Tinify API.Added a
news2md()function to convert package news to the Markdown format. This is mainly for converting the plain-textNEWSfile and theNEWS.Rdfile toNEWS.md.Added a
format_bytes()function to format numbers of bytes using a specified unit, e.g.,1024can be formatted as1 Kb.When using
pkg_load2()in an renv project, it will userenv::install()to install missing packages by default to take advantage of renv’s caching feature (thanks, @chunyunma @cderv, #52).upload_win_builder()no longer requires the system commandcurlto be available; ifcurlis not available, the R package curl will be used instead, which means this R package must be installed. In addition to uploading to theftpserver of win-builder, it’s also possible to upload to https://win-builder.r-project.org/upload.aspx: callupload_win_builder(..., server = 'https'). This change was made so that it would be possible to continue to upload to win-builder in case it should stop supportingftp(CRAN has discouraged package authors from usingftp://).
BUG FIXES
- Backticks are added to math environments by mistake when
\begin{}and\end{}do not match (thanks, @oliviergimenez, #51).
MINOR CHANGES
The argument
srcwas renamed topkgininstall_dir().The argument
fileofupload_win_builder()defaults topkg_build()now, i.e., by default, it will build a source package and upload it, so you do not need to build the package separately.
CHANGES IN xfun VERSION 0.22
CRAN release: 2021-03-11
NEW FEATURES
relative_path()is vectorized now.Added a new function
retry()to retry calling a function for a number of times in case of errors.Added a new function
sort_file(), which is a shorthand forprocess_file(fun = sort)to sort the lines in a text file.
MAJOR CHANGES
- The argument
FUNwas renamed tofuninprocess_file().
MINOR CHANGES
- Inside
download_file(), thetimeoutoption inoptions()is set to 3600 seconds when it takes the default value of 60 seconds, which may not be enough for downloading large files (thanks, @matthewgson, yihui/tinytex#286).
CHANGES IN xfun VERSION 0.21
CRAN release: 2021-02-10
NEW FEATURES
Added a new function
pkg_available()to test if a package with a minimal version is available (thanks, @cderv, #45).Added a new function
set_envvar()to set environment variables and return their old values, so they could be restored later.Added a new function
exit_call()to call a function when a parent function exits.Exported the internal function
read_bin().Added an argument
verbosetobg_process().Rscript_call()gains anoptionsargument to pass command-line options toRscript(thanks, @cderv, #48).
CHANGES IN xfun VERSION 0.20
CRAN release: 2021-01-06
NEW FEATURES
Added a function
msg_cat()to generate a message withcat(). See the help page?xfun::msg_catfor more information.Added a function
mark_dirs()to mark directories with a trailing slash in a vector of paths to differentiate them from normal filenames (#44).
BUG FIXES
xfun::proc_kill()failed to work on *nix.xfun::del_empty_dir()failed to delete empty dirs.xfun::file_string()preserves emptiness (thanks, @MichaelChirico, #38).xfun::raw_string()preserves the class(es) of the input now (thanks, @MichaelChirico, #40).
MINOR CHANGES
- Exported the function
dir_create().
CHANGES IN xfun VERSION 0.19
CRAN release: 2020-10-30
NEW FEATURES
Added functions
bg_process()to run a command in a background process, andproc_kill()to kill a process.Added a function
del_empty_dir()to delete a directory if it is empty.Added functions
is_abs_path()andis_rel_path()to check if paths are absolute or relative.Added a function
is_sub_path()to test if a path is under a directory.Added a function
is_web_path()to test if a path is a web path that starts withhttp://orhttps://orftp://orftps://.Documented and exported the previously internal functions
dir_exists()andfile_exists()(thanks, @cderv, #36).Added a function
dir_create()to create a directory recursively by default when it does not exist.Added an argument
failtoRscript_call()to allow users to customize the error message when an error occurred in calling the function in a new R session.
MINOR CHANGES
-
file_ext(),sans_ext(), andwith_ext()no longer usetools::file_ext()ortools::file_path_sans_ext(), but provide a slightly different implementation. They treattar.(gz|bz2|xz)andnb.htmlas file extensions, and also allow extensions to contain a trailing~or#.
CHANGES IN xfun VERSION 0.18
CRAN release: 2020-09-29
NEW FEATURES
Added a function
grep_sub()to perform replacement withgsub()on elements matched fromgrep().Added a function
github_releases()to obtain the tags from the Github releases of a repo.Added a function
bump_version()to increase the last digit of version numbers by one.Moved a function
process_file()from the blogdown package to this package, and documented it.Added a function
valid_syntax()to check if an R code fragment is syntactically valid. This function was moved from the highr package.Added a function
url_filename()to extract filenames from URLs. This function is used bydownload_file()to determine the default output filename.Added a function
do_once()to perform a task once in an R session.Added a function
proj_root()to find the root directory of a project. Currently it only supports R package projects and RStudio projects by default.Added a function
relative_path()to calculate the relative path of a path relative to a directory.Added a function
from_root(), which is similar tohere::here()but returns a relative path instead of an absolute path.Added a function
magic_path()that, given an incomplete input path, tries to find the actual path recursively under subdirectories of a root directory. For example, users may only provide a base filename, andmagic_path()will look for this file under subdirectories and return the actual path if it is found.
MINOR CHANGES
- Now
download_file()tries the download methodwinnetfirst (previously it waslibcurl) on Windows (thanks, @cderv, #33).
CHANGES IN xfun VERSION 0.17
CRAN release: 2020-09-09
NEW FEATURES
Supports
xfun::pkg_attach(packages, install = "pak"), i.e., usepak::pkg_install()to install a package when it is not installed (thanks, @GitHunter0, #32).Added a new function
xfun::split_source()to split lines of R source code into minimal complete expressions. This function was moved from the highr package.
CHANGES IN xfun VERSION 0.16
CRAN release: 2020-07-24
- Added a new function
base64_decode()to decode data from the base64 encoding (thanks, @wush978, #31).
CHANGES IN xfun VERSION 0.15
CRAN release: 2020-06-21
NEW FEATURES
Added a new function
tree(), which is based onstr()in base R, but changes the output ofstr()into a tree diagram to make it easier to understand nested data structures.Added a new function
base64_encode()to encode data into the base64 encoding (thanks, @wush978, #27).Added a new function
base64_uri()to generate the Data URI (or Data URL) for a file.
CHANGES IN xfun VERSION 0.14
CRAN release: 2020-05-20
NEW FEATURES
- The
cache_rds()function can invalidate the cache automatically when the code passed to itsexprargument has changed. Two new arguments,hashandcleanwere added to this function to make it more useful and powerful. See the help page?xfun::cache_rds()for more information.
CHANGES IN xfun VERSION 0.13
CRAN release: 2020-04-13
NEW FEATURES
Added a new function
cache_rds()to cache an R expression to a*.rdsfile.Added a new function
Rscript_call()to call a function (with arguments) in a new R session via the commandRscript.The
recheckargument ofrev_check()can take a vector of package names, and only these packages will be checked. See?xfun::rev_checkfor more details.
CHANGES IN xfun VERSION 0.12
CRAN release: 2020-01-13
NEW FEATURES
- Added a new function
split_lines().
CHANGES IN xfun VERSION 0.11
CRAN release: 2019-11-12
BUG FIXES
-
read_utf8()will read the file withoptions(encoding = 'native.enc')and ignore user’s setting such asoptions(encoding = 'UTF-8')(#21).
CHANGES IN xfun VERSION 0.10
CRAN release: 2019-10-01
NEW FEATURES
- Added the function
as_strict_list()to convert an existing object to a strict list without wrapping it in another list if the object already is of type list (in contrast to howstrict_list()behaves) (thanks, @salim-b, #20).
CHANGES IN xfun VERSION 0.9
CRAN release: 2019-08-21
NEW FEATURES
- Added a function
rename_seq()to rename files to add an incremental numeric prefix to the filenames, e.g., renamea.txt,b.txt,c.txtto1-a.txt,2-b.txt,3-c.txt.
CHANGES IN xfun VERSION 0.8
CRAN release: 2019-06-25
MINOR CHANGES
-
xfun::write_utf8(NULL)is equivalent toxfun::write_utf8(character(0))now (thanks, @schloerke, yihui/knitr#1714).
CHANGES IN xfun VERSION 0.7
CRAN release: 2019-05-14
MINOR CHANGES
-
loadable()is quiet with R 3.6.0 (https://stat.ethz.ch/pipermail/r-devel/2019-May/077774.html).
CHANGES IN xfun VERSION 0.6
CRAN release: 2019-04-02
NEW FEATURES
- Added the
...argument tosame_path()to pass additional arguments tonormalize_path().
BUG FIXES
- The
warnargument inprose_index()failed to suppress warnings.
CHANGES IN xfun VERSION 0.5
CRAN release: 2019-02-20
NEW FEATURES
Added functions
upload_ftp()andupload_win_builder()to upload files to FTP servers.Added a function
stringsAsStrings()(see its help page for details).Added an argument
warntoprose_index()to suppress the warning when code fences are not balanced.
BUG FIXES
- Fixed the bug that
prose_index()recognizes double backticks as code fences (thanks, @shrektan, #14 #15).
CHANGES IN xfun VERSION 0.4
CRAN release: 2018-10-23
NEW FEATURES
Added functions
embed_file(),embed_dir(), andembed_files()to embed files in an HTML output file (e.g., from R Markdown), so that the files can be directly downloaded from the web browser. One use case is to call one of these functions in an R code chunk of an Rmd document to embed the Rmd source document or data files in the HTML output, so readers can download them.Added a new argument
messagetopkg_attach(), so you can suppress package startup messages viaxfun::pkg_attach(..., message = FALSE)or set the global optionoptions(xfun.pkg_attach.message = FALSE)(thanks, @wch, yihui/knitr#1583).
MINOR CHANGES
The argument
rw_errorwas moved fromgsub_dir()togsub_file()(gsub_dir(rw_error = ...)will still work).is_ascii()now returnsNAforNA_character_(thanks, @shrektan, #8 #9).
CHANGES IN xfun VERSION 0.3
CRAN release: 2018-07-06
NEW FEATURES
Added a new functions
download_file()to try various methods to download a file.Added a new function
is_ascii()to test if a character vector only consists of ASCII characters.Added a new function
numbers_to_words()to convert numbers to English words (thanks, @daijiang, #3).
CHANGES IN xfun VERSION 0.2
CRAN release: 2018-06-16
NEW FEATURES
Added a
new_sessionargument toloadable().Added new functions
gsub_file(),gsub_files(),gsub_dir(), andgsub_ext()to replace strings in files.Added new functions
RscriptandRcmdas wrappers ofsystem2('Rscript')andsystem2('R', 'CMD'), respectively.Added a new function
install_dir()to install a source package from a directory.Added a new function
file_string()to read a text file (encoded in UTF-8) and return its content a single character string (lines concatenated by\n).Added a new function
raw_string()to print a character vector in its “raw” form usingcat(..., sep = '\n')instead ofprint(), because the latter may introduce[1], “extra” double quotes, and escape sequences, which are not very human-readable.Added a new function
session_info()as an alternative tosessionInfo().Added a new function
rev_check()to runR CMD checkon the reverse dependencies of a package, and a corresponding helper functioncompare_Rcheck()for showing the differences in logs with the CRAN version and the current version of the package, respectively.Added new functions for dealing with Markdown text:
prose_index()returns the line indices of text that is prose (not code blocks), andprotect_math()protects math expressions in Markdown in backticks.Added an
errorargument toread_utf8()to signal an error if the file is not encoded in UTF-8.
CHANGES IN xfun VERSION 0.1
CRAN release: 2018-01-22
NEW FEATURES
attr()as an abbreviation ofbase::attr(exact = TRUE).file_ext(),sans_ext(), andwith_ext()to manipulate extensions in filenames.in_dir()to evaluate an R expression in a directory.isFALSE()as an abbreviation ofidentical(x, FALSE).is_windows(),is_macos(),is_linux(), andis_unix()to test operating systems.native_encode()to try to encode a character vector in the native encoding.normalize_path()as an abbreviation ofnormalizePath(winslash = '/', mustWork = FALSE).optipng()to run the commandoptipngto optimize all PNG files under a directory.parse_only()parses R code without keeping the source references.pkg_attach()andpkg_load()to attach and load a vector of packages, respectively (and optionally, install the missing packages).read_utf8()andwrite_utf8()to read and write UTF-8 files, respectively.same_path()to test if two paths are the same.strict_list()is a version oflist()that disables partial matching of the$operator.tojson()is a simple JSON serializer.try_silent()is an abbreviation oftry(silent = TRUE).