Skip to content

Commit

Permalink
Replace spaces with underscores when mapping filenames to ids in the …
Browse files Browse the repository at this point in the history
…showcase, closes #1926
  • Loading branch information
cpsievert committed Sep 9, 2019
1 parent 2e0221e commit 26dd456
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions R/showcase.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ navTabsHelper <- function(files, prefix = "") {
lapply(files, function(file) {
with(tags,
li(class=if (tolower(file) %in% c("app.r", "server.r")) "active" else "",
a(href=paste("#", gsub(".", "_", file, fixed=TRUE), "_code", sep=""),
a(href=paste0("#", gsub("\\.|\\s+", "_", file), "_code"),
"data-toggle"="tab", paste0(prefix, file)))
)
})
Expand All @@ -105,12 +105,11 @@ navTabsDropdown <- function(files) {
tabContentHelper <- function(files, path, language) {
lapply(files, function(file) {
with(tags,
div(class=paste("tab-pane",
div(class=paste0("tab-pane",
# TODO: what if the app filename is something else?
if (tolower(file) %in% c("app.r", "server.r")) " active"
else "",
sep=""),
id=paste(gsub(".", "_", file, fixed=TRUE),
"_code", sep=""),
else ""),
id=paste0(gsub("\\.|\\s+", "_", file), "_code"),
pre(class="shiny-code",
# we need to prevent the indentation of <code> ... </code>
HTML(format(tags$code(
Expand Down
2 changes: 1 addition & 1 deletion inst/www/shared/shiny-showcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
el = document.createElement("span");
el.id = "srcref_" + srcref;
var ref = srcref;
var code = document.getElementById(srcfile.replace(/\./g, "_") + "_code");
var code = document.getElementById(srcfile.replace(/\.|\s+/g, "_") + "_code");
var start = findTextPoint(code, ref[0], ref[4]);
var end = findTextPoint(code, ref[2], ref[5]);

Expand Down

0 comments on commit 26dd456

Please sign in to comment.