Skip to content

Commit

Permalink
Recognize Shiny
Browse files Browse the repository at this point in the history
  • Loading branch information
flujoo committed Jun 3, 2022
1 parent c818540 commit 0d776f9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: gm
Type: Package
Title: Generate Music Easily and Show Them Anywhere
Version: 1.0.3
Version: 1.0.4
Author: Renfei Mao
Maintainer: Renfei Mao <renfeimao@gmail.com>
Description: Provides a simple and intuitive high-level language, with which
Expand Down Expand Up @@ -30,6 +30,7 @@ Imports:
MASS,
rlang,
rstudioapi,
shiny,
stringr,
utils
Roxygen: list(markdown = TRUE)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# gm 1.0.4

* Recognize Shiny apps.


# gm 1.0.3

* Change default score margin to 0.
Expand Down
8 changes: 5 additions & 3 deletions R/external.R
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ get_show_context <- function() {
if (isTRUE(getOption('knitr.in.progress'))) {
# check if knit to pdf or word
ifelse(knitr::is_html_output(), "rmd", "rmd_other")
} else if (shiny::isRunning()) {
"shiny"
} else if (rstudioapi::isAvailable()) {
"rstudio"
} else if (is_jupyter()) {
Expand Down Expand Up @@ -322,7 +324,7 @@ show_musicxml <- function(musicxml, to, musescore) {
} else {
content <- generate_show_content(name_path, to, context)

if (context %in% c("rmd", "jupyter")) {
if (context %in% c("rmd", "jupyter", "shiny")) {
content

} else {
Expand Down Expand Up @@ -401,8 +403,8 @@ generate_file_path <- function(name_path, format, context) {
file_path %<>% basename()
}

# use data URL in R Markdown documents and Jupyter Notebooks
if (context %in% c("jupyter", "rmd")) {
# use data URL in R Markdown documents, Jupyter Notebooks and Shiny apps
if (context %in% c("jupyter", "rmd", "shiny")) {
file_path %<>% {base64enc::dataURI(file = .)}
}

Expand Down

0 comments on commit 0d776f9

Please sign in to comment.