Title: | 'RStudio' Addins to Simplify 'Markdown' Writing |
---|---|
Description: | An 'RStudio' addin providing shortcuts for writing in 'Markdown'. This package provides a series of functions that allow the user to be more efficient when using 'Markdown'. For example, you can select a word, and put it in bold or in italics, or change the alignment of elements inside you Rmd. The idea is to map all the functionalities from 'remedy' on keyboard shortcuts, so that it provides an interface close to what you can find in any other text editor. |
Authors: | Colin Fay [aut, cre] , Jonathan Sidi [aut] , Luke Smith [aut] (author of seasmith/AlignAssign), Jonathan Carroll [ctb] , Andrzej Oleś [ctb] , Daniel Possenriede [ctb] , ThinkR [cph] |
Maintainer: | Colin Fay <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2024-12-21 02:38:35 UTC |
Source: | https://github.com/ThinkR-open/remedy |
Align a highlighted region's assignment operators.
align_arrow()
align_arrow()
Aligns the single assignment operators (<-
) within a highlighted region.
## Not run: remedy_example( c( "# Align arrows", "a <- 12", "aaa <- 13"), align_arrow ) ## End(Not run)
## Not run: remedy_example( c( "# Align arrows", "a <- 12", "aaa <- 13"), align_arrow ) ## End(Not run)
Align a highlighted region's assignment operators.
align_equal()
align_equal()
Aligns the equal sign assignment operators (=
) within a
highlighted region.
## Not run: remedy_example( c( "# Align equal signs", "a = 12", "aaa = 13"), align_equal ) ## End(Not run)
## Not run: remedy_example( c( "# Align equal signs", "a = 12", "aaa = 13"), align_equal ) ## End(Not run)
Backtick selected word(s)
backtickr()
backtickr()
a backticked text selection
## Not run: remedy_example( c( "to_backtick"), backtickr ) ## End(Not run)
## Not run: remedy_example( c( "to_backtick"), backtickr ) ## End(Not run)
Turn the selected text into a blockquote.
blockquoter()
blockquoter()
a markdown blockquote
## Not run: remedy_example( c( "to_blockquote"), blockquoter ) ## End(Not run)
## Not run: remedy_example( c( "to_blockquote"), blockquoter ) ## End(Not run)
Addin that add in bulk a names to unnamed chunks in a Rmarkdown document in the source editor.
chunknamer()
chunknamer()
By default the addin will use "remedy" as the stem of the chunk names. this an be changed using
remedy_opts
$set(name='ANOTHER NAME'). The names are then added in sequential order using
an
Addin that splits full documents into Rmarkdown chunks or wraps highlighted text in an active RStudio document editor in a Rmarkdown chunk.
chunkr() chunkr_doc() chunkr_section()
chunkr() chunkr_doc() chunkr_section()
Setting remedy_opts
$set(list(full_doc=TRUE)) chunkr will convert entire document by
remedy_opts
$get('token_purl'). The default token is the output from a purl
conversion (## —-chunk name,chunk options—-).
Setting remedy_opts
$set(list(full_doc=FALSE)), user highlights text and chunkr will
wrap a new Rmarkdown chunk around it, utilizing the other options in remedy_opts
.
## Not run: remedy_example( c( "# Create a chunk", "a <- 12", "aaa <- 13"), chunkr ) ## End(Not run)
## Not run: remedy_example( c( "# Create a chunk", "a <- 12", "aaa <- 13"), chunkr ) ## End(Not run)
Split a chunk into two chunks
chunksplitr()
chunksplitr()
Will split below row of the current cursor position or under the highlighted text.
Create a footnote from selected text.
footnoter()
footnoter()
footnote text (in markdown)
## Not run: remedy_example( c( "# Create a footnote"), footnoter ) ## End(Not run)
## Not run: remedy_example( c( "# Create a footnote"), footnoter ) ## End(Not run)
Convert selected text into a header.
h1r() h2r() h3r() h4r() h5r() h6r()
h1r() h2r() h3r() h4r() h5r() h6r()
a markdown header
## Not run: remedy_example( c( "h1"), h1r) remedy_example( c( "h2"), h2r) remedy_example( c( "h3"), h3r) remedy_example( c( "h4"), h4r) remedy_example( c( "h5"), h5r) remedy_example( c( "h6"), h6r) ## End(Not run)
## Not run: remedy_example( c( "h1"), h1r) remedy_example( c( "h2"), h2r) remedy_example( c( "h3"), h3r) remedy_example( c( "h4"), h4r) remedy_example( c( "h5"), h5r) remedy_example( c( "h6"), h6r) ## End(Not run)
RStudio addin to add/remove html comments to highlighted text
htmlcommentr()
htmlcommentr()
Highlighting text will add html comment tags around it
Highlighting commented text will remove tags.
Highlighting
Something COMMENT Something
Something <!– COMMENT –> Something
New Comment
Something COMMENT [cursor here] Something
Something COMMENT <!– –> Something
Start of Row
[cursor here] Something COMMENT Something
<!– Something COMMENT Something –>
Highlighting Multiple rows
Something COMMENT Something
Something COMMENT Something
<!– Something COMMENT Something
Something COMMENT Something –>
## Not run: remedy_example( c( "<b>This is bold</b>"), htmlcommentr) ## End(Not run)
## Not run: remedy_example( c( "<b>This is bold</b>"), htmlcommentr) ## End(Not run)
Convert selected text into a markdown ref.
id_ref()
id_ref()
A referenced content
Only the three most common reference types are implemented: id, fig, and tab.
## Not run: remedy_example( "pouet", id_ref ) ## End(Not run)
## Not run: remedy_example( "pouet", id_ref ) ## End(Not run)
Convert the selected path into an embedded image
imager()
imager()
a markdown image link
## Not run: remedy_example( c( "https://thinkr.fr/wp-content/uploads/2015/03/thinkR1.png"), imager ) ## End(Not run)
## Not run: remedy_example( c( "https://thinkr.fr/wp-content/uploads/2015/03/thinkR1.png"), imager ) ## End(Not run)
Check if text is a relative link or URL
is_link(text)
is_link(text)
text |
A character string |
TRUE or FALSE
is_link("www.google.com") is_link("figs/plot.png")
is_link("www.google.com") is_link("figs/plot.png")
Emphasize the selected text.
italicsr() boldr() striker()
italicsr() boldr() striker()
emboldened, italicized or strikethrough text (in markdown)
## Not run: remedy_example( c( "to_italic"), italicsr ) remedy_example( c( "to_bold"), boldr ) remedy_example( c( "to_strike"), striker ) ## End(Not run)
## Not run: remedy_example( c( "to_italic"), italicsr ) remedy_example( c( "to_bold"), boldr ) remedy_example( c( "to_strike"), striker ) ## End(Not run)
Convert the selected text in inline LaTeX.
latexr()
latexr()
inline LaTeX text (in markdown)
## Not run: remedy_example( c( "Latex stuffs"), latexr ) ## End(Not run)
## Not run: remedy_example( c( "Latex stuffs"), latexr ) ## End(Not run)
Convert selected text into an (un)ordered list.
listr() olistr()
listr() olistr()
listr()
returns an unordered markdown list
olistr()
returns an ordered markdown list
## Not run: #unordered list remedy_example(c('line 1','line 2'),listr) #ordered list remedy_example(c('line 1','line 2'),olistr) ## End(Not run)
## Not run: #unordered list remedy_example(c('line 1','line 2'),listr) #ordered list remedy_example(c('line 1','line 2'),olistr) ## End(Not run)
Utility functions to deploy functions and tests for addins
remedy_example(txt, addin, mark = entire_document) scratch_file() entire_document() individual_lines() set_text(txt = "", sec, mark)
remedy_example(txt, addin, mark = entire_document) scratch_file() entire_document() individual_lines() set_text(txt = "", sec, mark)
txt |
character, text to place in temporary document |
addin |
function, addin function to deploy |
mark |
function, highlight using entire_document or individual_lines |
sec |
source editor context object |
These function only will work in a RStudio IDE
New document in source editor of RStudio
Options for functions in the remedy package. When running R code, the object remedy_opts
(default options) is not modified by chunk headers (local chunk options are
merged with default options), whereas remedy_opts_current
(current options)
changes with different chunk headers and it always reflects the options for
the current chunk.
Normally we set up the global options once in the first code chunk in a
document using remedy_opts$set()
, so that all latter chunks will
use these options. Note the global options set in one chunk will not affect
the options in this chunk itself, and that is why we often need to set global
options in a separate chunk.
Below is a list of default chunk options, retrieved via
remedy_opts$get()
:
remedy_opts remedy_opts_current
remedy_opts remedy_opts_current
An object of class list
of length 5.
An object of class list
of length 5.
remedy_opts_current
is read-only in the sense that it does nothing if
you call remedy_opts_current$set()
; you can only query the options via
remedy_opts_current$get()
.
remedy_opts$get()
remedy_opts$get()
Copy a selected text or the current line to the right
rightr()
rightr()
a clone of the line
## Not run: remedy_example( c( "I like to move it "), rightr ) ## End(Not run)
## Not run: remedy_example( c( "I like to move it "), rightr ) ## End(Not run)
Insert a table in your file.
tabler()
tabler()
a markdown table
## Not run: remedy_example( "head(iris)", tabler ) ## End(Not run)
## Not run: remedy_example( "head(iris)", tabler ) ## End(Not run)
Convert selected text into a link
urlr()
urlr()
a markdown link
## Not run: remedy_example( "https://www.thinkr.fr", urlr ) ## End(Not run)
## Not run: remedy_example( "https://www.thinkr.fr", urlr ) ## End(Not run)
xaringan pull left and pull right
xaringanr()
xaringanr()
a template for xaringan pull left and right
## Not run: remedy_example( "", xaringanr ) ## End(Not run)
## Not run: remedy_example( "", xaringanr ) ## End(Not run)
Highlight youtube link in source editor and it will be converted to a markdown link with an image saved in youtube.
youtuber()
youtuber()
if remedy_opts$get('youtube_output')=='md' then the output will be of the form
[![Alternative text](Youtube Image)](Link to Video). (useful for github readme)
if remedy_opts$get('youtube_output')=='html' then the output will be of the form
<iframe width="remedy_opts$get('youtube_width')" height="remedy_opts$get('youtube_height')" src="link to video" frameborder="0" allowfullscreen></iframe>
Default Settings:
remedy_opts$get('youtube_output'): str(remedy::remedy_opts$get('youtube_output'))
remedy_opts$get('youtube_height'): str(remedy::remedy_opts$get('youtube_height'))
remedy_opts$get('youtube_width'): str(remedy::remedy_opts$get('youtube_width'))
## Not run: remedy_example( "https://www.youtube.com/watch?v=dQw4w9WgXcQ", youtuber ) ## End(Not run)
## Not run: remedy_example( "https://www.youtube.com/watch?v=dQw4w9WgXcQ", youtuber ) ## End(Not run)