Skip to content

Commit

Permalink
Include JS to do highlighting of code
Browse files Browse the repository at this point in the history
  • Loading branch information
Stan125 committed Oct 10, 2017
1 parent 5cf1d43 commit 423b82a
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 1 deletion.
10 changes: 9 additions & 1 deletion R/vis.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ vis <- function() {
## Assemble UI
ui <- fluidPage(

# Use CSS and ShinyJS for Code Highlighting
includeCSS("inst/srcjs/solarized-dark.css"),
includeScript("inst/srcjs/highlight.pack.js"),

# Title
titlePanel("Visualize your bamlss predictions"),

Expand Down Expand Up @@ -384,7 +388,11 @@ vis <- function() {
code <- paste(c_data, c_predictions, c_plot, sep = "\n")
showModal(modalDialog(
title = "Obtain your R code",
tags$pre(tags$code(code)), easyClose = TRUE
tags$pre(tags$code(code)),
HTML('<script>$("pre code").each(function(i, block) {
hljs.highlightBlock(block);
});</script>'),
easyClose = TRUE
))
})

Expand Down
2 changes: 2 additions & 0 deletions inst/srcjs/highlight.pack.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 84 additions & 0 deletions inst/srcjs/solarized-dark.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull <sourdrums@gmail.com>
*/

.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #002b36;
color: #839496;
}

.hljs-comment,
.hljs-quote {
color: #586e75;
}

/* Solarized Green */
.hljs-keyword,
.hljs-selector-tag,
.hljs-addition {
color: #859900;
}

/* Solarized Cyan */
.hljs-number,
.hljs-string,
.hljs-meta .hljs-meta-string,
.hljs-literal,
.hljs-doctag,
.hljs-regexp {
color: #2aa198;
}

/* Solarized Blue */
.hljs-title,
.hljs-section,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
color: #268bd2;
}

/* Solarized Yellow */
.hljs-attribute,
.hljs-attr,
.hljs-variable,
.hljs-template-variable,
.hljs-class .hljs-title,
.hljs-type {
color: #b58900;
}

/* Solarized Orange */
.hljs-symbol,
.hljs-bullet,
.hljs-subst,
.hljs-meta,
.hljs-meta .hljs-keyword,
.hljs-selector-attr,
.hljs-selector-pseudo,
.hljs-link {
color: #cb4b16;
}

/* Solarized Red */
.hljs-built_in,
.hljs-deletion {
color: #dc322f;
}

.hljs-formula {
background: #073642;
}

.hljs-emphasis {
font-style: italic;
}

.hljs-strong {
font-weight: bold;
}

0 comments on commit 423b82a

Please sign in to comment.