From 0cf1fdc8d59986e109e452bb67702a58d752dae6 Mon Sep 17 00:00:00 2001 From: John Coene Date: Fri, 27 Oct 2023 15:21:54 +0200 Subject: [PATCH 1/3] fix: style --- R/block.R | 196 +-- R/demo-block.R | 8 +- R/field.R | 35 +- R/layout.R | 4 +- R/server.R | 193 ++- R/stack.R | 2 +- R/ui.R | 12 +- R/utils.R | 25 +- inst/assets/index.js | 3239 ++++++++++++++++++++++++++++++++++- makefile | 5 +- test.R | 2 +- tests/testthat/test-block.R | 5 - tests/testthat/test-field.R | 4 - tests/testthat/test-stack.R | 1 - 14 files changed, 3475 insertions(+), 256 deletions(-) diff --git a/R/block.R b/R/block.R index 79cf4ab4..477177f7 100644 --- a/R/block.R +++ b/R/block.R @@ -140,10 +140,9 @@ evaluate_block.ggiraph_block <- evaluate_block.plot_block #' @param selected Selected dataset. #' @export new_data_block <- function( - ..., - dat = as.environment("package:blockr.data"), - selected = character() -) { + ..., + dat = as.environment("package:blockr.data"), + selected = character()) { is_dataset_eligible <- function(x) { inherits( get(x, envir = dat, inherits = FALSE), @@ -204,18 +203,14 @@ initialize_block.data_block <- function(x, ...) { #' @rdname new_block #' @export new_filter_block <- function( - data, - columns = colnames(data)[1L], - values = character(), - filter_fun = "==", - ... -) { - + data, + columns = colnames(data)[1L], + values = character(), + filter_fun = "==", + ...) { sub_fields <- function(data, columns) { - determine_field <- function(x) { - switch( - class(x), + switch(class(x), factor = select_field, numeric = range_field, string_field @@ -223,9 +218,7 @@ new_filter_block <- function( } field_args <- function(x) { - - switch( - class(x), + switch(class(x), factor = list(levels(x)[1L], choices = levels(x)), numeric = list(range(x), min = min(x), max = max(x)), list() @@ -242,15 +235,12 @@ new_filter_block <- function( filter_exps <- function(data, values, filter_func) { - filter_exp <- function(cls, col, val) { - if (is.null(val)) { return(quote(TRUE)) } - switch( - cls, + switch(cls, numeric = bquote( dplyr::between(.(column), ..(values)), list(column = as.name(col), values = val), @@ -343,12 +333,10 @@ new_select_block <- function(data, columns = colnames(data)[1], ...) { #' @rdname new_block #' @export new_summarize_block <- function( - data, - func = character(), - default_columns = character(), - ... -) { - + data, + func = character(), + default_columns = character(), + ...) { if (length(default_columns) > 0) { stopifnot(length(func) == length(default_columns)) } @@ -374,14 +362,22 @@ new_summarize_block <- function( summarize_expr <- function(data, funcs, columns) { # Build expressions that will go inside the summarize - if (length(funcs) == 0) return(quote(TRUE)) - if (length(columns) == 0) return(quote(TRUE)) + if (length(funcs) == 0) { + return(quote(TRUE)) + } + if (length(columns) == 0) { + return(quote(TRUE)) + } tmp_exprs <- lapply(funcs, function(fun) { col <- columns[[fun]] - if (is.null(col)) return(quote(TRUE)) - if (!any(col %in% colnames(data))) return(quote(TRUE)) + if (is.null(col)) { + return(quote(TRUE)) + } + if (!any(col %in% colnames(data))) { + return(quote(TRUE)) + } col <- as.name(col) expr <- if (fun == "se") { @@ -479,12 +475,11 @@ group_by_block <- function(data, ...) { #' to join #' @export new_join_block <- function( - data, - y = data(package = "blockr.data")$result[, "Item"], - type = character(), - by_col = character(), - ... -) { + data, + y = data(package = "blockr.data")$result[, "Item"], + type = character(), + by_col = character(), + ...) { # by depends on selected dataset and the input data. by_choices <- function(data, y) { choices <- intersect( @@ -566,7 +561,6 @@ join_block <- function(data, ...) { #' @param n_rows Number of rows to return. #' @export new_head_block <- function(data, n_rows = numeric(), ...) { - tmp_expr <- function(n_rows) { bquote( head(n = .(n_rows)), @@ -600,36 +594,35 @@ head_block <- function(data, ...) { #' @import ggplot2 #' @export new_plot_block <- function( - data, - plot_opts = list( - colors = c("blue", "red"), # when outside aes ... - point_size = 3, - title = "Plot title", - theme = c( - "theme_minimal", - "theme_gray", - "theme_linedraw", - "theme_dark", - "theme_light", - "theme_classic", - "theme_void", - "theme_bw" - ), - x_lab = "X axis label", - y_lab = "Y axis label", - errors = list( - show = FALSE, - ymin = character(), - ymax = character() + data, + plot_opts = list( + colors = c("blue", "red"), # when outside aes ... + point_size = 3, + title = "Plot title", + theme = c( + "theme_minimal", + "theme_gray", + "theme_linedraw", + "theme_dark", + "theme_light", + "theme_classic", + "theme_void", + "theme_bw" + ), + x_lab = "X axis label", + y_lab = "Y axis label", + errors = list( + show = FALSE, + ymin = character(), + ymax = character() + ), + lines = list( + show = FALSE, + group = character(), + color = character() + ) ), - lines = list( - show = FALSE, - group = character(), - color = character() - ) - ), - ... -) { + ...) { # For plot blocks, fields will create input to style the plot ... all_cols <- function(data) colnames(data) fields <- list( @@ -665,7 +658,7 @@ new_plot_block <- function( color = .data[[color]], shape = .data[[shape]] ), - size = 3 #.(point_size) TO DO: allow slide to have 1 value + size = 3 # .(point_size) TO DO: allow slide to have 1 value ) # Adding errors @@ -693,13 +686,13 @@ new_plot_block <- function( ) } - p + + p + labs( title = .(title), x = .(x_lab), y = .(y_lab) ) + - #theme_update(.(theme)) + + # theme_update(.(theme)) + theme( axis.text.x = element_text(angle = 45, hjust = 1), legend.title = element_text(face = "bold"), @@ -730,36 +723,35 @@ plot_block <- function(data, ...) { #' @import ggiraph #' @export new_ggiraph_block <- function( - data, - plot_opts = list( - colors = c("blue", "red"), # when outside aes ... - point_size = 3, - title = "Plot title", - theme = c( - "theme_minimal", - "theme_gray", - "theme_linedraw", - "theme_dark", - "theme_light", - "theme_classic", - "theme_void", - "theme_bw" - ), - x_lab = "X axis label", - y_lab = "Y axis label", - errors = list( - show = TRUE, - ymin = character(), - ymax = character() + data, + plot_opts = list( + colors = c("blue", "red"), # when outside aes ... + point_size = 3, + title = "Plot title", + theme = c( + "theme_minimal", + "theme_gray", + "theme_linedraw", + "theme_dark", + "theme_light", + "theme_classic", + "theme_void", + "theme_bw" + ), + x_lab = "X axis label", + y_lab = "Y axis label", + errors = list( + show = TRUE, + ymin = character(), + ymax = character() + ), + lines = list( + show = TRUE, + group = character(), + color = character() + ) ), - lines = list( - show = TRUE, - group = character(), - color = character() - ) - ), - ... -) { + ...) { # For plot blocks, fields will create input to style the plot ... all_cols <- function(data) colnames(data) fields <- list( @@ -791,7 +783,7 @@ new_ggiraph_block <- function( TOOLTIP_SE = sprintf( "x: %s\ny: %s\nmin: %s\nmax: %s", .data[[x_var]], .data[[y_var]], - ymin, ymax + ymin, ymax ) ) @@ -805,7 +797,7 @@ new_ggiraph_block <- function( shape = .data[[shape]], tooltip = TOOLTIP ), - size = 3 #.(point_size) TO DO: allow slide to have 1 value + size = 3 # .(point_size) TO DO: allow slide to have 1 value ) # Adding errors @@ -834,7 +826,7 @@ new_ggiraph_block <- function( ) } - p <- p + + p <- p + labs( title = .(title), x = .(x_lab), diff --git a/R/demo-block.R b/R/demo-block.R index 64bca555..5a0a08e7 100644 --- a/R/demo-block.R +++ b/R/demo-block.R @@ -38,12 +38,12 @@ cheat_block <- function(data, ...) { #' @param column Column to apply the operation on. #' @export new_asfactor_block <- function(data, column = "VISIT", ...) { - all_cols <- function(data) colnames(data) mutate_expr <- function(data, column) { - - if (is.null(column)) return(NULL) + if (is.null(column)) { + return(NULL) + } if (!(column %in% colnames(data))) { return(NULL) } @@ -166,4 +166,4 @@ demo_summarize_block <- function(data, ...) { ), data ) -} \ No newline at end of file +} diff --git a/R/field.R b/R/field.R index 5a77443d..7a271ab2 100644 --- a/R/field.R +++ b/R/field.R @@ -75,7 +75,6 @@ initialize_field.field <- function(x, env = list()) { } eval_set_field_value <- function(x, env) { - for (cmp in names(x)[lgl_ply(x, is.function)]) { fun <- x[[cmp]] tmp <- do.call(fun, env[methods::formalArgs(fun)]) @@ -138,9 +137,10 @@ validate_field.select_field <- function(x) { #' @export new_select_field <- function(value = character(), choices = character(), multiple = FALSE, ...) { - - new_field(value, choices = choices, multiple = multiple, ..., - class = "select_field") + new_field(value, + choices = choices, multiple = multiple, ..., + class = "select_field" + ) } #' @rdname new_field @@ -160,7 +160,6 @@ switch_field <- function(...) validate_field(new_switch_field(...)) #' @rdname new_field #' @export validate_field.switch_field <- function(x) { - val <- value(x) if (length(val) == 0) { @@ -172,12 +171,10 @@ validate_field.switch_field <- function(x) { #' @rdname new_field #' @export new_numeric_field <- function( - value = numeric(), - min = numeric(), - max = numeric(), - ... -) { - + value = numeric(), + min = numeric(), + max = numeric(), + ...) { new_field(value, min = min, max = max, ..., class = "numeric_field") } @@ -228,7 +225,6 @@ values <- function(x, name = names(x)) { #' @rdname new_field #' @export `value<-` <- function(x, name = "value", value) { - if (is.null(x)) { return(NULL) } @@ -250,9 +246,10 @@ values <- function(x, name = names(x)) { #' @export new_variable_field <- function(value = character(), field = character(), components = list(), ...) { - - new_field(value, field = field, components = components, ..., - class = "variable_field") + new_field(value, + field = field, components = components, ..., + class = "variable_field" + ) } #' @rdname new_field @@ -262,7 +259,6 @@ variable_field <- function(...) validate_field(new_variable_field(...)) #' @rdname new_field #' @export validate_field.variable_field <- function(x) { - val <- value(x, "field") opt <- c( "string_field", @@ -287,7 +283,6 @@ validate_field.variable_field <- function(x) { } materialize_variable_field <- function(x) { - cmp <- value(x, "components") val <- value(x) @@ -303,7 +298,6 @@ materialize_variable_field <- function(x) { #' @export new_range_field <- function(value = numeric(), min = numeric(), max = numeric(), ...) { - new_field(value, min = min, max = max, ..., class = "range_field") } @@ -314,7 +308,6 @@ range_field <- function(...) validate_field(new_range_field(...)) #' @rdname new_field #' @export validate_field.range_field <- function(x) { - val <- value(x) if (!is.numeric(val) || length(val) < 2L) { @@ -358,13 +351,11 @@ list_field <- function(...) validate_field(new_list_field(...)) #' @rdname new_field #' @export validate_field.list_field <- function(x) { - val <- value(x) sub <- value(x, "sub_fields") if (!is.list(val) || length(val) != length(sub) || - !setequal(names(val), names(sub))) { - + !setequal(names(val), names(sub))) { value(x) <- lst_xtr(sub, "value") } diff --git a/R/layout.R b/R/layout.R index 2b8e2c8f..7032c7e0 100644 --- a/R/layout.R +++ b/R/layout.R @@ -60,7 +60,7 @@ plot_layout_fields <- function(fields, ...) { ggiraph_layout_fields <- plot_layout_fields -filter_layout_fields <- function(fields, ...){ +filter_layout_fields <- function(fields, ...) { tagList( div( class = "row", @@ -98,7 +98,7 @@ summarize_layout_fields <- function(fields, ...) { ) } -join_layout_fields <- function(fields, ...){ +join_layout_fields <- function(fields, ...) { tagList( div( class = "row", diff --git a/R/server.R b/R/server.R index d4c52d25..e3f63a54 100644 --- a/R/server.R +++ b/R/server.R @@ -20,7 +20,6 @@ generate_server.block <- function(x, ...) { #' @rdname generate_server #' @export generate_server.data_block <- function(x, id, ...) { - obs_expr <- function(x) { splice_args( list(..(args)), @@ -56,22 +55,25 @@ generate_server.data_block <- function(x, id, ...) { # Cleanup module inputs (UI and server side) # and observer - observeEvent(input$remove, { - # Trick to be able to tell the stack to wait - # for this event to run. - session$userData$is_cleaned(FALSE) - # Can only remove when it is the last stack block - if (length(session$userData$stack) == 1) { - message(sprintf("CLEANING UP BLOCK %s", id)) - remove_shiny_inputs(id = id, input) - o$destroy() - session$userData$is_cleaned(TRUE) - } - # We have to set high priority so this event - # executes before the one in the stack which - # updates the stack. If we don't, this will - # never execute because the stack will be empty :) - }, priority = 500) + observeEvent(input$remove, + { + # Trick to be able to tell the stack to wait + # for this event to run. + session$userData$is_cleaned(FALSE) + # Can only remove when it is the last stack block + if (length(session$userData$stack) == 1) { + message(sprintf("CLEANING UP BLOCK %s", id)) + remove_shiny_inputs(id = id, input) + o$destroy() + session$userData$is_cleaned(TRUE) + } + # We have to set high priority so this event + # executes before the one in the stack which + # updates the stack. If we don't, this will + # never execute because the stack will be empty :) + }, + priority = 500 + ) out_dat } @@ -82,7 +84,6 @@ generate_server.data_block <- function(x, id, ...) { #' @rdname generate_server #' @export generate_server.transform_block <- function(x, in_dat, id, ...) { - obs_expr <- function(x) { splice_args( list(in_dat(), ..(args)), @@ -134,7 +135,6 @@ generate_server.transform_block <- function(x, in_dat, id, ...) { #' @rdname generate_server #' @export generate_server.plot_block <- function(x, in_dat, id, ...) { - obs_expr <- function(x) { splice_args( list(in_dat(), ..(args)), @@ -207,47 +207,50 @@ generate_server.stack <- function(x, id = NULL, new_blocks = NULL, ...) { vals$remove <- TRUE }) - observeEvent({ - req(new_blocks) - new_blocks() - }, { - # Update stack - block_to_add <- new_blocks()$block - position <- new_blocks()$position - - vals$stack <- add_block(vals$stack, block_to_add, position) - - # Call module - p <- if (is.null(position)) { - length(vals$stack) - } else { - position + 1 - } - vals$blocks[[p]] <- init_block(p, vals) - - # Insert UI - insertUI( - selector = sprintf( - "[data-value='%s-block']", - session$ns(attr(vals$stack[[p - 1]], "name")) - ), - where = "afterEnd", - generate_ui( - vals$stack[[p]], - id = session$ns(attr(vals$stack[[p]], "name")), - .hidden = FALSE + observeEvent( + { + req(new_blocks) + new_blocks() + }, + { + # Update stack + block_to_add <- new_blocks()$block + position <- new_blocks()$position + + vals$stack <- add_block(vals$stack, block_to_add, position) + + # Call module + p <- if (is.null(position)) { + length(vals$stack) + } else { + position + 1 + } + vals$blocks[[p]] <- init_block(p, vals) + + # Insert UI + insertUI( + selector = sprintf( + "[data-value='%s-block']", + session$ns(attr(vals$stack[[p - 1]], "name")) + ), + where = "afterEnd", + generate_ui( + vals$stack[[p]], + id = session$ns(attr(vals$stack[[p]], "name")), + .hidden = FALSE + ) ) - ) - # Necessary to communicate with downstream modules - session$userData$stack <- vals$stack + # Necessary to communicate with downstream modules + session$userData$stack <- vals$stack - # trigger javascript-ui functionalities on add - session$sendCustomMessage( - "blockr-add-block", - list(stack = session$ns(NULL)) - ) - }) + # trigger javascript-ui functionalities on add + session$sendCustomMessage( + "blockr-add-block", + list(stack = session$ns(NULL)) + ) + } + ) # Remove block from stack (can't be done within the block) to_remove <- reactive({ @@ -269,37 +272,40 @@ generate_server.stack <- function(x, id = NULL, new_blocks = NULL, ...) { session$userData$is_cleaned <- reactiveVal(FALSE) - observeEvent({ - c( - to_remove(), - session$userData$is_cleaned() - ) - }, { - # We can't remove the data block if there are downstream consumers... - if (to_remove() == 1 && length(vals$stack) > 1) { - showModal( - modalDialog( - title = h3(icon("xmark"), "Error"), - "Can't remove a datablock whenever there are - downstream data block consumers." - ) + observeEvent( + { + c( + to_remove(), + session$userData$is_cleaned() ) - } else { - if (session$userData$is_cleaned()) { - message(sprintf("REMOVING BLOCK %s", to_remove())) - removeUI( - selector = sprintf( - "[data-value='%s%s-block']", - session$ns(""), - attr(vals$stack[[to_remove()]], "name") + }, + { + # We can't remove the data block if there are downstream consumers... + if (to_remove() == 1 && length(vals$stack) > 1) { + showModal( + modalDialog( + title = h3(icon("xmark"), "Error"), + "Can't remove a datablock whenever there are + downstream data block consumers." ) ) - vals$stack[[to_remove()]] <- NULL - session$userData$stack <- vals$stack - session$userData$is_cleaned(FALSE) + } else { + if (session$userData$is_cleaned()) { + message(sprintf("REMOVING BLOCK %s", to_remove())) + removeUI( + selector = sprintf( + "[data-value='%s%s-block']", + session$ns(""), + attr(vals$stack[[to_remove()]], "name") + ) + ) + vals$stack[[to_remove()]] <- NULL + session$userData$stack <- vals$stack + session$userData$is_cleaned(FALSE) + } } } - }) + ) observe({ session$sendCustomMessage( @@ -368,16 +374,19 @@ server_output <- function(x, result, output) { #' @rdname generate_ui #' @export server_output.block <- function(x, result, output) { - DT::renderDT({ - result() |> - DT::datatable( - selection = "none", - options = list( - pageLength = 5L, - processing = FALSE + DT::renderDT( + { + result() |> + DT::datatable( + selection = "none", + options = list( + pageLength = 5L, + processing = FALSE + ) ) - ) - }, server = TRUE) + }, + server = TRUE + ) } #' @rdname generate_ui diff --git a/R/stack.R b/R/stack.R index 580fedb1..382c4b69 100644 --- a/R/stack.R +++ b/R/stack.R @@ -67,7 +67,7 @@ add_block <- function(stack, block, position = NULL) { # get data from the previous block if (length(stack) == 1) { - data <- evaluate_block(stack[[position]]) + data <- evaluate_block(stack[[position]]) } else { data <- evaluate_block(stack[[1]]) for (i in seq_along(stack)[-1L]) { diff --git a/R/ui.R b/R/ui.R index 14963048..25042615 100644 --- a/R/ui.R +++ b/R/ui.R @@ -32,12 +32,14 @@ generate_ui.block <- function(x, id, ..., .hidden = TRUE) { header <- block_title(x, code_id, output_id, ns) block_class <- "block" - if (.hidden) + if (.hidden) { block_class <- sprintf("%s d-none", block_class) + } inputs_hidden <- "" - if (.hidden) + if (.hidden) { inputs_hidden <- "d-none" + } layout <- attr(x, "layout") @@ -254,7 +256,7 @@ ui_input.switch_field <- function(x, id, name) { #' @export ui_input.numeric_field <- function(x, id, name) { numericInput( - input_ids(x, id), name, value(x), value(x, "min"), value(x, "max") + input_ids(x, id), name, value(x), value(x, "min"), value(x, "max") ) } @@ -286,7 +288,6 @@ input_ids.list_field <- function(x, name, ...) { #' @rdname generate_ui #' @export ui_input.variable_field <- function(x, id, name) { - field <- validate_field( materialize_variable_field(x) ) @@ -314,7 +315,6 @@ ui_input.hidden_field <- function(x, id, name) { #' @rdname generate_ui #' @export ui_input.list_field <- function(x, id, name) { - fields <- lapply( update_sub_fields(value(x, "sub_fields"), value(x)), validate_field @@ -361,7 +361,6 @@ ui_update.switch_field <- function(x, session, id, name) { #' @rdname generate_ui #' @export ui_update.variable_field <- function(x, session, id, name) { - ns <- session$ns ns_id <- ns(id) @@ -406,7 +405,6 @@ ui_update.hidden_field <- function(x, session, id, name) { #' @rdname generate_ui #' @export ui_update.list_field <- function(x, session, id, name) { - ns <- session$ns ns_id <- ns(id) diff --git a/R/utils.R b/R/utils.R index bd6412f5..667d4840 100644 --- a/R/utils.R +++ b/R/utils.R @@ -114,7 +114,6 @@ quoted_input_entry <- function(x) { } quoted_input_entries <- function(x) { - if (length(x) == 1L && is.null(names(x))) { return(quoted_input_entry(x)) } @@ -143,7 +142,6 @@ type_trans <- function(x) { } is_truthy <- function(x) { - if (inherits(x, "try-error")) { FALSE } else if (!is.atomic(x)) { @@ -206,12 +204,10 @@ convert_block <- function(from = new_select_block, to, data, ...) { #' #' @keywords internal off_canvas <- function( - id, - title, - ..., - position = c("start", "top", "bottom", "end") -) { - + id, + title, + ..., + position = c("start", "top", "bottom", "end")) { position <- match.arg(position) label <- rand_names() @@ -266,9 +262,12 @@ create_modal <- function(...) { #' #' @keywords internal secure <- function(expr) { - tryCatch({ - expr - }, error = function(e) { - create_modal(e$message) - }) + tryCatch( + { + expr + }, + error = function(e) { + create_modal(e$message) + } + ) } diff --git a/inst/assets/index.js b/inst/assets/index.js index 3ec42ebf..0773b248 100644 --- a/inst/assets/index.js +++ b/inst/assets/index.js @@ -1 +1,3238 @@ -(()=>{var e={390:e=>{function n(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach((t=>{const i=e[t],s=typeof i;"object"!==s&&"function"!==s||Object.isFrozen(i)||n(i)})),e}class t{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function i(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function s(e,...n){const t=Object.create(null);for(const n in e)t[n]=e[n];return n.forEach((function(e){for(const n in e)t[n]=e[n]})),t}const o=e=>!!e.scope;class r{constructor(e,n){this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!o(e))return;const n=((e,{prefix:n})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const t=e.split(".");return[`${n}${t.shift()}`,...t.map(((e,n)=>`${e}${"_".repeat(n+1)}`))].join(" ")}return`${n}${e}`})(e.scope,{prefix:this.classPrefix});this.span(n)}closeNode(e){o(e)&&(this.buffer+="")}value(){return this.buffer}span(e){this.buffer+=``}}const a=(e={})=>{const n={children:[]};return Object.assign(n,e),n};class c{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const n=a({scope:e});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){return"string"==typeof n?e.addText(n):n.children&&(e.openNode(n),n.children.forEach((n=>this._walk(e,n))),e.closeNode(n)),e}static _collapse(e){"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{c._collapse(e)})))}}class l extends c{constructor(e){super(),this.options=e}addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,n){const t=e.root;n&&(t.scope=`language:${n}`),this.add(t)}toHTML(){return new r(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function g(e){return e?"string"==typeof e?e:e.source:null}function u(e){return f("(?=",e,")")}function d(e){return f("(?:",e,")*")}function h(e){return f("(?:",e,")?")}function f(...e){return e.map((e=>g(e))).join("")}function p(...e){const n=function(e){const n=e[e.length-1];return"object"==typeof n&&n.constructor===Object?(e.splice(e.length-1,1),n):{}}(e);return"("+(n.capture?"":"?:")+e.map((e=>g(e))).join("|")+")"}function b(e){return new RegExp(e.toString()+"|").exec("").length-1}const m=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function E(e,{joinWith:n}){let t=0;return e.map((e=>{t+=1;const n=t;let i=g(e),s="";for(;i.length>0;){const e=m.exec(i);if(!e){s+=i;break}s+=i.substring(0,e.index),i=i.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?s+="\\"+String(Number(e[1])+n):(s+=e[0],"("===e[0]&&t++)}return s})).map((e=>`(${e})`)).join(n)}const x="[a-zA-Z]\\w*",_="[a-zA-Z_]\\w*",w="\\b\\d+(\\.\\d+)?",y="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",v="\\b(0b[01]+)",k={begin:"\\\\[\\s\\S]",relevance:0},A={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[k]},N={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[k]},S=function(e,n,t={}){const i=s({scope:"comment",begin:e,end:n,contains:[]},t);i.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const o=p("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return i.contains.push({begin:f(/[ ]+/,"(",o,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),i},M=S("//","$"),O=S("/\\*","\\*/"),R=S("#","$"),T={scope:"number",begin:w,relevance:0},I={scope:"number",begin:y,relevance:0},j={scope:"number",begin:v,relevance:0},$={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[k,{begin:/\[/,end:/\]/,relevance:0,contains:[k]}]},L={scope:"title",begin:x,relevance:0},B={scope:"title",begin:_,relevance:0},C={begin:"\\.\\s*"+_,relevance:0};var D=Object.freeze({__proto__:null,APOS_STRING_MODE:A,BACKSLASH_ESCAPE:k,BINARY_NUMBER_MODE:j,BINARY_NUMBER_RE:v,COMMENT:S,C_BLOCK_COMMENT_MODE:O,C_LINE_COMMENT_MODE:M,C_NUMBER_MODE:I,C_NUMBER_RE:y,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,n)=>{n.data._beginMatch=e[1]},"on:end":(e,n)=>{n.data._beginMatch!==e[1]&&n.ignoreMatch()}})},HASH_COMMENT_MODE:R,IDENT_RE:x,MATCH_NOTHING_RE:/\b\B/,METHOD_GUARD:C,NUMBER_MODE:T,NUMBER_RE:w,PHRASAL_WORDS_MODE:{begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},QUOTE_STRING_MODE:N,REGEXP_MODE:$,RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{const n=/^#![ ]*\//;return e.binary&&(e.begin=f(n,/.*\b/,e.binary,/\b.*/)),s({scope:"meta",begin:n,end:/$/,relevance:0,"on:begin":(e,n)=>{0!==e.index&&n.ignoreMatch()}},e)},TITLE_MODE:L,UNDERSCORE_IDENT_RE:_,UNDERSCORE_TITLE_MODE:B});function H(e,n){"."===e.input[e.index-1]&&n.ignoreMatch()}function P(e,n){void 0!==e.className&&(e.scope=e.className,delete e.className)}function z(e,n){n&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=H,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,void 0===e.relevance&&(e.relevance=0))}function U(e,n){Array.isArray(e.illegal)&&(e.illegal=p(...e.illegal))}function G(e,n){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function Z(e,n){void 0===e.relevance&&(e.relevance=1)}const F=(e,n)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const t=Object.assign({},e);Object.keys(e).forEach((n=>{delete e[n]})),e.keywords=t.keywords,e.begin=f(t.beforeMatch,u(t.begin)),e.starts={relevance:0,contains:[Object.assign(t,{endsParent:!0})]},e.relevance=0,delete t.beforeMatch},W=["of","and","for","in","not","or","if","then","parent","list","value"],X="keyword";function K(e,n,t=X){const i=Object.create(null);return"string"==typeof e?s(t,e.split(" ")):Array.isArray(e)?s(t,e):Object.keys(e).forEach((function(t){Object.assign(i,K(e[t],n,t))})),i;function s(e,t){n&&(t=t.map((e=>e.toLowerCase()))),t.forEach((function(n){const t=n.split("|");i[t[0]]=[e,q(t[0],t[1])]}))}}function q(e,n){return n?Number(n):function(e){return W.includes(e.toLowerCase())}(e)?0:1}const V={},J=e=>{console.error(e)},Y=(e,...n)=>{console.log(`WARN: ${e}`,...n)},Q=(e,n)=>{V[`${e}/${n}`]||(console.log(`Deprecated as of ${e}. ${n}`),V[`${e}/${n}`]=!0)},ee=new Error;function ne(e,n,{key:t}){let i=0;const s=e[t],o={},r={};for(let e=1;e<=n.length;e++)r[e+i]=s[e],o[e+i]=!0,i+=b(n[e-1]);e[t]=r,e[t]._emit=o,e[t]._multi=!0}function te(e){!function(e){e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,delete e.scope)}(e),"string"==typeof e.beginScope&&(e.beginScope={_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope}),function(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw J("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ee;if("object"!=typeof e.beginScope||null===e.beginScope)throw J("beginScope must be object"),ee;ne(e,e.begin,{key:"beginScope"}),e.begin=E(e.begin,{joinWith:""})}}(e),function(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw J("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ee;if("object"!=typeof e.endScope||null===e.endScope)throw J("endScope must be object"),ee;ne(e,e.end,{key:"endScope"}),e.end=E(e.end,{joinWith:""})}}(e)}function ie(e){function n(n,t){return new RegExp(g(n),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(t?"g":""))}class t{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,n){n.position=this.position++,this.matchIndexes[this.matchAt]=n,this.regexes.push([n,e]),this.matchAt+=b(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);const e=this.regexes.map((e=>e[1]));this.matcherRe=n(E(e,{joinWith:"|"}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;const n=this.matcherRe.exec(e);if(!n)return null;const t=n.findIndex(((e,n)=>n>0&&void 0!==e)),i=this.matchIndexes[t];return n.splice(0,t),Object.assign(n,i)}}class i{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];const n=new t;return this.rules.slice(e).forEach((([e,t])=>n.addRule(e,t))),n.compile(),this.multiRegexes[e]=n,n}resumingScanAtSamePosition(){return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,n){this.rules.push([e,n]),"begin"===n.type&&this.count++}exec(e){const n=this.getMatcher(this.regexIndex);n.lastIndex=this.lastIndex;let t=n.exec(e);if(this.resumingScanAtSamePosition())if(t&&t.index===this.lastIndex);else{const n=this.getMatcher(0);n.lastIndex=this.lastIndex+1,t=n.exec(e)}return t&&(this.regexIndex+=t.position+1,this.regexIndex===this.count&&this.considerAll()),t}}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=s(e.classNameAliases||{}),function t(o,r){const a=o;if(o.isCompiled)return a;[P,G,te,F].forEach((e=>e(o,r))),e.compilerExtensions.forEach((e=>e(o,r))),o.__beforeBegin=null,[z,U,Z].forEach((e=>e(o,r))),o.isCompiled=!0;let c=null;return"object"==typeof o.keywords&&o.keywords.$pattern&&(o.keywords=Object.assign({},o.keywords),c=o.keywords.$pattern,delete o.keywords.$pattern),c=c||/\w+/,o.keywords&&(o.keywords=K(o.keywords,e.case_insensitive)),a.keywordPatternRe=n(c,!0),r&&(o.begin||(o.begin=/\B|\b/),a.beginRe=n(a.begin),o.end||o.endsWithParent||(o.end=/\B|\b/),o.end&&(a.endRe=n(a.end)),a.terminatorEnd=g(a.end)||"",o.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(o.end?"|":"")+r.terminatorEnd)),o.illegal&&(a.illegalRe=n(o.illegal)),o.contains||(o.contains=[]),o.contains=[].concat(...o.contains.map((function(e){return function(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((function(n){return s(e,{variants:null},n)}))),e.cachedVariants?e.cachedVariants:se(e)?s(e,{starts:e.starts?s(e.starts):null}):Object.isFrozen(e)?s(e):e}("self"===e?o:e)}))),o.contains.forEach((function(e){t(e,a)})),o.starts&&t(o.starts,r),a.matcher=function(e){const n=new i;return e.contains.forEach((e=>n.addRule(e.begin,{rule:e,type:"begin"}))),e.terminatorEnd&&n.addRule(e.terminatorEnd,{type:"end"}),e.illegal&&n.addRule(e.illegal,{type:"illegal"}),n}(a),a}(e)}function se(e){return!!e&&(e.endsWithParent||se(e.starts))}class oe extends Error{constructor(e,n){super(e),this.name="HTMLInjectionError",this.html=n}}const re=i,ae=s,ce=Symbol("nomatch"),le=function(e){const i=Object.create(null),s=Object.create(null),o=[];let r=!0;const a="Could not find the language '{}', did you forget to load/include a language module?",c={disableAutodetect:!0,name:"Plain text",contains:[]};let g={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:l};function b(e){return g.noHighlightRe.test(e)}function m(e,n,t){let i="",s="";"object"==typeof n?(i=e,t=n.ignoreIllegals,s=n.language):(Q("10.7.0","highlight(lang, code, ...args) has been deprecated."),Q("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),s=e,i=n),void 0===t&&(t=!0);const o={code:i,language:s};N("before:highlight",o);const r=o.result?o.result:E(o.language,o.code,t);return r.code=o.code,N("after:highlight",r),r}function E(e,n,s,o){const c=Object.create(null);function l(){if(!N.keywords)return void M.addText(O);let e=0;N.keywordPatternRe.lastIndex=0;let n=N.keywordPatternRe.exec(O),t="";for(;n;){t+=O.substring(e,n.index);const s=y.case_insensitive?n[0].toLowerCase():n[0],o=(i=s,N.keywords[i]);if(o){const[e,i]=o;if(M.addText(t),t="",c[s]=(c[s]||0)+1,c[s]<=7&&(R+=i),e.startsWith("_"))t+=n[0];else{const t=y.classNameAliases[e]||e;d(n[0],t)}}else t+=n[0];e=N.keywordPatternRe.lastIndex,n=N.keywordPatternRe.exec(O)}var i;t+=O.substring(e),M.addText(t)}function u(){null!=N.subLanguage?function(){if(""===O)return;let e=null;if("string"==typeof N.subLanguage){if(!i[N.subLanguage])return void M.addText(O);e=E(N.subLanguage,O,!0,S[N.subLanguage]),S[N.subLanguage]=e._top}else e=x(O,N.subLanguage.length?N.subLanguage:null);N.relevance>0&&(R+=e.relevance),M.__addSublanguage(e._emitter,e.language)}():l(),O=""}function d(e,n){""!==e&&(M.startScope(n),M.addText(e),M.endScope())}function h(e,n){let t=1;const i=n.length-1;for(;t<=i;){if(!e._emit[t]){t++;continue}const i=y.classNameAliases[e[t]]||e[t],s=n[t];i?d(s,i):(O=s,l(),O=""),t++}}function f(e,n){return e.scope&&"string"==typeof e.scope&&M.openNode(y.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(d(O,y.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),O=""):e.beginScope._multi&&(h(e.beginScope,n),O="")),N=Object.create(e,{parent:{value:N}}),N}function p(e,n,i){let s=function(e,n){const t=e&&e.exec(n);return t&&0===t.index}(e.endRe,i);if(s){if(e["on:end"]){const i=new t(e);e["on:end"](n,i),i.isMatchIgnored&&(s=!1)}if(s){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return p(e.parent,n,i)}function b(e){return 0===N.matcher.regexIndex?(O+=e[0],1):(j=!0,0)}function m(e){const t=e[0],i=n.substring(e.index),s=p(N,e,i);if(!s)return ce;const o=N;N.endScope&&N.endScope._wrap?(u(),d(t,N.endScope._wrap)):N.endScope&&N.endScope._multi?(u(),h(N.endScope,e)):o.skip?O+=t:(o.returnEnd||o.excludeEnd||(O+=t),u(),o.excludeEnd&&(O=t));do{N.scope&&M.closeNode(),N.skip||N.subLanguage||(R+=N.relevance),N=N.parent}while(N!==s.parent);return s.starts&&f(s.starts,e),o.returnEnd?0:t.length}let _={};function w(i,o){const a=o&&o[0];if(O+=i,null==a)return u(),0;if("begin"===_.type&&"end"===o.type&&_.index===o.index&&""===a){if(O+=n.slice(o.index,o.index+1),!r){const n=new Error(`0 width match regex (${e})`);throw n.languageName=e,n.badRule=_.rule,n}return 1}if(_=o,"begin"===o.type)return function(e){const n=e[0],i=e.rule,s=new t(i),o=[i.__beforeBegin,i["on:begin"]];for(const t of o)if(t&&(t(e,s),s.isMatchIgnored))return b(n);return i.skip?O+=n:(i.excludeBegin&&(O+=n),u(),i.returnBegin||i.excludeBegin||(O=n)),f(i,e),i.returnBegin?0:n.length}(o);if("illegal"===o.type&&!s){const e=new Error('Illegal lexeme "'+a+'" for mode "'+(N.scope||"")+'"');throw e.mode=N,e}if("end"===o.type){const e=m(o);if(e!==ce)return e}if("illegal"===o.type&&""===a)return 1;if(I>1e5&&I>3*o.index)throw new Error("potential infinite loop, way more iterations than matches");return O+=a,a.length}const y=v(e);if(!y)throw J(a.replace("{}",e)),new Error('Unknown language: "'+e+'"');const k=ie(y);let A="",N=o||k;const S={},M=new g.__emitter(g);!function(){const e=[];for(let n=N;n!==y;n=n.parent)n.scope&&e.unshift(n.scope);e.forEach((e=>M.openNode(e)))}();let O="",R=0,T=0,I=0,j=!1;try{if(y.__emitTokens)y.__emitTokens(n,M);else{for(N.matcher.considerAll();;){I++,j?j=!1:N.matcher.considerAll(),N.matcher.lastIndex=T;const e=N.matcher.exec(n);if(!e)break;const t=w(n.substring(T,e.index),e);T=e.index+t}w(n.substring(T))}return M.finalize(),A=M.toHTML(),{language:e,value:A,relevance:R,illegal:!1,_emitter:M,_top:N}}catch(t){if(t.message&&t.message.includes("Illegal"))return{language:e,value:re(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:T,context:n.slice(T-100,T+100),mode:t.mode,resultSoFar:A},_emitter:M};if(r)return{language:e,value:re(n),illegal:!1,relevance:0,errorRaised:t,_emitter:M,_top:N};throw t}}function x(e,n){n=n||g.languages||Object.keys(i);const t=function(e){const n={value:re(e),illegal:!1,relevance:0,_top:c,_emitter:new g.__emitter(g)};return n._emitter.addText(e),n}(e),s=n.filter(v).filter(A).map((n=>E(n,e,!1)));s.unshift(t);const o=s.sort(((e,n)=>{if(e.relevance!==n.relevance)return n.relevance-e.relevance;if(e.language&&n.language){if(v(e.language).supersetOf===n.language)return 1;if(v(n.language).supersetOf===e.language)return-1}return 0})),[r,a]=o,l=r;return l.secondBest=a,l}function _(e){let n=null;const t=function(e){let n=e.className+" ";n+=e.parentNode?e.parentNode.className:"";const t=g.languageDetectRe.exec(n);if(t){const n=v(t[1]);return n||(Y(a.replace("{}",t[1])),Y("Falling back to no-highlight mode for this block.",e)),n?t[1]:"no-highlight"}return n.split(/\s+/).find((e=>b(e)||v(e)))}(e);if(b(t))return;if(N("before:highlightElement",{el:e,language:t}),e.dataset.highlighted)return void console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);if(e.children.length>0&&(g.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(e)),g.throwUnescapedHTML))throw new oe("One of your code blocks includes unescaped HTML.",e.innerHTML);n=e;const i=n.textContent,o=t?m(i,{language:t,ignoreIllegals:!0}):x(i);e.innerHTML=o.value,e.dataset.highlighted="yes",function(e,n,t){const i=n&&s[n]||t;e.classList.add("hljs"),e.classList.add(`language-${i}`)}(e,t,o.language),e.result={language:o.language,re:o.relevance,relevance:o.relevance},o.secondBest&&(e.secondBest={language:o.secondBest.language,relevance:o.secondBest.relevance}),N("after:highlightElement",{el:e,result:o,text:i})}let w=!1;function y(){"loading"!==document.readyState?document.querySelectorAll(g.cssSelector).forEach(_):w=!0}function v(e){return e=(e||"").toLowerCase(),i[e]||i[s[e]]}function k(e,{languageName:n}){"string"==typeof e&&(e=[e]),e.forEach((e=>{s[e.toLowerCase()]=n}))}function A(e){const n=v(e);return n&&!n.disableAutodetect}function N(e,n){const t=e;o.forEach((function(e){e[t]&&e[t](n)}))}"undefined"!=typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",(function(){w&&y()}),!1),Object.assign(e,{highlight:m,highlightAuto:x,highlightAll:y,highlightElement:_,highlightBlock:function(e){return Q("10.7.0","highlightBlock will be removed entirely in v12.0"),Q("10.7.0","Please use highlightElement now."),_(e)},configure:function(e){g=ae(g,e)},initHighlighting:()=>{y(),Q("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")},initHighlightingOnLoad:function(){y(),Q("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")},registerLanguage:function(n,t){let s=null;try{s=t(e)}catch(e){if(J("Language definition for '{}' could not be registered.".replace("{}",n)),!r)throw e;J(e),s=c}s.name||(s.name=n),i[n]=s,s.rawDefinition=t.bind(null,e),s.aliases&&k(s.aliases,{languageName:n})},unregisterLanguage:function(e){delete i[e];for(const n of Object.keys(s))s[n]===e&&delete s[n]},listLanguages:function(){return Object.keys(i)},getLanguage:v,registerAliases:k,autoDetection:A,inherit:ae,addPlugin:function(e){!function(e){e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=n=>{e["before:highlightBlock"](Object.assign({block:n.el},n))}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=n=>{e["after:highlightBlock"](Object.assign({block:n.el},n))})}(e),o.push(e)},removePlugin:function(e){const n=o.indexOf(e);-1!==n&&o.splice(n,1)}}),e.debugMode=function(){r=!1},e.safeMode=function(){r=!0},e.versionString="11.9.0",e.regex={concat:f,lookahead:u,either:p,optional:h,anyNumberOfTimes:d};for(const e in D)"object"==typeof D[e]&&n(D[e]);return Object.assign(e,D),e},ge=le({});ge.newInstance=()=>le({}),e.exports=ge,ge.HighlightJS=ge,ge.default=ge}},n={};function t(i){var s=n[i];if(void 0!==s)return s.exports;var o=n[i]={exports:{}};return e[i](o,o.exports,t),o.exports}(()=>{"use strict";Shiny;const e=t(390);e.registerLanguage("r",(function(e){const n=e.regex,t=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,i=n.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),s=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,o=n.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:t,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:n.lookahead(n.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:t},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[s,i]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,i]},{scope:{1:"punctuation",2:"number"},match:[o,i]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,i]}]},{scope:{3:"operator"},match:[t,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:s},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:o},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}})),$((()=>{$(document).on("shiny:value",(n=>{n.name.match(/-code$/)&&($(`#${n.name}`).addClass("language-r"),setTimeout((()=>{e.highlightElement(document.getElementById(n.name))}),250))}))}));const n=e=>{const n=$(e).find(".block").last();n.removeClass("d-none");const t=n.find(".block-output");bootstrap.Collapse.getOrCreateInstance(t,{toggle:!1}).show(),$(t).trigger("shown")},i=()=>{$(".block-copy-code").each(((e,n)=>{$(n).off("click"),$(n).on("click",(e=>{var n;n=$(e.target).closest("div").find("pre"),navigator.clipboard.writeText($(n).text())}))})),$(".stack-copy-code").each(((e,n)=>{$(n).off("click"),$(n).on("click",(e=>{const n=$(e.target).closest(".stack").find("pre");let t=[];n.each(((e,n)=>{t.push($(n).text())})),t=t.join(" |>\n"),navigator.clipboard.writeText(t)}))}))};Shiny.addCustomMessageHandler("blockr-bind-stack",(e=>{const t=`#${e.stack}`;setTimeout((()=>{(e=>{$(e).find(".stack-remove").each(((e,n)=>{"true"!=n.getAttribute("listener")&&$(n).on("click",(e=>{const n=$(e.target).closest(".stack"),t=n.closest(".masonry-item");n.remove(),0!==t.length&&t.remove()}))}))})(t),(e=>{(e=>{const n=$(e).find(".stack-edit-toggle");n[0].getAttribute("listener")||$(n).on("click",(e=>{const n=$(e.target).closest(".stack").find(".block");$(e.currentTarget).toggleClass("etidable");const t=$(e.currentTarget).hasClass("etidable");n.each(((e,i)=>{const s=$(i);return t?(s.removeClass("d-none"),s.find(".block-inputs").removeClass("d-none"),s.find(".block-inputs").trigger("shown"),void(e==n.length-1&&(s.find(".block-output").addClass("show"),s.find(".block-output").removeClass("d-none"),s.find(".block-output").trigger("shown")))):(s.find(".block-inputs").addClass("d-none"),s.find(".block-inputs").trigger("hidden"),e==n.length-1?(s.removeClass("d-none"),s.find(".block-output").addClass("show"),s.find(".block-output").removeClass("d-none"),void s.find(".block-output").trigger("shown")):void s.addClass("d-none"))}))}))})(e),(e=>{$(e).each(((e,t)=>{n(t)}))})(e)})(t),i()}),750)})),Shiny.addCustomMessageHandler("blockr-add-block",(e=>{const t=`#${e.stack}`;setTimeout((()=>{n(t),i()}),500)}))})()})(); \ No newline at end of file +/******/ (() => { // webpackBootstrap +/******/ var __webpack_modules__ = ({ + +/***/ "./srcjs/collapse.js": +/*!***************************!*\ + !*** ./srcjs/collapse.js ***! + \***************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ collapse: () => (/* binding */ collapse), +/* harmony export */ showLastOutput: () => (/* binding */ showLastOutput) +/* harmony export */ }); +const collapse = (stack) => { + editor(stack); + showLastOutputs(stack); +}; + +const editor = (stack) => { + const editBtn = $(stack).find(".stack-edit-toggle"); + + // already has a listener + if (editBtn[0].getAttribute("listener")) { + return; + } + + $(editBtn).on("click", (event) => { + const $stack = $(event.target).closest(".stack"); + const $blocks = $stack.find(".block"); + + $(event.currentTarget).toggleClass("etidable"); + const editable = $(event.currentTarget).hasClass("etidable"); + + $blocks.each((index, block) => { + const $block = $(block); + + if (editable) { + $block.removeClass("d-none"); + $block.find(".block-inputs").removeClass("d-none"); + $block.find(".block-inputs").trigger("shown"); + + if (index == ($blocks.length - 1)) { + $block.find(".block-output").addClass("show"); + $block.find(".block-output").removeClass("d-none"); + $block.find(".block-output").trigger("shown"); + } + return; + } + + $block.find(".block-inputs").addClass("d-none"); + $block.find(".block-inputs").trigger("hidden"); + + if (index == ($blocks.length - 1)) { + $block.removeClass("d-none"); + + $block.find(".block-output").addClass("show"); + $block.find(".block-output").removeClass("d-none"); + $block.find(".block-output").trigger("shown"); + return; + } + + $block.addClass("d-none"); + }); + }); +}; + +const showLastOutput = (el) => { + const $block = $(el).find(".block").last(); + + $block.removeClass("d-none"); + const lastOutput = $block.find(".block-output"); + + bootstrap.Collapse.getOrCreateInstance(lastOutput, { toggle: false }).show(); + $(lastOutput).trigger("shown"); +}; + +const showLastOutputs = (stack) => { + $(stack).each((_, el) => { + showLastOutput(el); + }); +}; + + +/***/ }), + +/***/ "./srcjs/copy.js": +/*!***********************!*\ + !*** ./srcjs/copy.js ***! + \***********************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ copyCode: () => (/* binding */ copyCode) +/* harmony export */ }); +const copy = (el) => { + navigator.clipboard.writeText($(el).text()); +}; + +const copyCode = () => { + $(".block-copy-code").each((_index, btn) => { + // TODO bind selectively instead of reset + $(btn).off("click"); + + $(btn).on("click", (event) => { + const code = $(event.target).closest("div").find("pre"); + copy(code); + }); + }); + + $(".stack-copy-code").each((_index, btn) => { + // TODO bind selectively instead of reset + $(btn).off("click"); + + $(btn).on("click", (event) => { + const $codes = $(event.target).closest(".stack").find("pre"); + let code = []; + $codes.each((_index, c) => { + code.push($(c).text()); + }); + code = code.join(" |>\n"); + navigator.clipboard.writeText(code); + }); + }); +}; + + +/***/ }), + +/***/ "./srcjs/hl.js": +/*!*********************!*\ + !*** ./srcjs/hl.js ***! + \*********************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var highlight_js_lib_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! highlight.js/lib/core */ "./node_modules/highlight.js/es/core.js"); +/* harmony import */ var highlight_js_lib_languages_r__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! highlight.js/lib/languages/r */ "./node_modules/highlight.js/es/languages/r.js"); + + + +highlight_js_lib_core__WEBPACK_IMPORTED_MODULE_0__["default"].registerLanguage("r", highlight_js_lib_languages_r__WEBPACK_IMPORTED_MODULE_1__["default"]); + +$(() => { + $(document).on("shiny:value", (e) => { + if (!e.name.match(/-code$/)) { + return; + } + + $(`#${e.name}`).addClass("language-r"); + setTimeout(() => { + highlight_js_lib_core__WEBPACK_IMPORTED_MODULE_0__["default"].highlightElement(document.getElementById(e.name)); + }, 250); + }); +}); + + +/***/ }), + +/***/ "./srcjs/remove-stack.js": +/*!*******************************!*\ + !*** ./srcjs/remove-stack.js ***! + \*******************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ remove: () => (/* binding */ remove) +/* harmony export */ }); +const remove = (stack) => { + $(stack).find(".stack-remove").each((_, btn) => { + // already has a listener + if (btn.getAttribute("listener") == "true") { + return; + } + + $(btn).on("click", (event) => { + const $stack = $(event.target).closest(".stack"); + const $masonry = $stack.closest(".masonry-item"); + + $stack.remove(); + + if ($masonry.length === 0) { + return; + } + + $masonry.remove(); + }); + }); +}; + + +/***/ }), + +/***/ "./srcjs/shiny.js": +/*!************************!*\ + !*** ./srcjs/shiny.js ***! + \************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _collapse_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collapse.js */ "./srcjs/collapse.js"); +/* harmony import */ var _remove_stack_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./remove-stack.js */ "./srcjs/remove-stack.js"); +/* harmony import */ var _copy_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./copy.js */ "./srcjs/copy.js"); + + + + +Shiny.addCustomMessageHandler("blockr-bind-stack", (msg) => { + const stack = `#${msg.stack}`; + setTimeout(() => { + (0,_remove_stack_js__WEBPACK_IMPORTED_MODULE_1__.remove)(stack); + (0,_collapse_js__WEBPACK_IMPORTED_MODULE_0__.collapse)(stack); + (0,_copy_js__WEBPACK_IMPORTED_MODULE_2__.copyCode)(); + }, 750); +}); + +Shiny.addCustomMessageHandler("blockr-add-block", (msg) => { + const stack = `#${msg.stack}`; + // TODO remove this + // be event based/async instead of timeout + setTimeout(() => { + (0,_collapse_js__WEBPACK_IMPORTED_MODULE_0__.showLastOutput)(stack); + (0,_copy_js__WEBPACK_IMPORTED_MODULE_2__.copyCode)(); + }, 500); +}); + + +/***/ }), + +/***/ "shiny": +/*!************************!*\ + !*** external "Shiny" ***! + \************************/ +/***/ ((module) => { + +"use strict"; +module.exports = Shiny; + +/***/ }), + +/***/ "./node_modules/highlight.js/lib/core.js": +/*!***********************************************!*\ + !*** ./node_modules/highlight.js/lib/core.js ***! + \***********************************************/ +/***/ ((module) => { + +/* eslint-disable no-multi-assign */ + +function deepFreeze(obj) { + if (obj instanceof Map) { + obj.clear = + obj.delete = + obj.set = + function () { + throw new Error('map is read-only'); + }; + } else if (obj instanceof Set) { + obj.add = + obj.clear = + obj.delete = + function () { + throw new Error('set is read-only'); + }; + } + + // Freeze self + Object.freeze(obj); + + Object.getOwnPropertyNames(obj).forEach((name) => { + const prop = obj[name]; + const type = typeof prop; + + // Freeze prop if it is an object or function and also not already frozen + if ((type === 'object' || type === 'function') && !Object.isFrozen(prop)) { + deepFreeze(prop); + } + }); + + return obj; +} + +/** @typedef {import('highlight.js').CallbackResponse} CallbackResponse */ +/** @typedef {import('highlight.js').CompiledMode} CompiledMode */ +/** @implements CallbackResponse */ + +class Response { + /** + * @param {CompiledMode} mode + */ + constructor(mode) { + // eslint-disable-next-line no-undefined + if (mode.data === undefined) mode.data = {}; + + this.data = mode.data; + this.isMatchIgnored = false; + } + + ignoreMatch() { + this.isMatchIgnored = true; + } +} + +/** + * @param {string} value + * @returns {string} + */ +function escapeHTML(value) { + return value + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); +} + +/** + * performs a shallow merge of multiple objects into one + * + * @template T + * @param {T} original + * @param {Record[]} objects + * @returns {T} a single new object + */ +function inherit$1(original, ...objects) { + /** @type Record */ + const result = Object.create(null); + + for (const key in original) { + result[key] = original[key]; + } + objects.forEach(function(obj) { + for (const key in obj) { + result[key] = obj[key]; + } + }); + return /** @type {T} */ (result); +} + +/** + * @typedef {object} Renderer + * @property {(text: string) => void} addText + * @property {(node: Node) => void} openNode + * @property {(node: Node) => void} closeNode + * @property {() => string} value + */ + +/** @typedef {{scope?: string, language?: string, sublanguage?: boolean}} Node */ +/** @typedef {{walk: (r: Renderer) => void}} Tree */ +/** */ + +const SPAN_CLOSE = ''; + +/** + * Determines if a node needs to be wrapped in + * + * @param {Node} node */ +const emitsWrappingTags = (node) => { + // rarely we can have a sublanguage where language is undefined + // TODO: track down why + return !!node.scope; +}; + +/** + * + * @param {string} name + * @param {{prefix:string}} options + */ +const scopeToCSSClass = (name, { prefix }) => { + // sub-language + if (name.startsWith("language:")) { + return name.replace("language:", "language-"); + } + // tiered scope: comment.line + if (name.includes(".")) { + const pieces = name.split("."); + return [ + `${prefix}${pieces.shift()}`, + ...(pieces.map((x, i) => `${x}${"_".repeat(i + 1)}`)) + ].join(" "); + } + // simple scope + return `${prefix}${name}`; +}; + +/** @type {Renderer} */ +class HTMLRenderer { + /** + * Creates a new HTMLRenderer + * + * @param {Tree} parseTree - the parse tree (must support `walk` API) + * @param {{classPrefix: string}} options + */ + constructor(parseTree, options) { + this.buffer = ""; + this.classPrefix = options.classPrefix; + parseTree.walk(this); + } + + /** + * Adds texts to the output stream + * + * @param {string} text */ + addText(text) { + this.buffer += escapeHTML(text); + } + + /** + * Adds a node open to the output stream (if needed) + * + * @param {Node} node */ + openNode(node) { + if (!emitsWrappingTags(node)) return; + + const className = scopeToCSSClass(node.scope, + { prefix: this.classPrefix }); + this.span(className); + } + + /** + * Adds a node close to the output stream (if needed) + * + * @param {Node} node */ + closeNode(node) { + if (!emitsWrappingTags(node)) return; + + this.buffer += SPAN_CLOSE; + } + + /** + * returns the accumulated buffer + */ + value() { + return this.buffer; + } + + // helpers + + /** + * Builds a span element + * + * @param {string} className */ + span(className) { + this.buffer += ``; + } +} + +/** @typedef {{scope?: string, language?: string, children: Node[]} | string} Node */ +/** @typedef {{scope?: string, language?: string, children: Node[]} } DataNode */ +/** @typedef {import('highlight.js').Emitter} Emitter */ +/** */ + +/** @returns {DataNode} */ +const newNode = (opts = {}) => { + /** @type DataNode */ + const result = { children: [] }; + Object.assign(result, opts); + return result; +}; + +class TokenTree { + constructor() { + /** @type DataNode */ + this.rootNode = newNode(); + this.stack = [this.rootNode]; + } + + get top() { + return this.stack[this.stack.length - 1]; + } + + get root() { return this.rootNode; } + + /** @param {Node} node */ + add(node) { + this.top.children.push(node); + } + + /** @param {string} scope */ + openNode(scope) { + /** @type Node */ + const node = newNode({ scope }); + this.add(node); + this.stack.push(node); + } + + closeNode() { + if (this.stack.length > 1) { + return this.stack.pop(); + } + // eslint-disable-next-line no-undefined + return undefined; + } + + closeAllNodes() { + while (this.closeNode()); + } + + toJSON() { + return JSON.stringify(this.rootNode, null, 4); + } + + /** + * @typedef { import("./html_renderer").Renderer } Renderer + * @param {Renderer} builder + */ + walk(builder) { + // this does not + return this.constructor._walk(builder, this.rootNode); + // this works + // return TokenTree._walk(builder, this.rootNode); + } + + /** + * @param {Renderer} builder + * @param {Node} node + */ + static _walk(builder, node) { + if (typeof node === "string") { + builder.addText(node); + } else if (node.children) { + builder.openNode(node); + node.children.forEach((child) => this._walk(builder, child)); + builder.closeNode(node); + } + return builder; + } + + /** + * @param {Node} node + */ + static _collapse(node) { + if (typeof node === "string") return; + if (!node.children) return; + + if (node.children.every(el => typeof el === "string")) { + // node.text = node.children.join(""); + // delete node.children; + node.children = [node.children.join("")]; + } else { + node.children.forEach((child) => { + TokenTree._collapse(child); + }); + } + } +} + +/** + Currently this is all private API, but this is the minimal API necessary + that an Emitter must implement to fully support the parser. + + Minimal interface: + + - addText(text) + - __addSublanguage(emitter, subLanguageName) + - startScope(scope) + - endScope() + - finalize() + - toHTML() + +*/ + +/** + * @implements {Emitter} + */ +class TokenTreeEmitter extends TokenTree { + /** + * @param {*} options + */ + constructor(options) { + super(); + this.options = options; + } + + /** + * @param {string} text + */ + addText(text) { + if (text === "") { return; } + + this.add(text); + } + + /** @param {string} scope */ + startScope(scope) { + this.openNode(scope); + } + + endScope() { + this.closeNode(); + } + + /** + * @param {Emitter & {root: DataNode}} emitter + * @param {string} name + */ + __addSublanguage(emitter, name) { + /** @type DataNode */ + const node = emitter.root; + if (name) node.scope = `language:${name}`; + + this.add(node); + } + + toHTML() { + const renderer = new HTMLRenderer(this, this.options); + return renderer.value(); + } + + finalize() { + this.closeAllNodes(); + return true; + } +} + +/** + * @param {string} value + * @returns {RegExp} + * */ + +/** + * @param {RegExp | string } re + * @returns {string} + */ +function source(re) { + if (!re) return null; + if (typeof re === "string") return re; + + return re.source; +} + +/** + * @param {RegExp | string } re + * @returns {string} + */ +function lookahead(re) { + return concat('(?=', re, ')'); +} + +/** + * @param {RegExp | string } re + * @returns {string} + */ +function anyNumberOfTimes(re) { + return concat('(?:', re, ')*'); +} + +/** + * @param {RegExp | string } re + * @returns {string} + */ +function optional(re) { + return concat('(?:', re, ')?'); +} + +/** + * @param {...(RegExp | string) } args + * @returns {string} + */ +function concat(...args) { + const joined = args.map((x) => source(x)).join(""); + return joined; +} + +/** + * @param { Array } args + * @returns {object} + */ +function stripOptionsFromArgs(args) { + const opts = args[args.length - 1]; + + if (typeof opts === 'object' && opts.constructor === Object) { + args.splice(args.length - 1, 1); + return opts; + } else { + return {}; + } +} + +/** @typedef { {capture?: boolean} } RegexEitherOptions */ + +/** + * Any of the passed expresssions may match + * + * Creates a huge this | this | that | that match + * @param {(RegExp | string)[] | [...(RegExp | string)[], RegexEitherOptions]} args + * @returns {string} + */ +function either(...args) { + /** @type { object & {capture?: boolean} } */ + const opts = stripOptionsFromArgs(args); + const joined = '(' + + (opts.capture ? "" : "?:") + + args.map((x) => source(x)).join("|") + ")"; + return joined; +} + +/** + * @param {RegExp | string} re + * @returns {number} + */ +function countMatchGroups(re) { + return (new RegExp(re.toString() + '|')).exec('').length - 1; +} + +/** + * Does lexeme start with a regular expression match at the beginning + * @param {RegExp} re + * @param {string} lexeme + */ +function startsWith(re, lexeme) { + const match = re && re.exec(lexeme); + return match && match.index === 0; +} + +// BACKREF_RE matches an open parenthesis or backreference. To avoid +// an incorrect parse, it additionally matches the following: +// - [...] elements, where the meaning of parentheses and escapes change +// - other escape sequences, so we do not misparse escape sequences as +// interesting elements +// - non-matching or lookahead parentheses, which do not capture. These +// follow the '(' with a '?'. +const BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./; + +// **INTERNAL** Not intended for outside usage +// join logically computes regexps.join(separator), but fixes the +// backreferences so they continue to match. +// it also places each individual regular expression into it's own +// match group, keeping track of the sequencing of those match groups +// is currently an exercise for the caller. :-) +/** + * @param {(string | RegExp)[]} regexps + * @param {{joinWith: string}} opts + * @returns {string} + */ +function _rewriteBackreferences(regexps, { joinWith }) { + let numCaptures = 0; + + return regexps.map((regex) => { + numCaptures += 1; + const offset = numCaptures; + let re = source(regex); + let out = ''; + + while (re.length > 0) { + const match = BACKREF_RE.exec(re); + if (!match) { + out += re; + break; + } + out += re.substring(0, match.index); + re = re.substring(match.index + match[0].length); + if (match[0][0] === '\\' && match[1]) { + // Adjust the backreference. + out += '\\' + String(Number(match[1]) + offset); + } else { + out += match[0]; + if (match[0] === '(') { + numCaptures++; + } + } + } + return out; + }).map(re => `(${re})`).join(joinWith); +} + +/** @typedef {import('highlight.js').Mode} Mode */ +/** @typedef {import('highlight.js').ModeCallback} ModeCallback */ + +// Common regexps +const MATCH_NOTHING_RE = /\b\B/; +const IDENT_RE = '[a-zA-Z]\\w*'; +const UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*'; +const NUMBER_RE = '\\b\\d+(\\.\\d+)?'; +const C_NUMBER_RE = '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)'; // 0x..., 0..., decimal, float +const BINARY_NUMBER_RE = '\\b(0b[01]+)'; // 0b... +const RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~'; + +/** +* @param { Partial & {binary?: string | RegExp} } opts +*/ +const SHEBANG = (opts = {}) => { + const beginShebang = /^#![ ]*\//; + if (opts.binary) { + opts.begin = concat( + beginShebang, + /.*\b/, + opts.binary, + /\b.*/); + } + return inherit$1({ + scope: 'meta', + begin: beginShebang, + end: /$/, + relevance: 0, + /** @type {ModeCallback} */ + "on:begin": (m, resp) => { + if (m.index !== 0) resp.ignoreMatch(); + } + }, opts); +}; + +// Common modes +const BACKSLASH_ESCAPE = { + begin: '\\\\[\\s\\S]', relevance: 0 +}; +const APOS_STRING_MODE = { + scope: 'string', + begin: '\'', + end: '\'', + illegal: '\\n', + contains: [BACKSLASH_ESCAPE] +}; +const QUOTE_STRING_MODE = { + scope: 'string', + begin: '"', + end: '"', + illegal: '\\n', + contains: [BACKSLASH_ESCAPE] +}; +const PHRASAL_WORDS_MODE = { + begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/ +}; +/** + * Creates a comment mode + * + * @param {string | RegExp} begin + * @param {string | RegExp} end + * @param {Mode | {}} [modeOptions] + * @returns {Partial} + */ +const COMMENT = function(begin, end, modeOptions = {}) { + const mode = inherit$1( + { + scope: 'comment', + begin, + end, + contains: [] + }, + modeOptions + ); + mode.contains.push({ + scope: 'doctag', + // hack to avoid the space from being included. the space is necessary to + // match here to prevent the plain text rule below from gobbling up doctags + begin: '[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)', + end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/, + excludeBegin: true, + relevance: 0 + }); + const ENGLISH_WORD = either( + // list of common 1 and 2 letter words in English + "I", + "a", + "is", + "so", + "us", + "to", + "at", + "if", + "in", + "it", + "on", + // note: this is not an exhaustive list of contractions, just popular ones + /[A-Za-z]+['](d|ve|re|ll|t|s|n)/, // contractions - can't we'd they're let's, etc + /[A-Za-z]+[-][a-z]+/, // `no-way`, etc. + /[A-Za-z][a-z]{2,}/ // allow capitalized words at beginning of sentences + ); + // looking like plain text, more likely to be a comment + mode.contains.push( + { + // TODO: how to include ", (, ) without breaking grammars that use these for + // comment delimiters? + // begin: /[ ]+([()"]?([A-Za-z'-]{3,}|is|a|I|so|us|[tT][oO]|at|if|in|it|on)[.]?[()":]?([.][ ]|[ ]|\))){3}/ + // --- + + // this tries to find sequences of 3 english words in a row (without any + // "programming" type syntax) this gives us a strong signal that we've + // TRULY found a comment - vs perhaps scanning with the wrong language. + // It's possible to find something that LOOKS like the start of the + // comment - but then if there is no readable text - good chance it is a + // false match and not a comment. + // + // for a visual example please see: + // https://github.com/highlightjs/highlight.js/issues/2827 + + begin: concat( + /[ ]+/, // necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */ + '(', + ENGLISH_WORD, + /[.]?[:]?([.][ ]|[ ])/, + '){3}') // look for 3 words in a row + } + ); + return mode; +}; +const C_LINE_COMMENT_MODE = COMMENT('//', '$'); +const C_BLOCK_COMMENT_MODE = COMMENT('/\\*', '\\*/'); +const HASH_COMMENT_MODE = COMMENT('#', '$'); +const NUMBER_MODE = { + scope: 'number', + begin: NUMBER_RE, + relevance: 0 +}; +const C_NUMBER_MODE = { + scope: 'number', + begin: C_NUMBER_RE, + relevance: 0 +}; +const BINARY_NUMBER_MODE = { + scope: 'number', + begin: BINARY_NUMBER_RE, + relevance: 0 +}; +const REGEXP_MODE = { + scope: "regexp", + begin: /\/(?=[^/\n]*\/)/, + end: /\/[gimuy]*/, + contains: [ + BACKSLASH_ESCAPE, + { + begin: /\[/, + end: /\]/, + relevance: 0, + contains: [BACKSLASH_ESCAPE] + } + ] +}; +const TITLE_MODE = { + scope: 'title', + begin: IDENT_RE, + relevance: 0 +}; +const UNDERSCORE_TITLE_MODE = { + scope: 'title', + begin: UNDERSCORE_IDENT_RE, + relevance: 0 +}; +const METHOD_GUARD = { + // excludes method names from keyword processing + begin: '\\.\\s*' + UNDERSCORE_IDENT_RE, + relevance: 0 +}; + +/** + * Adds end same as begin mechanics to a mode + * + * Your mode must include at least a single () match group as that first match + * group is what is used for comparison + * @param {Partial} mode + */ +const END_SAME_AS_BEGIN = function(mode) { + return Object.assign(mode, + { + /** @type {ModeCallback} */ + 'on:begin': (m, resp) => { resp.data._beginMatch = m[1]; }, + /** @type {ModeCallback} */ + 'on:end': (m, resp) => { if (resp.data._beginMatch !== m[1]) resp.ignoreMatch(); } + }); +}; + +var MODES = /*#__PURE__*/Object.freeze({ + __proto__: null, + APOS_STRING_MODE: APOS_STRING_MODE, + BACKSLASH_ESCAPE: BACKSLASH_ESCAPE, + BINARY_NUMBER_MODE: BINARY_NUMBER_MODE, + BINARY_NUMBER_RE: BINARY_NUMBER_RE, + COMMENT: COMMENT, + C_BLOCK_COMMENT_MODE: C_BLOCK_COMMENT_MODE, + C_LINE_COMMENT_MODE: C_LINE_COMMENT_MODE, + C_NUMBER_MODE: C_NUMBER_MODE, + C_NUMBER_RE: C_NUMBER_RE, + END_SAME_AS_BEGIN: END_SAME_AS_BEGIN, + HASH_COMMENT_MODE: HASH_COMMENT_MODE, + IDENT_RE: IDENT_RE, + MATCH_NOTHING_RE: MATCH_NOTHING_RE, + METHOD_GUARD: METHOD_GUARD, + NUMBER_MODE: NUMBER_MODE, + NUMBER_RE: NUMBER_RE, + PHRASAL_WORDS_MODE: PHRASAL_WORDS_MODE, + QUOTE_STRING_MODE: QUOTE_STRING_MODE, + REGEXP_MODE: REGEXP_MODE, + RE_STARTERS_RE: RE_STARTERS_RE, + SHEBANG: SHEBANG, + TITLE_MODE: TITLE_MODE, + UNDERSCORE_IDENT_RE: UNDERSCORE_IDENT_RE, + UNDERSCORE_TITLE_MODE: UNDERSCORE_TITLE_MODE +}); + +/** +@typedef {import('highlight.js').CallbackResponse} CallbackResponse +@typedef {import('highlight.js').CompilerExt} CompilerExt +*/ + +// Grammar extensions / plugins +// See: https://github.com/highlightjs/highlight.js/issues/2833 + +// Grammar extensions allow "syntactic sugar" to be added to the grammar modes +// without requiring any underlying changes to the compiler internals. + +// `compileMatch` being the perfect small example of now allowing a grammar +// author to write `match` when they desire to match a single expression rather +// than being forced to use `begin`. The extension then just moves `match` into +// `begin` when it runs. Ie, no features have been added, but we've just made +// the experience of writing (and reading grammars) a little bit nicer. + +// ------ + +// TODO: We need negative look-behind support to do this properly +/** + * Skip a match if it has a preceding dot + * + * This is used for `beginKeywords` to prevent matching expressions such as + * `bob.keyword.do()`. The mode compiler automatically wires this up as a + * special _internal_ 'on:begin' callback for modes with `beginKeywords` + * @param {RegExpMatchArray} match + * @param {CallbackResponse} response + */ +function skipIfHasPrecedingDot(match, response) { + const before = match.input[match.index - 1]; + if (before === ".") { + response.ignoreMatch(); + } +} + +/** + * + * @type {CompilerExt} + */ +function scopeClassName(mode, _parent) { + // eslint-disable-next-line no-undefined + if (mode.className !== undefined) { + mode.scope = mode.className; + delete mode.className; + } +} + +/** + * `beginKeywords` syntactic sugar + * @type {CompilerExt} + */ +function beginKeywords(mode, parent) { + if (!parent) return; + if (!mode.beginKeywords) return; + + // for languages with keywords that include non-word characters checking for + // a word boundary is not sufficient, so instead we check for a word boundary + // or whitespace - this does no harm in any case since our keyword engine + // doesn't allow spaces in keywords anyways and we still check for the boundary + // first + mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')(?!\\.)(?=\\b|\\s)'; + mode.__beforeBegin = skipIfHasPrecedingDot; + mode.keywords = mode.keywords || mode.beginKeywords; + delete mode.beginKeywords; + + // prevents double relevance, the keywords themselves provide + // relevance, the mode doesn't need to double it + // eslint-disable-next-line no-undefined + if (mode.relevance === undefined) mode.relevance = 0; +} + +/** + * Allow `illegal` to contain an array of illegal values + * @type {CompilerExt} + */ +function compileIllegal(mode, _parent) { + if (!Array.isArray(mode.illegal)) return; + + mode.illegal = either(...mode.illegal); +} + +/** + * `match` to match a single expression for readability + * @type {CompilerExt} + */ +function compileMatch(mode, _parent) { + if (!mode.match) return; + if (mode.begin || mode.end) throw new Error("begin & end are not supported with match"); + + mode.begin = mode.match; + delete mode.match; +} + +/** + * provides the default 1 relevance to all modes + * @type {CompilerExt} + */ +function compileRelevance(mode, _parent) { + // eslint-disable-next-line no-undefined + if (mode.relevance === undefined) mode.relevance = 1; +} + +// allow beforeMatch to act as a "qualifier" for the match +// the full match begin must be [beforeMatch][begin] +const beforeMatchExt = (mode, parent) => { + if (!mode.beforeMatch) return; + // starts conflicts with endsParent which we need to make sure the child + // rule is not matched multiple times + if (mode.starts) throw new Error("beforeMatch cannot be used with starts"); + + const originalMode = Object.assign({}, mode); + Object.keys(mode).forEach((key) => { delete mode[key]; }); + + mode.keywords = originalMode.keywords; + mode.begin = concat(originalMode.beforeMatch, lookahead(originalMode.begin)); + mode.starts = { + relevance: 0, + contains: [ + Object.assign(originalMode, { endsParent: true }) + ] + }; + mode.relevance = 0; + + delete originalMode.beforeMatch; +}; + +// keywords that should have no default relevance value +const COMMON_KEYWORDS = [ + 'of', + 'and', + 'for', + 'in', + 'not', + 'or', + 'if', + 'then', + 'parent', // common variable name + 'list', // common variable name + 'value' // common variable name +]; + +const DEFAULT_KEYWORD_SCOPE = "keyword"; + +/** + * Given raw keywords from a language definition, compile them. + * + * @param {string | Record | Array} rawKeywords + * @param {boolean} caseInsensitive + */ +function compileKeywords(rawKeywords, caseInsensitive, scopeName = DEFAULT_KEYWORD_SCOPE) { + /** @type {import("highlight.js/private").KeywordDict} */ + const compiledKeywords = Object.create(null); + + // input can be a string of keywords, an array of keywords, or a object with + // named keys representing scopeName (which can then point to a string or array) + if (typeof rawKeywords === 'string') { + compileList(scopeName, rawKeywords.split(" ")); + } else if (Array.isArray(rawKeywords)) { + compileList(scopeName, rawKeywords); + } else { + Object.keys(rawKeywords).forEach(function(scopeName) { + // collapse all our objects back into the parent object + Object.assign( + compiledKeywords, + compileKeywords(rawKeywords[scopeName], caseInsensitive, scopeName) + ); + }); + } + return compiledKeywords; + + // --- + + /** + * Compiles an individual list of keywords + * + * Ex: "for if when while|5" + * + * @param {string} scopeName + * @param {Array} keywordList + */ + function compileList(scopeName, keywordList) { + if (caseInsensitive) { + keywordList = keywordList.map(x => x.toLowerCase()); + } + keywordList.forEach(function(keyword) { + const pair = keyword.split('|'); + compiledKeywords[pair[0]] = [scopeName, scoreForKeyword(pair[0], pair[1])]; + }); + } +} + +/** + * Returns the proper score for a given keyword + * + * Also takes into account comment keywords, which will be scored 0 UNLESS + * another score has been manually assigned. + * @param {string} keyword + * @param {string} [providedScore] + */ +function scoreForKeyword(keyword, providedScore) { + // manual scores always win over common keywords + // so you can force a score of 1 if you really insist + if (providedScore) { + return Number(providedScore); + } + + return commonKeyword(keyword) ? 0 : 1; +} + +/** + * Determines if a given keyword is common or not + * + * @param {string} keyword */ +function commonKeyword(keyword) { + return COMMON_KEYWORDS.includes(keyword.toLowerCase()); +} + +/* + +For the reasoning behind this please see: +https://github.com/highlightjs/highlight.js/issues/2880#issuecomment-747275419 + +*/ + +/** + * @type {Record} + */ +const seenDeprecations = {}; + +/** + * @param {string} message + */ +const error = (message) => { + console.error(message); +}; + +/** + * @param {string} message + * @param {any} args + */ +const warn = (message, ...args) => { + console.log(`WARN: ${message}`, ...args); +}; + +/** + * @param {string} version + * @param {string} message + */ +const deprecated = (version, message) => { + if (seenDeprecations[`${version}/${message}`]) return; + + console.log(`Deprecated as of ${version}. ${message}`); + seenDeprecations[`${version}/${message}`] = true; +}; + +/* eslint-disable no-throw-literal */ + +/** +@typedef {import('highlight.js').CompiledMode} CompiledMode +*/ + +const MultiClassError = new Error(); + +/** + * Renumbers labeled scope names to account for additional inner match + * groups that otherwise would break everything. + * + * Lets say we 3 match scopes: + * + * { 1 => ..., 2 => ..., 3 => ... } + * + * So what we need is a clean match like this: + * + * (a)(b)(c) => [ "a", "b", "c" ] + * + * But this falls apart with inner match groups: + * + * (a)(((b)))(c) => ["a", "b", "b", "b", "c" ] + * + * Our scopes are now "out of alignment" and we're repeating `b` 3 times. + * What needs to happen is the numbers are remapped: + * + * { 1 => ..., 2 => ..., 5 => ... } + * + * We also need to know that the ONLY groups that should be output + * are 1, 2, and 5. This function handles this behavior. + * + * @param {CompiledMode} mode + * @param {Array} regexes + * @param {{key: "beginScope"|"endScope"}} opts + */ +function remapScopeNames(mode, regexes, { key }) { + let offset = 0; + const scopeNames = mode[key]; + /** @type Record */ + const emit = {}; + /** @type Record */ + const positions = {}; + + for (let i = 1; i <= regexes.length; i++) { + positions[i + offset] = scopeNames[i]; + emit[i + offset] = true; + offset += countMatchGroups(regexes[i - 1]); + } + // we use _emit to keep track of which match groups are "top-level" to avoid double + // output from inside match groups + mode[key] = positions; + mode[key]._emit = emit; + mode[key]._multi = true; +} + +/** + * @param {CompiledMode} mode + */ +function beginMultiClass(mode) { + if (!Array.isArray(mode.begin)) return; + + if (mode.skip || mode.excludeBegin || mode.returnBegin) { + error("skip, excludeBegin, returnBegin not compatible with beginScope: {}"); + throw MultiClassError; + } + + if (typeof mode.beginScope !== "object" || mode.beginScope === null) { + error("beginScope must be object"); + throw MultiClassError; + } + + remapScopeNames(mode, mode.begin, { key: "beginScope" }); + mode.begin = _rewriteBackreferences(mode.begin, { joinWith: "" }); +} + +/** + * @param {CompiledMode} mode + */ +function endMultiClass(mode) { + if (!Array.isArray(mode.end)) return; + + if (mode.skip || mode.excludeEnd || mode.returnEnd) { + error("skip, excludeEnd, returnEnd not compatible with endScope: {}"); + throw MultiClassError; + } + + if (typeof mode.endScope !== "object" || mode.endScope === null) { + error("endScope must be object"); + throw MultiClassError; + } + + remapScopeNames(mode, mode.end, { key: "endScope" }); + mode.end = _rewriteBackreferences(mode.end, { joinWith: "" }); +} + +/** + * this exists only to allow `scope: {}` to be used beside `match:` + * Otherwise `beginScope` would necessary and that would look weird + + { + match: [ /def/, /\w+/ ] + scope: { 1: "keyword" , 2: "title" } + } + + * @param {CompiledMode} mode + */ +function scopeSugar(mode) { + if (mode.scope && typeof mode.scope === "object" && mode.scope !== null) { + mode.beginScope = mode.scope; + delete mode.scope; + } +} + +/** + * @param {CompiledMode} mode + */ +function MultiClass(mode) { + scopeSugar(mode); + + if (typeof mode.beginScope === "string") { + mode.beginScope = { _wrap: mode.beginScope }; + } + if (typeof mode.endScope === "string") { + mode.endScope = { _wrap: mode.endScope }; + } + + beginMultiClass(mode); + endMultiClass(mode); +} + +/** +@typedef {import('highlight.js').Mode} Mode +@typedef {import('highlight.js').CompiledMode} CompiledMode +@typedef {import('highlight.js').Language} Language +@typedef {import('highlight.js').HLJSPlugin} HLJSPlugin +@typedef {import('highlight.js').CompiledLanguage} CompiledLanguage +*/ + +// compilation + +/** + * Compiles a language definition result + * + * Given the raw result of a language definition (Language), compiles this so + * that it is ready for highlighting code. + * @param {Language} language + * @returns {CompiledLanguage} + */ +function compileLanguage(language) { + /** + * Builds a regex with the case sensitivity of the current language + * + * @param {RegExp | string} value + * @param {boolean} [global] + */ + function langRe(value, global) { + return new RegExp( + source(value), + 'm' + + (language.case_insensitive ? 'i' : '') + + (language.unicodeRegex ? 'u' : '') + + (global ? 'g' : '') + ); + } + + /** + Stores multiple regular expressions and allows you to quickly search for + them all in a string simultaneously - returning the first match. It does + this by creating a huge (a|b|c) regex - each individual item wrapped with () + and joined by `|` - using match groups to track position. When a match is + found checking which position in the array has content allows us to figure + out which of the original regexes / match groups triggered the match. + + The match object itself (the result of `Regex.exec`) is returned but also + enhanced by merging in any meta-data that was registered with the regex. + This is how we keep track of which mode matched, and what type of rule + (`illegal`, `begin`, end, etc). + */ + class MultiRegex { + constructor() { + this.matchIndexes = {}; + // @ts-ignore + this.regexes = []; + this.matchAt = 1; + this.position = 0; + } + + // @ts-ignore + addRule(re, opts) { + opts.position = this.position++; + // @ts-ignore + this.matchIndexes[this.matchAt] = opts; + this.regexes.push([opts, re]); + this.matchAt += countMatchGroups(re) + 1; + } + + compile() { + if (this.regexes.length === 0) { + // avoids the need to check length every time exec is called + // @ts-ignore + this.exec = () => null; + } + const terminators = this.regexes.map(el => el[1]); + this.matcherRe = langRe(_rewriteBackreferences(terminators, { joinWith: '|' }), true); + this.lastIndex = 0; + } + + /** @param {string} s */ + exec(s) { + this.matcherRe.lastIndex = this.lastIndex; + const match = this.matcherRe.exec(s); + if (!match) { return null; } + + // eslint-disable-next-line no-undefined + const i = match.findIndex((el, i) => i > 0 && el !== undefined); + // @ts-ignore + const matchData = this.matchIndexes[i]; + // trim off any earlier non-relevant match groups (ie, the other regex + // match groups that make up the multi-matcher) + match.splice(0, i); + + return Object.assign(match, matchData); + } + } + + /* + Created to solve the key deficiently with MultiRegex - there is no way to + test for multiple matches at a single location. Why would we need to do + that? In the future a more dynamic engine will allow certain matches to be + ignored. An example: if we matched say the 3rd regex in a large group but + decided to ignore it - we'd need to started testing again at the 4th + regex... but MultiRegex itself gives us no real way to do that. + + So what this class creates MultiRegexs on the fly for whatever search + position they are needed. + + NOTE: These additional MultiRegex objects are created dynamically. For most + grammars most of the time we will never actually need anything more than the + first MultiRegex - so this shouldn't have too much overhead. + + Say this is our search group, and we match regex3, but wish to ignore it. + + regex1 | regex2 | regex3 | regex4 | regex5 ' ie, startAt = 0 + + What we need is a new MultiRegex that only includes the remaining + possibilities: + + regex4 | regex5 ' ie, startAt = 3 + + This class wraps all that complexity up in a simple API... `startAt` decides + where in the array of expressions to start doing the matching. It + auto-increments, so if a match is found at position 2, then startAt will be + set to 3. If the end is reached startAt will return to 0. + + MOST of the time the parser will be setting startAt manually to 0. + */ + class ResumableMultiRegex { + constructor() { + // @ts-ignore + this.rules = []; + // @ts-ignore + this.multiRegexes = []; + this.count = 0; + + this.lastIndex = 0; + this.regexIndex = 0; + } + + // @ts-ignore + getMatcher(index) { + if (this.multiRegexes[index]) return this.multiRegexes[index]; + + const matcher = new MultiRegex(); + this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts)); + matcher.compile(); + this.multiRegexes[index] = matcher; + return matcher; + } + + resumingScanAtSamePosition() { + return this.regexIndex !== 0; + } + + considerAll() { + this.regexIndex = 0; + } + + // @ts-ignore + addRule(re, opts) { + this.rules.push([re, opts]); + if (opts.type === "begin") this.count++; + } + + /** @param {string} s */ + exec(s) { + const m = this.getMatcher(this.regexIndex); + m.lastIndex = this.lastIndex; + let result = m.exec(s); + + // The following is because we have no easy way to say "resume scanning at the + // existing position but also skip the current rule ONLY". What happens is + // all prior rules are also skipped which can result in matching the wrong + // thing. Example of matching "booger": + + // our matcher is [string, "booger", number] + // + // ....booger.... + + // if "booger" is ignored then we'd really need a regex to scan from the + // SAME position for only: [string, number] but ignoring "booger" (if it + // was the first match), a simple resume would scan ahead who knows how + // far looking only for "number", ignoring potential string matches (or + // future "booger" matches that might be valid.) + + // So what we do: We execute two matchers, one resuming at the same + // position, but the second full matcher starting at the position after: + + // /--- resume first regex match here (for [number]) + // |/---- full match here for [string, "booger", number] + // vv + // ....booger.... + + // Which ever results in a match first is then used. So this 3-4 step + // process essentially allows us to say "match at this position, excluding + // a prior rule that was ignored". + // + // 1. Match "booger" first, ignore. Also proves that [string] does non match. + // 2. Resume matching for [number] + // 3. Match at index + 1 for [string, "booger", number] + // 4. If #2 and #3 result in matches, which came first? + if (this.resumingScanAtSamePosition()) { + if (result && result.index === this.lastIndex) ; else { // use the second matcher result + const m2 = this.getMatcher(0); + m2.lastIndex = this.lastIndex + 1; + result = m2.exec(s); + } + } + + if (result) { + this.regexIndex += result.position + 1; + if (this.regexIndex === this.count) { + // wrap-around to considering all matches again + this.considerAll(); + } + } + + return result; + } + } + + /** + * Given a mode, builds a huge ResumableMultiRegex that can be used to walk + * the content and find matches. + * + * @param {CompiledMode} mode + * @returns {ResumableMultiRegex} + */ + function buildModeRegex(mode) { + const mm = new ResumableMultiRegex(); + + mode.contains.forEach(term => mm.addRule(term.begin, { rule: term, type: "begin" })); + + if (mode.terminatorEnd) { + mm.addRule(mode.terminatorEnd, { type: "end" }); + } + if (mode.illegal) { + mm.addRule(mode.illegal, { type: "illegal" }); + } + + return mm; + } + + /** skip vs abort vs ignore + * + * @skip - The mode is still entered and exited normally (and contains rules apply), + * but all content is held and added to the parent buffer rather than being + * output when the mode ends. Mostly used with `sublanguage` to build up + * a single large buffer than can be parsed by sublanguage. + * + * - The mode begin ands ends normally. + * - Content matched is added to the parent mode buffer. + * - The parser cursor is moved forward normally. + * + * @abort - A hack placeholder until we have ignore. Aborts the mode (as if it + * never matched) but DOES NOT continue to match subsequent `contains` + * modes. Abort is bad/suboptimal because it can result in modes + * farther down not getting applied because an earlier rule eats the + * content but then aborts. + * + * - The mode does not begin. + * - Content matched by `begin` is added to the mode buffer. + * - The parser cursor is moved forward accordingly. + * + * @ignore - Ignores the mode (as if it never matched) and continues to match any + * subsequent `contains` modes. Ignore isn't technically possible with + * the current parser implementation. + * + * - The mode does not begin. + * - Content matched by `begin` is ignored. + * - The parser cursor is not moved forward. + */ + + /** + * Compiles an individual mode + * + * This can raise an error if the mode contains certain detectable known logic + * issues. + * @param {Mode} mode + * @param {CompiledMode | null} [parent] + * @returns {CompiledMode | never} + */ + function compileMode(mode, parent) { + const cmode = /** @type CompiledMode */ (mode); + if (mode.isCompiled) return cmode; + + [ + scopeClassName, + // do this early so compiler extensions generally don't have to worry about + // the distinction between match/begin + compileMatch, + MultiClass, + beforeMatchExt + ].forEach(ext => ext(mode, parent)); + + language.compilerExtensions.forEach(ext => ext(mode, parent)); + + // __beforeBegin is considered private API, internal use only + mode.__beforeBegin = null; + + [ + beginKeywords, + // do this later so compiler extensions that come earlier have access to the + // raw array if they wanted to perhaps manipulate it, etc. + compileIllegal, + // default to 1 relevance if not specified + compileRelevance + ].forEach(ext => ext(mode, parent)); + + mode.isCompiled = true; + + let keywordPattern = null; + if (typeof mode.keywords === "object" && mode.keywords.$pattern) { + // we need a copy because keywords might be compiled multiple times + // so we can't go deleting $pattern from the original on the first + // pass + mode.keywords = Object.assign({}, mode.keywords); + keywordPattern = mode.keywords.$pattern; + delete mode.keywords.$pattern; + } + keywordPattern = keywordPattern || /\w+/; + + if (mode.keywords) { + mode.keywords = compileKeywords(mode.keywords, language.case_insensitive); + } + + cmode.keywordPatternRe = langRe(keywordPattern, true); + + if (parent) { + if (!mode.begin) mode.begin = /\B|\b/; + cmode.beginRe = langRe(cmode.begin); + if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b/; + if (mode.end) cmode.endRe = langRe(cmode.end); + cmode.terminatorEnd = source(cmode.end) || ''; + if (mode.endsWithParent && parent.terminatorEnd) { + cmode.terminatorEnd += (mode.end ? '|' : '') + parent.terminatorEnd; + } + } + if (mode.illegal) cmode.illegalRe = langRe(/** @type {RegExp | string} */ (mode.illegal)); + if (!mode.contains) mode.contains = []; + + mode.contains = [].concat(...mode.contains.map(function(c) { + return expandOrCloneMode(c === 'self' ? mode : c); + })); + mode.contains.forEach(function(c) { compileMode(/** @type Mode */ (c), cmode); }); + + if (mode.starts) { + compileMode(mode.starts, parent); + } + + cmode.matcher = buildModeRegex(cmode); + return cmode; + } + + if (!language.compilerExtensions) language.compilerExtensions = []; + + // self is not valid at the top-level + if (language.contains && language.contains.includes('self')) { + throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation."); + } + + // we need a null object, which inherit will guarantee + language.classNameAliases = inherit$1(language.classNameAliases || {}); + + return compileMode(/** @type Mode */ (language)); +} + +/** + * Determines if a mode has a dependency on it's parent or not + * + * If a mode does have a parent dependency then often we need to clone it if + * it's used in multiple places so that each copy points to the correct parent, + * where-as modes without a parent can often safely be re-used at the bottom of + * a mode chain. + * + * @param {Mode | null} mode + * @returns {boolean} - is there a dependency on the parent? + * */ +function dependencyOnParent(mode) { + if (!mode) return false; + + return mode.endsWithParent || dependencyOnParent(mode.starts); +} + +/** + * Expands a mode or clones it if necessary + * + * This is necessary for modes with parental dependenceis (see notes on + * `dependencyOnParent`) and for nodes that have `variants` - which must then be + * exploded into their own individual modes at compile time. + * + * @param {Mode} mode + * @returns {Mode | Mode[]} + * */ +function expandOrCloneMode(mode) { + if (mode.variants && !mode.cachedVariants) { + mode.cachedVariants = mode.variants.map(function(variant) { + return inherit$1(mode, { variants: null }, variant); + }); + } + + // EXPAND + // if we have variants then essentially "replace" the mode with the variants + // this happens in compileMode, where this function is called from + if (mode.cachedVariants) { + return mode.cachedVariants; + } + + // CLONE + // if we have dependencies on parents then we need a unique + // instance of ourselves, so we can be reused with many + // different parents without issue + if (dependencyOnParent(mode)) { + return inherit$1(mode, { starts: mode.starts ? inherit$1(mode.starts) : null }); + } + + if (Object.isFrozen(mode)) { + return inherit$1(mode); + } + + // no special dependency issues, just return ourselves + return mode; +} + +var version = "11.9.0"; + +class HTMLInjectionError extends Error { + constructor(reason, html) { + super(reason); + this.name = "HTMLInjectionError"; + this.html = html; + } +} + +/* +Syntax highlighting with language autodetection. +https://highlightjs.org/ +*/ + + + +/** +@typedef {import('highlight.js').Mode} Mode +@typedef {import('highlight.js').CompiledMode} CompiledMode +@typedef {import('highlight.js').CompiledScope} CompiledScope +@typedef {import('highlight.js').Language} Language +@typedef {import('highlight.js').HLJSApi} HLJSApi +@typedef {import('highlight.js').HLJSPlugin} HLJSPlugin +@typedef {import('highlight.js').PluginEvent} PluginEvent +@typedef {import('highlight.js').HLJSOptions} HLJSOptions +@typedef {import('highlight.js').LanguageFn} LanguageFn +@typedef {import('highlight.js').HighlightedHTMLElement} HighlightedHTMLElement +@typedef {import('highlight.js').BeforeHighlightContext} BeforeHighlightContext +@typedef {import('highlight.js/private').MatchType} MatchType +@typedef {import('highlight.js/private').KeywordData} KeywordData +@typedef {import('highlight.js/private').EnhancedMatch} EnhancedMatch +@typedef {import('highlight.js/private').AnnotatedError} AnnotatedError +@typedef {import('highlight.js').AutoHighlightResult} AutoHighlightResult +@typedef {import('highlight.js').HighlightOptions} HighlightOptions +@typedef {import('highlight.js').HighlightResult} HighlightResult +*/ + + +const escape = escapeHTML; +const inherit = inherit$1; +const NO_MATCH = Symbol("nomatch"); +const MAX_KEYWORD_HITS = 7; + +/** + * @param {any} hljs - object that is extended (legacy) + * @returns {HLJSApi} + */ +const HLJS = function(hljs) { + // Global internal variables used within the highlight.js library. + /** @type {Record} */ + const languages = Object.create(null); + /** @type {Record} */ + const aliases = Object.create(null); + /** @type {HLJSPlugin[]} */ + const plugins = []; + + // safe/production mode - swallows more errors, tries to keep running + // even if a single syntax or parse hits a fatal error + let SAFE_MODE = true; + const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?"; + /** @type {Language} */ + const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: 'Plain text', contains: [] }; + + // Global options used when within external APIs. This is modified when + // calling the `hljs.configure` function. + /** @type HLJSOptions */ + let options = { + ignoreUnescapedHTML: false, + throwUnescapedHTML: false, + noHighlightRe: /^(no-?highlight)$/i, + languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i, + classPrefix: 'hljs-', + cssSelector: 'pre code', + languages: null, + // beta configuration options, subject to change, welcome to discuss + // https://github.com/highlightjs/highlight.js/issues/1086 + __emitter: TokenTreeEmitter + }; + + /* Utility functions */ + + /** + * Tests a language name to see if highlighting should be skipped + * @param {string} languageName + */ + function shouldNotHighlight(languageName) { + return options.noHighlightRe.test(languageName); + } + + /** + * @param {HighlightedHTMLElement} block - the HTML element to determine language for + */ + function blockLanguage(block) { + let classes = block.className + ' '; + + classes += block.parentNode ? block.parentNode.className : ''; + + // language-* takes precedence over non-prefixed class names. + const match = options.languageDetectRe.exec(classes); + if (match) { + const language = getLanguage(match[1]); + if (!language) { + warn(LANGUAGE_NOT_FOUND.replace("{}", match[1])); + warn("Falling back to no-highlight mode for this block.", block); + } + return language ? match[1] : 'no-highlight'; + } + + return classes + .split(/\s+/) + .find((_class) => shouldNotHighlight(_class) || getLanguage(_class)); + } + + /** + * Core highlighting function. + * + * OLD API + * highlight(lang, code, ignoreIllegals, continuation) + * + * NEW API + * highlight(code, {lang, ignoreIllegals}) + * + * @param {string} codeOrLanguageName - the language to use for highlighting + * @param {string | HighlightOptions} optionsOrCode - the code to highlight + * @param {boolean} [ignoreIllegals] - whether to ignore illegal matches, default is to bail + * + * @returns {HighlightResult} Result - an object that represents the result + * @property {string} language - the language name + * @property {number} relevance - the relevance score + * @property {string} value - the highlighted HTML code + * @property {string} code - the original raw code + * @property {CompiledMode} top - top of the current mode stack + * @property {boolean} illegal - indicates whether any illegal matches were found + */ + function highlight(codeOrLanguageName, optionsOrCode, ignoreIllegals) { + let code = ""; + let languageName = ""; + if (typeof optionsOrCode === "object") { + code = codeOrLanguageName; + ignoreIllegals = optionsOrCode.ignoreIllegals; + languageName = optionsOrCode.language; + } else { + // old API + deprecated("10.7.0", "highlight(lang, code, ...args) has been deprecated."); + deprecated("10.7.0", "Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"); + languageName = codeOrLanguageName; + code = optionsOrCode; + } + + // https://github.com/highlightjs/highlight.js/issues/3149 + // eslint-disable-next-line no-undefined + if (ignoreIllegals === undefined) { ignoreIllegals = true; } + + /** @type {BeforeHighlightContext} */ + const context = { + code, + language: languageName + }; + // the plugin can change the desired language or the code to be highlighted + // just be changing the object it was passed + fire("before:highlight", context); + + // a before plugin can usurp the result completely by providing it's own + // in which case we don't even need to call highlight + const result = context.result + ? context.result + : _highlight(context.language, context.code, ignoreIllegals); + + result.code = context.code; + // the plugin can change anything in result to suite it + fire("after:highlight", result); + + return result; + } + + /** + * private highlight that's used internally and does not fire callbacks + * + * @param {string} languageName - the language to use for highlighting + * @param {string} codeToHighlight - the code to highlight + * @param {boolean?} [ignoreIllegals] - whether to ignore illegal matches, default is to bail + * @param {CompiledMode?} [continuation] - current continuation mode, if any + * @returns {HighlightResult} - result of the highlight operation + */ + function _highlight(languageName, codeToHighlight, ignoreIllegals, continuation) { + const keywordHits = Object.create(null); + + /** + * Return keyword data if a match is a keyword + * @param {CompiledMode} mode - current mode + * @param {string} matchText - the textual match + * @returns {KeywordData | false} + */ + function keywordData(mode, matchText) { + return mode.keywords[matchText]; + } + + function processKeywords() { + if (!top.keywords) { + emitter.addText(modeBuffer); + return; + } + + let lastIndex = 0; + top.keywordPatternRe.lastIndex = 0; + let match = top.keywordPatternRe.exec(modeBuffer); + let buf = ""; + + while (match) { + buf += modeBuffer.substring(lastIndex, match.index); + const word = language.case_insensitive ? match[0].toLowerCase() : match[0]; + const data = keywordData(top, word); + if (data) { + const [kind, keywordRelevance] = data; + emitter.addText(buf); + buf = ""; + + keywordHits[word] = (keywordHits[word] || 0) + 1; + if (keywordHits[word] <= MAX_KEYWORD_HITS) relevance += keywordRelevance; + if (kind.startsWith("_")) { + // _ implied for relevance only, do not highlight + // by applying a class name + buf += match[0]; + } else { + const cssClass = language.classNameAliases[kind] || kind; + emitKeyword(match[0], cssClass); + } + } else { + buf += match[0]; + } + lastIndex = top.keywordPatternRe.lastIndex; + match = top.keywordPatternRe.exec(modeBuffer); + } + buf += modeBuffer.substring(lastIndex); + emitter.addText(buf); + } + + function processSubLanguage() { + if (modeBuffer === "") return; + /** @type HighlightResult */ + let result = null; + + if (typeof top.subLanguage === 'string') { + if (!languages[top.subLanguage]) { + emitter.addText(modeBuffer); + return; + } + result = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage]); + continuations[top.subLanguage] = /** @type {CompiledMode} */ (result._top); + } else { + result = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null); + } + + // Counting embedded language score towards the host language may be disabled + // with zeroing the containing mode relevance. Use case in point is Markdown that + // allows XML everywhere and makes every XML snippet to have a much larger Markdown + // score. + if (top.relevance > 0) { + relevance += result.relevance; + } + emitter.__addSublanguage(result._emitter, result.language); + } + + function processBuffer() { + if (top.subLanguage != null) { + processSubLanguage(); + } else { + processKeywords(); + } + modeBuffer = ''; + } + + /** + * @param {string} text + * @param {string} scope + */ + function emitKeyword(keyword, scope) { + if (keyword === "") return; + + emitter.startScope(scope); + emitter.addText(keyword); + emitter.endScope(); + } + + /** + * @param {CompiledScope} scope + * @param {RegExpMatchArray} match + */ + function emitMultiClass(scope, match) { + let i = 1; + const max = match.length - 1; + while (i <= max) { + if (!scope._emit[i]) { i++; continue; } + const klass = language.classNameAliases[scope[i]] || scope[i]; + const text = match[i]; + if (klass) { + emitKeyword(text, klass); + } else { + modeBuffer = text; + processKeywords(); + modeBuffer = ""; + } + i++; + } + } + + /** + * @param {CompiledMode} mode - new mode to start + * @param {RegExpMatchArray} match + */ + function startNewMode(mode, match) { + if (mode.scope && typeof mode.scope === "string") { + emitter.openNode(language.classNameAliases[mode.scope] || mode.scope); + } + if (mode.beginScope) { + // beginScope just wraps the begin match itself in a scope + if (mode.beginScope._wrap) { + emitKeyword(modeBuffer, language.classNameAliases[mode.beginScope._wrap] || mode.beginScope._wrap); + modeBuffer = ""; + } else if (mode.beginScope._multi) { + // at this point modeBuffer should just be the match + emitMultiClass(mode.beginScope, match); + modeBuffer = ""; + } + } + + top = Object.create(mode, { parent: { value: top } }); + return top; + } + + /** + * @param {CompiledMode } mode - the mode to potentially end + * @param {RegExpMatchArray} match - the latest match + * @param {string} matchPlusRemainder - match plus remainder of content + * @returns {CompiledMode | void} - the next mode, or if void continue on in current mode + */ + function endOfMode(mode, match, matchPlusRemainder) { + let matched = startsWith(mode.endRe, matchPlusRemainder); + + if (matched) { + if (mode["on:end"]) { + const resp = new Response(mode); + mode["on:end"](match, resp); + if (resp.isMatchIgnored) matched = false; + } + + if (matched) { + while (mode.endsParent && mode.parent) { + mode = mode.parent; + } + return mode; + } + } + // even if on:end fires an `ignore` it's still possible + // that we might trigger the end node because of a parent mode + if (mode.endsWithParent) { + return endOfMode(mode.parent, match, matchPlusRemainder); + } + } + + /** + * Handle matching but then ignoring a sequence of text + * + * @param {string} lexeme - string containing full match text + */ + function doIgnore(lexeme) { + if (top.matcher.regexIndex === 0) { + // no more regexes to potentially match here, so we move the cursor forward one + // space + modeBuffer += lexeme[0]; + return 1; + } else { + // no need to move the cursor, we still have additional regexes to try and + // match at this very spot + resumeScanAtSamePosition = true; + return 0; + } + } + + /** + * Handle the start of a new potential mode match + * + * @param {EnhancedMatch} match - the current match + * @returns {number} how far to advance the parse cursor + */ + function doBeginMatch(match) { + const lexeme = match[0]; + const newMode = match.rule; + + const resp = new Response(newMode); + // first internal before callbacks, then the public ones + const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]]; + for (const cb of beforeCallbacks) { + if (!cb) continue; + cb(match, resp); + if (resp.isMatchIgnored) return doIgnore(lexeme); + } + + if (newMode.skip) { + modeBuffer += lexeme; + } else { + if (newMode.excludeBegin) { + modeBuffer += lexeme; + } + processBuffer(); + if (!newMode.returnBegin && !newMode.excludeBegin) { + modeBuffer = lexeme; + } + } + startNewMode(newMode, match); + return newMode.returnBegin ? 0 : lexeme.length; + } + + /** + * Handle the potential end of mode + * + * @param {RegExpMatchArray} match - the current match + */ + function doEndMatch(match) { + const lexeme = match[0]; + const matchPlusRemainder = codeToHighlight.substring(match.index); + + const endMode = endOfMode(top, match, matchPlusRemainder); + if (!endMode) { return NO_MATCH; } + + const origin = top; + if (top.endScope && top.endScope._wrap) { + processBuffer(); + emitKeyword(lexeme, top.endScope._wrap); + } else if (top.endScope && top.endScope._multi) { + processBuffer(); + emitMultiClass(top.endScope, match); + } else if (origin.skip) { + modeBuffer += lexeme; + } else { + if (!(origin.returnEnd || origin.excludeEnd)) { + modeBuffer += lexeme; + } + processBuffer(); + if (origin.excludeEnd) { + modeBuffer = lexeme; + } + } + do { + if (top.scope) { + emitter.closeNode(); + } + if (!top.skip && !top.subLanguage) { + relevance += top.relevance; + } + top = top.parent; + } while (top !== endMode.parent); + if (endMode.starts) { + startNewMode(endMode.starts, match); + } + return origin.returnEnd ? 0 : lexeme.length; + } + + function processContinuations() { + const list = []; + for (let current = top; current !== language; current = current.parent) { + if (current.scope) { + list.unshift(current.scope); + } + } + list.forEach(item => emitter.openNode(item)); + } + + /** @type {{type?: MatchType, index?: number, rule?: Mode}}} */ + let lastMatch = {}; + + /** + * Process an individual match + * + * @param {string} textBeforeMatch - text preceding the match (since the last match) + * @param {EnhancedMatch} [match] - the match itself + */ + function processLexeme(textBeforeMatch, match) { + const lexeme = match && match[0]; + + // add non-matched text to the current mode buffer + modeBuffer += textBeforeMatch; + + if (lexeme == null) { + processBuffer(); + return 0; + } + + // we've found a 0 width match and we're stuck, so we need to advance + // this happens when we have badly behaved rules that have optional matchers to the degree that + // sometimes they can end up matching nothing at all + // Ref: https://github.com/highlightjs/highlight.js/issues/2140 + if (lastMatch.type === "begin" && match.type === "end" && lastMatch.index === match.index && lexeme === "") { + // spit the "skipped" character that our regex choked on back into the output sequence + modeBuffer += codeToHighlight.slice(match.index, match.index + 1); + if (!SAFE_MODE) { + /** @type {AnnotatedError} */ + const err = new Error(`0 width match regex (${languageName})`); + err.languageName = languageName; + err.badRule = lastMatch.rule; + throw err; + } + return 1; + } + lastMatch = match; + + if (match.type === "begin") { + return doBeginMatch(match); + } else if (match.type === "illegal" && !ignoreIllegals) { + // illegal match, we do not continue processing + /** @type {AnnotatedError} */ + const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.scope || '') + '"'); + err.mode = top; + throw err; + } else if (match.type === "end") { + const processed = doEndMatch(match); + if (processed !== NO_MATCH) { + return processed; + } + } + + // edge case for when illegal matches $ (end of line) which is technically + // a 0 width match but not a begin/end match so it's not caught by the + // first handler (when ignoreIllegals is true) + if (match.type === "illegal" && lexeme === "") { + // advance so we aren't stuck in an infinite loop + return 1; + } + + // infinite loops are BAD, this is a last ditch catch all. if we have a + // decent number of iterations yet our index (cursor position in our + // parsing) still 3x behind our index then something is very wrong + // so we bail + if (iterations > 100000 && iterations > match.index * 3) { + const err = new Error('potential infinite loop, way more iterations than matches'); + throw err; + } + + /* + Why might be find ourselves here? An potential end match that was + triggered but could not be completed. IE, `doEndMatch` returned NO_MATCH. + (this could be because a callback requests the match be ignored, etc) + + This causes no real harm other than stopping a few times too many. + */ + + modeBuffer += lexeme; + return lexeme.length; + } + + const language = getLanguage(languageName); + if (!language) { + error(LANGUAGE_NOT_FOUND.replace("{}", languageName)); + throw new Error('Unknown language: "' + languageName + '"'); + } + + const md = compileLanguage(language); + let result = ''; + /** @type {CompiledMode} */ + let top = continuation || md; + /** @type Record */ + const continuations = {}; // keep continuations for sub-languages + const emitter = new options.__emitter(options); + processContinuations(); + let modeBuffer = ''; + let relevance = 0; + let index = 0; + let iterations = 0; + let resumeScanAtSamePosition = false; + + try { + if (!language.__emitTokens) { + top.matcher.considerAll(); + + for (;;) { + iterations++; + if (resumeScanAtSamePosition) { + // only regexes not matched previously will now be + // considered for a potential match + resumeScanAtSamePosition = false; + } else { + top.matcher.considerAll(); + } + top.matcher.lastIndex = index; + + const match = top.matcher.exec(codeToHighlight); + // console.log("match", match[0], match.rule && match.rule.begin) + + if (!match) break; + + const beforeMatch = codeToHighlight.substring(index, match.index); + const processedCount = processLexeme(beforeMatch, match); + index = match.index + processedCount; + } + processLexeme(codeToHighlight.substring(index)); + } else { + language.__emitTokens(codeToHighlight, emitter); + } + + emitter.finalize(); + result = emitter.toHTML(); + + return { + language: languageName, + value: result, + relevance, + illegal: false, + _emitter: emitter, + _top: top + }; + } catch (err) { + if (err.message && err.message.includes('Illegal')) { + return { + language: languageName, + value: escape(codeToHighlight), + illegal: true, + relevance: 0, + _illegalBy: { + message: err.message, + index, + context: codeToHighlight.slice(index - 100, index + 100), + mode: err.mode, + resultSoFar: result + }, + _emitter: emitter + }; + } else if (SAFE_MODE) { + return { + language: languageName, + value: escape(codeToHighlight), + illegal: false, + relevance: 0, + errorRaised: err, + _emitter: emitter, + _top: top + }; + } else { + throw err; + } + } + } + + /** + * returns a valid highlight result, without actually doing any actual work, + * auto highlight starts with this and it's possible for small snippets that + * auto-detection may not find a better match + * @param {string} code + * @returns {HighlightResult} + */ + function justTextHighlightResult(code) { + const result = { + value: escape(code), + illegal: false, + relevance: 0, + _top: PLAINTEXT_LANGUAGE, + _emitter: new options.__emitter(options) + }; + result._emitter.addText(code); + return result; + } + + /** + Highlighting with language detection. Accepts a string with the code to + highlight. Returns an object with the following properties: + + - language (detected language) + - relevance (int) + - value (an HTML string with highlighting markup) + - secondBest (object with the same structure for second-best heuristically + detected language, may be absent) + + @param {string} code + @param {Array} [languageSubset] + @returns {AutoHighlightResult} + */ + function highlightAuto(code, languageSubset) { + languageSubset = languageSubset || options.languages || Object.keys(languages); + const plaintext = justTextHighlightResult(code); + + const results = languageSubset.filter(getLanguage).filter(autoDetection).map(name => + _highlight(name, code, false) + ); + results.unshift(plaintext); // plaintext is always an option + + const sorted = results.sort((a, b) => { + // sort base on relevance + if (a.relevance !== b.relevance) return b.relevance - a.relevance; + + // always award the tie to the base language + // ie if C++ and Arduino are tied, it's more likely to be C++ + if (a.language && b.language) { + if (getLanguage(a.language).supersetOf === b.language) { + return 1; + } else if (getLanguage(b.language).supersetOf === a.language) { + return -1; + } + } + + // otherwise say they are equal, which has the effect of sorting on + // relevance while preserving the original ordering - which is how ties + // have historically been settled, ie the language that comes first always + // wins in the case of a tie + return 0; + }); + + const [best, secondBest] = sorted; + + /** @type {AutoHighlightResult} */ + const result = best; + result.secondBest = secondBest; + + return result; + } + + /** + * Builds new class name for block given the language name + * + * @param {HTMLElement} element + * @param {string} [currentLang] + * @param {string} [resultLang] + */ + function updateClassName(element, currentLang, resultLang) { + const language = (currentLang && aliases[currentLang]) || resultLang; + + element.classList.add("hljs"); + element.classList.add(`language-${language}`); + } + + /** + * Applies highlighting to a DOM node containing code. + * + * @param {HighlightedHTMLElement} element - the HTML element to highlight + */ + function highlightElement(element) { + /** @type HTMLElement */ + let node = null; + const language = blockLanguage(element); + + if (shouldNotHighlight(language)) return; + + fire("before:highlightElement", + { el: element, language }); + + if (element.dataset.highlighted) { + console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", element); + return; + } + + // we should be all text, no child nodes (unescaped HTML) - this is possibly + // an HTML injection attack - it's likely too late if this is already in + // production (the code has likely already done its damage by the time + // we're seeing it)... but we yell loudly about this so that hopefully it's + // more likely to be caught in development before making it to production + if (element.children.length > 0) { + if (!options.ignoreUnescapedHTML) { + console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."); + console.warn("https://github.com/highlightjs/highlight.js/wiki/security"); + console.warn("The element with unescaped HTML:"); + console.warn(element); + } + if (options.throwUnescapedHTML) { + const err = new HTMLInjectionError( + "One of your code blocks includes unescaped HTML.", + element.innerHTML + ); + throw err; + } + } + + node = element; + const text = node.textContent; + const result = language ? highlight(text, { language, ignoreIllegals: true }) : highlightAuto(text); + + element.innerHTML = result.value; + element.dataset.highlighted = "yes"; + updateClassName(element, language, result.language); + element.result = { + language: result.language, + // TODO: remove with version 11.0 + re: result.relevance, + relevance: result.relevance + }; + if (result.secondBest) { + element.secondBest = { + language: result.secondBest.language, + relevance: result.secondBest.relevance + }; + } + + fire("after:highlightElement", { el: element, result, text }); + } + + /** + * Updates highlight.js global options with the passed options + * + * @param {Partial} userOptions + */ + function configure(userOptions) { + options = inherit(options, userOptions); + } + + // TODO: remove v12, deprecated + const initHighlighting = () => { + highlightAll(); + deprecated("10.6.0", "initHighlighting() deprecated. Use highlightAll() now."); + }; + + // TODO: remove v12, deprecated + function initHighlightingOnLoad() { + highlightAll(); + deprecated("10.6.0", "initHighlightingOnLoad() deprecated. Use highlightAll() now."); + } + + let wantsHighlight = false; + + /** + * auto-highlights all pre>code elements on the page + */ + function highlightAll() { + // if we are called too early in the loading process + if (document.readyState === "loading") { + wantsHighlight = true; + return; + } + + const blocks = document.querySelectorAll(options.cssSelector); + blocks.forEach(highlightElement); + } + + function boot() { + // if a highlight was requested before DOM was loaded, do now + if (wantsHighlight) highlightAll(); + } + + // make sure we are in the browser environment + if (typeof window !== 'undefined' && window.addEventListener) { + window.addEventListener('DOMContentLoaded', boot, false); + } + + /** + * Register a language grammar module + * + * @param {string} languageName + * @param {LanguageFn} languageDefinition + */ + function registerLanguage(languageName, languageDefinition) { + let lang = null; + try { + lang = languageDefinition(hljs); + } catch (error$1) { + error("Language definition for '{}' could not be registered.".replace("{}", languageName)); + // hard or soft error + if (!SAFE_MODE) { throw error$1; } else { error(error$1); } + // languages that have serious errors are replaced with essentially a + // "plaintext" stand-in so that the code blocks will still get normal + // css classes applied to them - and one bad language won't break the + // entire highlighter + lang = PLAINTEXT_LANGUAGE; + } + // give it a temporary name if it doesn't have one in the meta-data + if (!lang.name) lang.name = languageName; + languages[languageName] = lang; + lang.rawDefinition = languageDefinition.bind(null, hljs); + + if (lang.aliases) { + registerAliases(lang.aliases, { languageName }); + } + } + + /** + * Remove a language grammar module + * + * @param {string} languageName + */ + function unregisterLanguage(languageName) { + delete languages[languageName]; + for (const alias of Object.keys(aliases)) { + if (aliases[alias] === languageName) { + delete aliases[alias]; + } + } + } + + /** + * @returns {string[]} List of language internal names + */ + function listLanguages() { + return Object.keys(languages); + } + + /** + * @param {string} name - name of the language to retrieve + * @returns {Language | undefined} + */ + function getLanguage(name) { + name = (name || '').toLowerCase(); + return languages[name] || languages[aliases[name]]; + } + + /** + * + * @param {string|string[]} aliasList - single alias or list of aliases + * @param {{languageName: string}} opts + */ + function registerAliases(aliasList, { languageName }) { + if (typeof aliasList === 'string') { + aliasList = [aliasList]; + } + aliasList.forEach(alias => { aliases[alias.toLowerCase()] = languageName; }); + } + + /** + * Determines if a given language has auto-detection enabled + * @param {string} name - name of the language + */ + function autoDetection(name) { + const lang = getLanguage(name); + return lang && !lang.disableAutodetect; + } + + /** + * Upgrades the old highlightBlock plugins to the new + * highlightElement API + * @param {HLJSPlugin} plugin + */ + function upgradePluginAPI(plugin) { + // TODO: remove with v12 + if (plugin["before:highlightBlock"] && !plugin["before:highlightElement"]) { + plugin["before:highlightElement"] = (data) => { + plugin["before:highlightBlock"]( + Object.assign({ block: data.el }, data) + ); + }; + } + if (plugin["after:highlightBlock"] && !plugin["after:highlightElement"]) { + plugin["after:highlightElement"] = (data) => { + plugin["after:highlightBlock"]( + Object.assign({ block: data.el }, data) + ); + }; + } + } + + /** + * @param {HLJSPlugin} plugin + */ + function addPlugin(plugin) { + upgradePluginAPI(plugin); + plugins.push(plugin); + } + + /** + * @param {HLJSPlugin} plugin + */ + function removePlugin(plugin) { + const index = plugins.indexOf(plugin); + if (index !== -1) { + plugins.splice(index, 1); + } + } + + /** + * + * @param {PluginEvent} event + * @param {any} args + */ + function fire(event, args) { + const cb = event; + plugins.forEach(function(plugin) { + if (plugin[cb]) { + plugin[cb](args); + } + }); + } + + /** + * DEPRECATED + * @param {HighlightedHTMLElement} el + */ + function deprecateHighlightBlock(el) { + deprecated("10.7.0", "highlightBlock will be removed entirely in v12.0"); + deprecated("10.7.0", "Please use highlightElement now."); + + return highlightElement(el); + } + + /* Interface definition */ + Object.assign(hljs, { + highlight, + highlightAuto, + highlightAll, + highlightElement, + // TODO: Remove with v12 API + highlightBlock: deprecateHighlightBlock, + configure, + initHighlighting, + initHighlightingOnLoad, + registerLanguage, + unregisterLanguage, + listLanguages, + getLanguage, + registerAliases, + autoDetection, + inherit, + addPlugin, + removePlugin + }); + + hljs.debugMode = function() { SAFE_MODE = false; }; + hljs.safeMode = function() { SAFE_MODE = true; }; + hljs.versionString = version; + + hljs.regex = { + concat: concat, + lookahead: lookahead, + either: either, + optional: optional, + anyNumberOfTimes: anyNumberOfTimes + }; + + for (const key in MODES) { + // @ts-ignore + if (typeof MODES[key] === "object") { + // @ts-ignore + deepFreeze(MODES[key]); + } + } + + // merge all the modes/regexes into our main object + Object.assign(hljs, MODES); + + return hljs; +}; + +// Other names for the variable may break build script +const highlight = HLJS({}); + +// returns a new instance of the highlighter to be used for extensions +// check https://github.com/wooorm/lowlight/issues/47 +highlight.newInstance = () => HLJS({}); + +module.exports = highlight; +highlight.HighlightJS = highlight; +highlight.default = highlight; + + +/***/ }), + +/***/ "./node_modules/highlight.js/es/core.js": +/*!**********************************************!*\ + !*** ./node_modules/highlight.js/es/core.js ***! + \**********************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ HighlightJS: () => (/* reexport default export from named module */ _lib_core_js__WEBPACK_IMPORTED_MODULE_0__), +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _lib_core_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/core.js */ "./node_modules/highlight.js/lib/core.js"); +// https://nodejs.org/api/packages.html#packages_writing_dual_packages_while_avoiding_or_minimizing_hazards + + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_lib_core_js__WEBPACK_IMPORTED_MODULE_0__); + + +/***/ }), + +/***/ "./node_modules/highlight.js/es/languages/r.js": +/*!*****************************************************!*\ + !*** ./node_modules/highlight.js/es/languages/r.js ***! + \*****************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ r) +/* harmony export */ }); +/* +Language: R +Description: R is a free software environment for statistical computing and graphics. +Author: Joe Cheng +Contributors: Konrad Rudolph +Website: https://www.r-project.org +Category: common,scientific +*/ + +/** @type LanguageFn */ +function r(hljs) { + const regex = hljs.regex; + // Identifiers in R cannot start with `_`, but they can start with `.` if it + // is not immediately followed by a digit. + // R also supports quoted identifiers, which are near-arbitrary sequences + // delimited by backticks (`…`), which may contain escape sequences. These are + // handled in a separate mode. See `test/markup/r/names.txt` for examples. + // FIXME: Support Unicode identifiers. + const IDENT_RE = /(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/; + const NUMBER_TYPES_RE = regex.either( + // Special case: only hexadecimal binary powers can contain fractions + /0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/, + // Hexadecimal numbers without fraction and optional binary power + /0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/, + // Decimal numbers + /(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/ + ); + const OPERATORS_RE = /[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/; + const PUNCTUATION_RE = regex.either( + /[()]/, + /[{}]/, + /\[\[/, + /[[\]]/, + /\\/, + /,/ + ); + + return { + name: 'R', + + keywords: { + $pattern: IDENT_RE, + keyword: + 'function if in break next repeat else for while', + literal: + 'NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 ' + + 'NA_character_|10 NA_complex_|10', + built_in: + // Builtin constants + 'LETTERS letters month.abb month.name pi T F ' + // Primitive functions + // These are all the functions in `base` that are implemented as a + // `.Primitive`, minus those functions that are also keywords. + + 'abs acos acosh all any anyNA Arg as.call as.character ' + + 'as.complex as.double as.environment as.integer as.logical ' + + 'as.null.default as.numeric as.raw asin asinh atan atanh attr ' + + 'attributes baseenv browser c call ceiling class Conj cos cosh ' + + 'cospi cummax cummin cumprod cumsum digamma dim dimnames ' + + 'emptyenv exp expression floor forceAndCall gamma gc.time ' + + 'globalenv Im interactive invisible is.array is.atomic is.call ' + + 'is.character is.complex is.double is.environment is.expression ' + + 'is.finite is.function is.infinite is.integer is.language ' + + 'is.list is.logical is.matrix is.na is.name is.nan is.null ' + + 'is.numeric is.object is.pairlist is.raw is.recursive is.single ' + + 'is.symbol lazyLoadDBfetch length lgamma list log max min ' + + 'missing Mod names nargs nzchar oldClass on.exit pos.to.env ' + + 'proc.time prod quote range Re rep retracemem return round ' + + 'seq_along seq_len seq.int sign signif sin sinh sinpi sqrt ' + + 'standardGeneric substitute sum switch tan tanh tanpi tracemem ' + + 'trigamma trunc unclass untracemem UseMethod xtfrm', + }, + + contains: [ + // Roxygen comments + hljs.COMMENT( + /#'/, + /$/, + { contains: [ + { + // Handle `@examples` separately to cause all subsequent code + // until the next `@`-tag on its own line to be kept as-is, + // preventing highlighting. This code is example R code, so nested + // doctags shouldn’t be treated as such. See + // `test/markup/r/roxygen.txt` for an example. + scope: 'doctag', + match: /@examples/, + starts: { + end: regex.lookahead(regex.either( + // end if another doc comment + /\n^#'\s*(?=@[a-zA-Z]+)/, + // or a line with no comment + /\n^(?!#')/ + )), + endsParent: true + } + }, + { + // Handle `@param` to highlight the parameter name following + // after. + scope: 'doctag', + begin: '@param', + end: /$/, + contains: [ + { + scope: 'variable', + variants: [ + { match: IDENT_RE }, + { match: /`(?:\\.|[^`\\])+`/ } + ], + endsParent: true + } + ] + }, + { + scope: 'doctag', + match: /@[a-zA-Z]+/ + }, + { + scope: 'keyword', + match: /\\[a-zA-Z]+/ + } + ] } + ), + + hljs.HASH_COMMENT_MODE, + + { + scope: 'string', + contains: [ hljs.BACKSLASH_ESCAPE ], + variants: [ + hljs.END_SAME_AS_BEGIN({ + begin: /[rR]"(-*)\(/, + end: /\)(-*)"/ + }), + hljs.END_SAME_AS_BEGIN({ + begin: /[rR]"(-*)\{/, + end: /\}(-*)"/ + }), + hljs.END_SAME_AS_BEGIN({ + begin: /[rR]"(-*)\[/, + end: /\](-*)"/ + }), + hljs.END_SAME_AS_BEGIN({ + begin: /[rR]'(-*)\(/, + end: /\)(-*)'/ + }), + hljs.END_SAME_AS_BEGIN({ + begin: /[rR]'(-*)\{/, + end: /\}(-*)'/ + }), + hljs.END_SAME_AS_BEGIN({ + begin: /[rR]'(-*)\[/, + end: /\](-*)'/ + }), + { + begin: '"', + end: '"', + relevance: 0 + }, + { + begin: "'", + end: "'", + relevance: 0 + } + ], + }, + + // Matching numbers immediately following punctuation and operators is + // tricky since we need to look at the character ahead of a number to + // ensure the number is not part of an identifier, and we cannot use + // negative look-behind assertions. So instead we explicitly handle all + // possible combinations of (operator|punctuation), number. + // TODO: replace with negative look-behind when available + // { begin: /(? { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = (module) => { +/******/ var getter = module && module.__esModule ? +/******/ () => (module['default']) : +/******/ () => (module); +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be in strict mode. +(() => { +"use strict"; +/*!************************!*\ + !*** ./srcjs/index.js ***! + \************************/ +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var shiny__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! shiny */ "shiny"); +/* harmony import */ var shiny__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(shiny__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _copy_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./copy.js */ "./srcjs/copy.js"); +/* harmony import */ var _hl_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hl.js */ "./srcjs/hl.js"); +/* harmony import */ var _shiny_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shiny.js */ "./srcjs/shiny.js"); + + + + + +})(); + +/******/ })() +; +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7O0FBQU87QUFDUDtBQUNBO0FBQ0E7O0FBRUE7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTs7QUFFQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQ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goaW5kZXgsIGJsb2NrKSA9PiB7XG4gICAgICBjb25zdCAkYmxvY2sgPSAkKGJsb2NrKTtcblxuICAgICAgaWYgKGVkaXRhYmxlKSB7XG4gICAgICAgICRibG9jay5yZW1vdmVDbGFzcyhcImQtbm9uZVwiKTtcbiAgICAgICAgJGJsb2NrLmZpbmQoXCIuYmxvY2staW5wdXRzXCIpLnJlbW92ZUNsYXNzKFwiZC1ub25lXCIpO1xuICAgICAgICAkYmxvY2suZmluZChcIi5ibG9jay1pbnB1dHNcIikudHJpZ2dlcihcInNob3duXCIpO1xuXG4gICAgICAgIGlmIChpbmRleCA9PSAoJGJsb2Nrcy5sZW5ndGggLSAxKSkge1xuICAgICAgICAgICRibG9jay5maW5kKFwiLmJsb2NrLW91dHB1dFwiKS5hZGRDbGFzcyhcInNob3dcIik7XG4gICAgICAgICAgJGJsb2NrLmZpbmQoXCIuYmxvY2stb3V0cHV0XCIpLnJlbW92ZUNsYXNzKFwiZC1ub25lXCIpO1xuICAgICAgICAgICRibG9jay5maW5kKFwiLmJsb2NrLW91dHB1dFwiKS50cmlnZ2VyKFwic2hvd25cIik7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuO1xuICAgICAgfVxuXG4gICAgICAkYmxvY2suZmluZChcIi5ibG9jay1pbnB1dHNcIikuYWRkQ2xhc3MoXCJkLW5vbmVcIik7XG4gICAgICAkYmxvY2suZmluZChcIi5ibG9jay1pbnB1dHNcIikudHJpZ2dlcihcImhpZGRlblwiKTtcblxuICAgICAgaWYgKGluZGV4ID09ICgkYmxvY2tzLmxlbmd0aCAtIDEpKSB7XG4gICAgICAgICRibG9jay5yZW1vdmVDbGFzcyhcImQtbm9uZVwiKTtcblxuICAgICAgICAkYmxvY2suZmluZChcIi5ibG9jay1vdXRwdXRcIikuYWRkQ2xhc3MoXCJzaG93XCIpO1xuICAgICAgICAkYmxvY2suZmluZChcIi5ibG9jay1vdXRwdXRcIikucmVtb3ZlQ2xhc3MoXCJkLW5vbmVcI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gICAgICAgICAgbGFuZ3VhZ2U6IGxhbmd1YWdlTmFtZSxcbiAgICAgICAgICB2YWx1ZTogZXNjYXBlKGNvZGVUb0hpZ2hsaWdodCksXG4gICAgICAgICAgaWxsZWdhbDogdHJ1ZSxcbiAgICAgICAgICByZWxldmFuY2U6IDAsXG4gICAgICAgICAgX2lsbGVnYWxCeToge1xuICAgICAgICAgICAgbWVzc2FnZTogZXJyLm1lc3NhZ2UsXG4gICAgICAgICAgICBpbmRleCxcbiAgICAgICAgICAgIGNvbnRleHQ6IGNvZGVUb0hpZ2hsaWdodC5zbGljZShpbmRleCAtIDEwMCwgaW5kZXggKyAxMDApLFxuICAgICAgICAgICAgbW9kZTogZXJyLm1vZGUsXG4gICAgICAgICAgICByZXN1bHRTb0ZhcjogcmVzdWx0XG4gICAgICAgICAgfSxcbiAgICAgICAgICBfZW1pdHRlcjogZW1pdHRlclxuICAgICAgICB9O1xuICAgICAgfSBlbHNlIGlmIChTQUZFX01PREUpIHtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICBsYW5ndWFnZTogbGFuZ3VhZ2VOYW1lLFxuICAgICAgICAgIHZhbHVlOiBlc2NhcGUoY29kZVRvSGlnaGxpZ2h0KSxcbiAgICAgICAgICBpbGxlZ2FsOiBmYWxzZSxcbiAgICAgICAgICByZWxldmFuY2U6IDAsXG4gICAgICAgICAgZXJyb3JSYWlzZWQ6IGVycixcbiAgICAgICAgICBfZW1pdHRlcjogZW1pdHRlcixcbiAgICAgICAgICBfdG9wOiB0b3BcbiAgICAgICAgfTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHRocm93IGVycjtcbiAgICAgIH1cbiAgICB9XG4gIH1cblxuICAvKipcbiAgICogcmV0dXJucyBhIHZhbGlkIGhpZ2hsaWdodCByZXN1bHQsIHdpdGhvdXQgYWN0dWFsbHkgZG9pbmcgYW55IGFjdHVhbCB3b3JrLFxuICAgKiBhdXRvIGhpZ2hsaWdodCBzdGFydHMgd2l0aCB0a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0sXG5cbiAgICBjb250YWluczogW1xuICAgICAgLy8gUm94eWdlbiBjb21tZW50c1xuICAgICAgaGxqcy5DT01NRU5UKFxuICAgICAgICAvIycvLFxuICAgICAgICAvJC8sXG4gICAgICAgIHsgY29udGFpbnM6IFtcbiAgICAgICAgICB7XG4gICAgICAgICAgICAvLyBIYW5kbGUgYEBleGFtcGxlc2Agc2VwYXJhdGVseSB0byBjYXVzZSBhbGwgc3Vic2VxdWVudCBjb2RlXG4gICAgICAgICAgICAvLyB1bnRpbCB0aGUgbmV4dCBgQGAtdGFnIG9uIGl0cyBvd24gbGluZSB0byBiZSBrZXB0IGFzLWlzLFxuICAgICAgICAgICAgLy8gcHJldmVudGluZyBoaWdobGlnaHRpbmcuIFRoaXMgY29kZSBpcyBleGFtcGxlIFIgY29kZSwgc28gbmVzdGVkXG4gICAgICAgICAgICAvLyBkb2N0YWdzIHNob3VsZG7igJl0IGJlIHRyZWF0ZWQgYXMgc3VjaC4gU2VlXG4gICAgICAgICAgICAvLyBgdGVzdC9tYXJrdXAvci9yb3h5Z2VuLnR4dGAgZm9yIGFuIGV4YW1wbGUuXG4gICAgICAgICAgICBzY29wZTogJ2RvY3RhZycsXG4gICAgICAgICAgICBtYXRjaDogL0BleGFtcGxlcy8sXG4gICAgICAgICAgICBzdGFydHM6IHtcbiAgICAgICAgICAgICAgZW5kOiByZWdleC5sb29rYWhlYWQocmVnZXguZWl0aGVyKFxuICAgICAgICAgICAgICAgIC8vIGVuZCBpZiBhbm90aGVyIGRvYyBjb21tZW50XG4gICAgICAgICAgICAgICAgL1xcbl4jJ1xccyooPz1AW2EtekEtWl0rKS8sXG4gICAgICAgICAgICAgICAgLy8gb3IgYSBsaW5lIHdpdGggbm8gY29tbWVudFxuICAgICAgICAgICAgICAgIC9cXG5eKD8hIycpL1xuICAgICAgICAgICAgICApKSxcbiAgICAgICAgICAgICAgZW5kc1BhcmVudDogdHJ1ZVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAge1xuICAgICAgICAgICAgLy8gSGFuZGxlIGBAcGFyYW1gIHRvIGhpZ2hsaWdodCB0aGUgcGFyYW1ldGVyIG5hbWUgZm9sbG93aW5nXG4gICAgICAgICAgICAvLyBhZnRlci5cbiAgICAgICAgICAgIHNjb3BlOiAnZG9jdGFnJyxcbiAgICAgICAgICAgIGJlZ2luOiAnQHBhcmFtJyxcbiAgICAgICAgICAgIGVuZDogLyQvLFxuICAgICAgICAgICAgY29udGFpbnM6IFtcbiAgICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgIHNjb3BlOiAndmFyaWFibGUnLFxuICAgICAgICAgICAgICAgIHZhcmlhbnRzOiBbXG4gICAgICAgICAgICAgICAgICB7IG1hdGNoOiBJREVOVF9SRSB9LFxuICAgICAgICAgICAgICAgICAgeyBtYXRjaDogL2AoPzpcXFxcLnxbXmBcXFxcXSkrYC8gfVxuICAgICAgICAgICAgICAgIF0sXG4gICAgICAgICAgICAgICAgZW5kc1BhcmVudDogdHJ1ZVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICBdXG4gICAgICAgICAgfSxcbiAgICAgICAgICB7XG4gICAgICAgICAgICBzY29wZTogJ2RvY3RhZycsXG4gICAgICAgICAgICBtYXRjaDogL0BbYS16QS1aXSsvXG4gICAgICAgICAgfSxcbiAgICAgICAgICB7XG4gICAgICAgICAgICBzY29wZTogJ2tleXdvcmQnLFxuICAgICAgICAgICAgbWF0Y2g6IC9cXFxcW2EtekEtWl0rL1xuICAgICAgICAgIH1cbiAgICAgICAgXSB9XG4gICAgICApLFxuXG4gICAgICBobGpzLkhBU0hfQ09NTUVOVF9NT0RFLFxuXG4gICAgICB7XG4gICAgICAgIHNjb3BlOiAnc3RyaW5nJyxcbiAgICAgICAgY29udGFpbnM6IFsgaGxqcy5CQUNLU0xBU0hfRVNDQVBFIF0sXG4gICAgICAgIHZhcmlhbnRzOiBbXG4gICAgICAgICAgaGxqcy5FTkRfU0FNRV9BU19CRUdJTih7XG4gICAgICAgICAgICBiZWdpbjogL1tyUl1cIigtKilcXCgvLFxuICAgICAgICAgICAgZW5kOiAvXFwpKC0qKVwiL1xuICAgICAgICAgIH0pLFxuICAgICAgICAgIGhsanMuRU5EX1NBTUVfQVNfQkVHSU4oe1xuICAgICAgICAgICAgYmVnaW46IC9bclJdXCIoLSopXFx7LyxcbiAgICAgICAgICAgIGVuZDogL1xcfSgtKilcIi9cbiAgICAgICAgICB9KSxcbiAgICAgICAgICBobGpzLkVORF9TQU1FX0FTX0JFR0lOKHtcbiAgICAgICAgICAgIGJlZ2luOiAvW3JSXVwiKC0qKVxcWy8sXG4gICAgICAgICAgICBlbmQ6IC9cXF0oLSopXCIvXG4gICAgICAgICAgfSksXG4gICAgICAgICAgaGxqcy5FTkRfU0FNRV9BU19CRUdJTih7XG4gICAgICAgICAgICBiZWdpbjogL1tyUl0nKC0qKVxcKC8sXG4gICAgICAgICAgICBlbmQ6IC9cXCkoLSopJy9cbiAgICAgICAgICB9KSxcbiAgICAgICAgICBobGpzLkVORF9TQU1FX0FTX0JFR0lOKHtcbiAgICAgICAgICAgIGJlZ2luOiAvW3JSXScoLSopXFx7LyxcbiAgICAgICAgICAgIGVuZDogL1xcfSgtKiknL1xuICAgICAgICAgIH0pLFxuICAgICAgICAgIGhsanMuRU5EX1NBTUVfQVNfQkVHSU4oe1xuICAgICAgICAgICAgYmVnaW46IC9bclJdJygtKilcXFsvLFxuICAgICAgICAgICAgZW5kOiAvXFxdKC0qKScvXG4gICAgICAgICAgfSksXG4gICAgICAgICAge1xuICAgICAgICAgICAgYmVnaW46ICdcIicsXG4gICAgICAgICAgICBlbmQ6ICdcIicsXG4gICAgICAgICAgICByZWxldmFuY2U6IDBcbiAgICAgICAgICB9LFxuICAgICAgICAgIHtcbiAgICAgICAgICAgIGJlZ2luOiBcIidcIixcbiAgICAgICAgICAgIGVuZDogXCInXCIsXG4gICAgICAgICAgICByZWxldmFuY2U6IDBcbiAgICAgICAgICB9XG4gICAgICAgIF0sXG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hdG9yJyxcbiAgICAgICAgICAgICAgMjogJ251bWJlcidcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBtYXRjaDogW1xuICAgICAgICAgICAgICBPUEVSQVRPUlNfUkUsXG4gICAgICAgICAgICAgIE5VTUJFUl9UWVBFU19SRVxuICAgICAgICAgICAgXVxuICAgICAgICAgIH0sXG4gICAgICAgICAge1xuICAgICAgICAgICAgc2NvcGU6IHtcbiAgICAgICAgICAgICAgMTogJ29wZXJhdG9yJyxcbiAgICAgICAgICAgICAgMjogJ251bWJlcidcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBtYXRjaDogW1xuICAgICAgICAgICAgICAvJVteJV0qJS8sXG4gICAgICAgICAgICAgIE5VTUJFUl9UWVBFU19SRVxuICAgICAgICAgICAgXVxuICAgICAgICAgIH0sXG4gICAgICAgICAge1xuICAgICAgICAgICAgc2NvcGU6IHtcbiAgICAgICAgICAgICAgMTogJ3B1bmN0dWF0aW9uJyxcbiAgICAgICAgICAgICAgMjogJ251bWJlcidcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBtYXRjaDogW1xuICAgICAgICAgICAgICBQVU5DVFVBVElPTl9SRSxcbiAgICAgICAgICAgICAgTlVNQkVSX1RZUEVTX1JFXG4gICAgICAgICAgICBdXG4gICAgICAgICAgfSxcbiAgICAgICAgICB7XG4gICAgICAgICAgICBzY29wZTogeyAyOiAnbnVtYmVyJyB9LFxuICAgICAgICAgICAgbWF0Y2g6IFtcbiAgICAgICAgICAgICAgL1teYS16QS1aMC05Ll9dfF4vLCAvLyBub3QgcGFydCBvZiBhbiBpZGVudGlmaWVyLCBvciBzdGFydCBvZiBkb2N1bWVudFxuICAgICAgICAgICAgICBOVU1CRVJfVFlQRVNfUkVcbiAgICAgICAgICAgIF1cbiAgICAgICAgICB9XG4gICAgICAgIF1cbiAgICAgIH0sXG5cbiAgICAgIC8vIE9wZXJhdG9ycy9wdW5jdHVhdGlvbiB3aGVuIHRoZXkncmUgbm90IGRpcmVjdGx5IGZvbGxvd2VkIGJ5IG51bWJlcnNcbiAgICAgIHtcbiAgICAgICAgLy8gUmVsZXZhbmNlIGJvb3N0IGZvciB0aGUgbW9zdCBjb21tb24gYXNzaWdubWVudCBmb3JtLlxuICAgICAgICBzY29wZTogeyAzOiAnb3BlcmF0b3InIH0sXG4gICAgICAgIG1hdGNoOiBbXG4gICAgICAgICAgSURFTlRfUkUsXG4gICAgICAgICAgL1xccysvLFxuICAgICAgICAgIC88LS8sXG4gICAgICAgICAgL1xccysvXG4gICAgICAgIF1cbiAgICAgIH0sXG5cbiAgICAgIHtcbiAgICAgICAgc2NvcGU6ICdvcGVyYXRvcicsXG4gICAgICAgIHJlbGV2YW5jZTogMCxcbiAgICAgICAgdmFyaWFudHM6IFtcbiAgICAgICAgICB7IG1hdGNoOiBPUEVSQVRPUlNfUkUgfSxcbiAgICAgICAgICB7IG1hdGNoOiAvJVteJV0qJS8gfVxuICAgICAgICBdXG4gICAgICB9LFxuXG4gICAgICB7XG4gICAgICAgIHNjb3BlOiAncHVuY3R1YXRpb24nLFxuICAgICAgICByZWxldmFuY2U6IDAsXG4gICAgICAgIG1hdGNoOiBQVU5DVFVBVElPTl9SRVxuICAgICAgfSxcblxuICAgICAge1xuICAgICAgICAvLyBFc2NhcGVkIGlkZW50aWZpZXJcbiAgICAgICAgYmVnaW46ICdgJyxcbiAgICAgICAgZW5kOiAnYCcsXG4gICAgICAgIGNvbnRhaW5zOiBbIHsgYmVnaW46IC9cXFxcLi8gfSBdXG4gICAgICB9XG4gICAgXVxuICB9O1xufVxuXG5leHBvcnQgeyByIGFzIGRlZmF1bHQgfTtcbiIsIi8vIFRoZSBtb2R1bGUgY2FjaGVcbnZhciBfX3dlYnBhY2tfbW9kdWxlX2NhY2hlX18gPSB7fTtcblxuLy8gVGhlIHJlcXVpcmUgZnVuY3Rpb25cbmZ1bmN0aW9uIF9fd2VicGFja19yZXF1aXJlX18obW9kdWxlSWQpIHtcblx0Ly8gQ2hlY2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XCI7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0= \ No newline at end of file diff --git a/makefile b/makefile index c98b1028..afc1a902 100644 --- a/makefile +++ b/makefile @@ -13,9 +13,12 @@ bundle_dev: sass install: check Rscript -e "devtools::install()" -sass: +sass: style Rscript dev/sass.R +style: + Rscript -e "styler::style_pkg()" + run: bundle_dev Rscript test.R diff --git a/test.R b/test.R index 3a72f356..a8c75b0c 100644 --- a/test.R +++ b/test.R @@ -4,7 +4,7 @@ library(shiny) stack <- new_stack( demo_data_block, - demo_join_block + demo_select_block ) ui <- fluidPage( diff --git a/tests/testthat/test-block.R b/tests/testthat/test-block.R index 092d2525..fee0dac9 100644 --- a/tests/testthat/test-block.R +++ b/tests/testthat/test-block.R @@ -1,7 +1,6 @@ library(dplyr) library(blockr.data) test_that("data blocks", { - block <- data_block() expect_s3_class(block, "data_block") @@ -18,7 +17,6 @@ test_that("data blocks", { }) test_that("filter blocks", { - data <- datasets::iris block <- filter_block(data) @@ -38,7 +36,6 @@ test_that("filter blocks", { }) test_that("select blocks", { - data <- datasets::iris block <- select_block(data) @@ -54,7 +51,6 @@ test_that("select blocks", { }) test_that("arrange blocks", { - data <- datasets::iris min_sepal_len <- min(data$Sepal.Length) @@ -71,7 +67,6 @@ test_that("arrange blocks", { }) test_that("group_by blocks", { - data <- datasets::iris block <- group_by_block(data, columns = "Species") diff --git a/tests/testthat/test-field.R b/tests/testthat/test-field.R index 87473dc3..dcd3b602 100644 --- a/tests/testthat/test-field.R +++ b/tests/testthat/test-field.R @@ -1,5 +1,4 @@ test_that("string fields", { - field <- string_field("foo") expect_s3_class(field, "string_field") @@ -14,7 +13,6 @@ test_that("string fields", { }) test_that("select fields", { - field <- select_field("a", letters) expect_s3_class(field, "select_field") @@ -35,7 +33,6 @@ test_that("select fields", { }) test_that("range fields", { - field <- range_field(min = 0, max = 10) expect_s3_class(field, "range_field") @@ -44,7 +41,6 @@ test_that("range fields", { }) test_that("numeric fields", { - field <- numeric_field(min = 0, max = 10) expect_s3_class(field, "numeric_field") diff --git a/tests/testthat/test-stack.R b/tests/testthat/test-stack.R index e2a84806..8287e53b 100644 --- a/tests/testthat/test-stack.R +++ b/tests/testthat/test-stack.R @@ -1,5 +1,4 @@ test_that("stacks", { - stack <- new_stack( new_data_block, new_filter_block From c899a35983abf9acf922ccbfad9ec4794521136b Mon Sep 17 00:00:00 2001 From: John Coene Date: Fri, 27 Oct 2023 18:10:16 +0200 Subject: [PATCH 2/3] feat: hide inputs improved + added feedback fixes #61 --- NAMESPACE | 8 +- R/server.R | 24 + R/ui.R | 52 +- inst/assets/index.js | 3239 +------------------------------------ inst/assets/style.min.css | 2 +- man/generate_ui.Rd | 16 +- man/new_block.Rd | 2 +- scss/_block.scss | 4 + srcjs/collapse.js | 55 +- srcjs/shiny.js | 1 - test.R | 2 +- 11 files changed, 123 insertions(+), 3282 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 2e4f188f..dee23f5b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -29,9 +29,9 @@ S3method(server_output,block) S3method(server_output,ggiraph_block) S3method(server_output,plot_block) S3method(uiCode,block) -S3method(uiOutput,block) -S3method(uiOutput,ggiraph_block) -S3method(uiOutput,plot_block) +S3method(uiOutputBlock,block) +S3method(uiOutputBlock,ggiraph_block) +S3method(uiOutputBlock,plot_block) S3method(ui_input,hidden_field) S3method(ui_input,list_field) S3method(ui_input,numeric_field) @@ -126,7 +126,7 @@ export(string_field) export(summarize_block) export(switch_field) export(uiCode) -export(uiOutput) +export(uiOutputBlock) export(ui_input) export(ui_update) export(update_field) diff --git a/R/server.R b/R/server.R index e3f63a54..3c81a58e 100644 --- a/R/server.R +++ b/R/server.R @@ -53,6 +53,14 @@ generate_server.data_block <- function(x, id, ...) { output$res <- server_output(x, out_dat, output) output$code <- server_code(x, blk, output) + output$nrow <- renderText({ + prettyNum(nrow(out_dat()), big.mark = ",") + }) + + output$ncol <- renderText({ + prettyNum(ncol(out_dat()), big.mark = ",") + }) + # Cleanup module inputs (UI and server side) # and observer observeEvent(input$remove, @@ -117,6 +125,14 @@ generate_server.transform_block <- function(x, in_dat, id, ...) { output$res <- server_output(x, out_dat, output) output$code <- server_code(x, blk, output) + output$nrow <- renderText({ + prettyNum(nrow(out_dat()), big.mark = ",") + }) + + output$ncol <- renderText({ + prettyNum(ncol(out_dat()), big.mark = ",") + }) + # Cleanup module inputs (UI and server side) # and observer observeEvent(input$remove, { @@ -167,6 +183,14 @@ generate_server.plot_block <- function(x, in_dat, id, ...) { output$plot <- server_output(x, out_dat, output) output$code <- server_code(x, blk, output) + output$nrow <- renderText({ + prettyNum(nrow(out_dat()), big.mark = ",") + }) + + output$ncol <- renderText({ + prettyNum(ncol(out_dat()), big.mark = ",") + }) + # Cleanup module inputs (UI and server side) # and observer observeEvent(input$remove, { diff --git a/R/ui.R b/R/ui.R index 25042615..f63bd714 100644 --- a/R/ui.R +++ b/R/ui.R @@ -29,7 +29,7 @@ generate_ui.block <- function(x, id, ..., .hidden = TRUE) { code_id <- ns("codeCollapse") output_id <- ns("outputCollapse") - header <- block_title(x, code_id, output_id, ns) + header <- block_title(x, code_id, output_id, ns, .hidden) block_class <- "block" if (.hidden) { @@ -51,9 +51,9 @@ generate_ui.block <- function(x, id, ..., .hidden = TRUE) { class = "card shadow-sm p-2 mb-2 border", shiny::div( class = "card-body p-1", + header, div( class = sprintf("block-inputs %s", inputs_hidden), - header, layout(fields) ), div( @@ -62,9 +62,9 @@ generate_ui.block <- function(x, id, ..., .hidden = TRUE) { uiCode(x, ns) ), div( - class = "collapse block-output", + class = "d-none block-output", id = output_id, - uiOutput(x, ns) + uiOutputBlock(x, ns) ) ) ) @@ -136,21 +136,38 @@ generate_ui.stack <- function(x, id = NULL, ...) { } #' @importFrom shiny tags div -block_title <- function(block, code_id, output_id, ns) { +block_title <- function(block, code_id, output_id, ns, .hidden) { + hidden_class <- "" + if (.hidden) { + hidden_class <- "d-none" + } + title <- class(block)[1] |> (\(.) gsub("_.*$", "", .))() |> tools::toTitleCase() div( - class = "card-title", + class = sprintf("m-0 card-title block-title %s", hidden_class), div( class = "d-flex", - if (not_null(title)) { - div( - class = "flex-grow-1", - shiny::p(title, class = "fw-bold") + div( + class = "flex-grow-1", + shiny::p( + title, + class = "fw-bold" ) - }, + ), + div( + class = "flex-grow-1", + span( + class = "block-feedback text-muted", + span(textOutput(ns("nrow"), inline = TRUE), class = "fw-bold"), + "rows |", + class = "block-feedback text-muted", + span(textOutput(ns("ncol"), inline = TRUE), class = "fw-bold"), + "cols" + ) + ), div( class = "flex-shrink-1", actionLink( @@ -168,10 +185,7 @@ block_title <- function(block, code_id, output_id, ns) { ), tags$a( class = "text-decoration-none block-output-toggle", - `data-bs-toggle` = "collapse", href = sprintf("#%s", output_id), - `aria-expanded` = "false", - `aria-controls` = output_id, iconOutput() ) ) @@ -452,25 +466,25 @@ custom_verbatim_output <- function(id) { #' @param ns Output namespace #' @rdname generate_ui #' @export -uiOutput <- function(x, ns) { - UseMethod("uiOutput", x) +uiOutputBlock <- function(x, ns) { + UseMethod("uiOutputBlock", x) } #' @rdname generate_ui #' @export -uiOutput.block <- function(x, ns) { +uiOutputBlock.block <- function(x, ns) { DT::dataTableOutput(ns("res")) } #' @rdname generate_ui #' @export -uiOutput.plot_block <- function(x, ns) { +uiOutputBlock.plot_block <- function(x, ns) { shiny::plotOutput(ns("plot")) } #' @rdname generate_ui #' @export -uiOutput.ggiraph_block <- function(x, ns) { +uiOutputBlock.ggiraph_block <- function(x, ns) { ggiraph::girafeOutput(ns("plot")) } diff --git a/inst/assets/index.js b/inst/assets/index.js index 0773b248..81070acc 100644 --- a/inst/assets/index.js +++ b/inst/assets/index.js @@ -1,3238 +1 @@ -/******/ (() => { // webpackBootstrap -/******/ var __webpack_modules__ = ({ - -/***/ "./srcjs/collapse.js": -/*!***************************!*\ - !*** ./srcjs/collapse.js ***! - \***************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ collapse: () => (/* binding */ collapse), -/* harmony export */ showLastOutput: () => (/* binding */ showLastOutput) -/* harmony export */ }); -const collapse = (stack) => { - editor(stack); - showLastOutputs(stack); -}; - -const editor = (stack) => { - const editBtn = $(stack).find(".stack-edit-toggle"); - - // already has a listener - if (editBtn[0].getAttribute("listener")) { - return; - } - - $(editBtn).on("click", (event) => { - const $stack = $(event.target).closest(".stack"); - const $blocks = $stack.find(".block"); - - $(event.currentTarget).toggleClass("etidable"); - const editable = $(event.currentTarget).hasClass("etidable"); - - $blocks.each((index, block) => { - const $block = $(block); - - if (editable) { - $block.removeClass("d-none"); - $block.find(".block-inputs").removeClass("d-none"); - $block.find(".block-inputs").trigger("shown"); - - if (index == ($blocks.length - 1)) { - $block.find(".block-output").addClass("show"); - $block.find(".block-output").removeClass("d-none"); - $block.find(".block-output").trigger("shown"); - } - return; - } - - $block.find(".block-inputs").addClass("d-none"); - $block.find(".block-inputs").trigger("hidden"); - - if (index == ($blocks.length - 1)) { - $block.removeClass("d-none"); - - $block.find(".block-output").addClass("show"); - $block.find(".block-output").removeClass("d-none"); - $block.find(".block-output").trigger("shown"); - return; - } - - $block.addClass("d-none"); - }); - }); -}; - -const showLastOutput = (el) => { - const $block = $(el).find(".block").last(); - - $block.removeClass("d-none"); - const lastOutput = $block.find(".block-output"); - - bootstrap.Collapse.getOrCreateInstance(lastOutput, { toggle: false }).show(); - $(lastOutput).trigger("shown"); -}; - -const showLastOutputs = (stack) => { - $(stack).each((_, el) => { - showLastOutput(el); - }); -}; - - -/***/ }), - -/***/ "./srcjs/copy.js": -/*!***********************!*\ - !*** ./srcjs/copy.js ***! - \***********************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ copyCode: () => (/* binding */ copyCode) -/* harmony export */ }); -const copy = (el) => { - navigator.clipboard.writeText($(el).text()); -}; - -const copyCode = () => { - $(".block-copy-code").each((_index, btn) => { - // TODO bind selectively instead of reset - $(btn).off("click"); - - $(btn).on("click", (event) => { - const code = $(event.target).closest("div").find("pre"); - copy(code); - }); - }); - - $(".stack-copy-code").each((_index, btn) => { - // TODO bind selectively instead of reset - $(btn).off("click"); - - $(btn).on("click", (event) => { - const $codes = $(event.target).closest(".stack").find("pre"); - let code = []; - $codes.each((_index, c) => { - code.push($(c).text()); - }); - code = code.join(" |>\n"); - navigator.clipboard.writeText(code); - }); - }); -}; - - -/***/ }), - -/***/ "./srcjs/hl.js": -/*!*********************!*\ - !*** ./srcjs/hl.js ***! - \*********************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var highlight_js_lib_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! highlight.js/lib/core */ "./node_modules/highlight.js/es/core.js"); -/* harmony import */ var highlight_js_lib_languages_r__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! highlight.js/lib/languages/r */ "./node_modules/highlight.js/es/languages/r.js"); - - - -highlight_js_lib_core__WEBPACK_IMPORTED_MODULE_0__["default"].registerLanguage("r", highlight_js_lib_languages_r__WEBPACK_IMPORTED_MODULE_1__["default"]); - -$(() => { - $(document).on("shiny:value", (e) => { - if (!e.name.match(/-code$/)) { - return; - } - - $(`#${e.name}`).addClass("language-r"); - setTimeout(() => { - highlight_js_lib_core__WEBPACK_IMPORTED_MODULE_0__["default"].highlightElement(document.getElementById(e.name)); - }, 250); - }); -}); - - -/***/ }), - -/***/ "./srcjs/remove-stack.js": -/*!*******************************!*\ - !*** ./srcjs/remove-stack.js ***! - \*******************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ remove: () => (/* binding */ remove) -/* harmony export */ }); -const remove = (stack) => { - $(stack).find(".stack-remove").each((_, btn) => { - // already has a listener - if (btn.getAttribute("listener") == "true") { - return; - } - - $(btn).on("click", (event) => { - const $stack = $(event.target).closest(".stack"); - const $masonry = $stack.closest(".masonry-item"); - - $stack.remove(); - - if ($masonry.length === 0) { - return; - } - - $masonry.remove(); - }); - }); -}; - - -/***/ }), - -/***/ "./srcjs/shiny.js": -/*!************************!*\ - !*** ./srcjs/shiny.js ***! - \************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _collapse_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collapse.js */ "./srcjs/collapse.js"); -/* harmony import */ var _remove_stack_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./remove-stack.js */ "./srcjs/remove-stack.js"); -/* harmony import */ var _copy_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./copy.js */ "./srcjs/copy.js"); - - - - -Shiny.addCustomMessageHandler("blockr-bind-stack", (msg) => { - const stack = `#${msg.stack}`; - setTimeout(() => { - (0,_remove_stack_js__WEBPACK_IMPORTED_MODULE_1__.remove)(stack); - (0,_collapse_js__WEBPACK_IMPORTED_MODULE_0__.collapse)(stack); - (0,_copy_js__WEBPACK_IMPORTED_MODULE_2__.copyCode)(); - }, 750); -}); - -Shiny.addCustomMessageHandler("blockr-add-block", (msg) => { - const stack = `#${msg.stack}`; - // TODO remove this - // be event based/async instead of timeout - setTimeout(() => { - (0,_collapse_js__WEBPACK_IMPORTED_MODULE_0__.showLastOutput)(stack); - (0,_copy_js__WEBPACK_IMPORTED_MODULE_2__.copyCode)(); - }, 500); -}); - - -/***/ }), - -/***/ "shiny": -/*!************************!*\ - !*** external "Shiny" ***! - \************************/ -/***/ ((module) => { - -"use strict"; -module.exports = Shiny; - -/***/ }), - -/***/ "./node_modules/highlight.js/lib/core.js": -/*!***********************************************!*\ - !*** ./node_modules/highlight.js/lib/core.js ***! - \***********************************************/ -/***/ ((module) => { - -/* eslint-disable no-multi-assign */ - -function deepFreeze(obj) { - if (obj instanceof Map) { - obj.clear = - obj.delete = - obj.set = - function () { - throw new Error('map is read-only'); - }; - } else if (obj instanceof Set) { - obj.add = - obj.clear = - obj.delete = - function () { - throw new Error('set is read-only'); - }; - } - - // Freeze self - Object.freeze(obj); - - Object.getOwnPropertyNames(obj).forEach((name) => { - const prop = obj[name]; - const type = typeof prop; - - // Freeze prop if it is an object or function and also not already frozen - if ((type === 'object' || type === 'function') && !Object.isFrozen(prop)) { - deepFreeze(prop); - } - }); - - return obj; -} - -/** @typedef {import('highlight.js').CallbackResponse} CallbackResponse */ -/** @typedef {import('highlight.js').CompiledMode} CompiledMode */ -/** @implements CallbackResponse */ - -class Response { - /** - * @param {CompiledMode} mode - */ - constructor(mode) { - // eslint-disable-next-line no-undefined - if (mode.data === undefined) mode.data = {}; - - this.data = mode.data; - this.isMatchIgnored = false; - } - - ignoreMatch() { - this.isMatchIgnored = true; - } -} - -/** - * @param {string} value - * @returns {string} - */ -function escapeHTML(value) { - return value - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); -} - -/** - * performs a shallow merge of multiple objects into one - * - * @template T - * @param {T} original - * @param {Record[]} objects - * @returns {T} a single new object - */ -function inherit$1(original, ...objects) { - /** @type Record */ - const result = Object.create(null); - - for (const key in original) { - result[key] = original[key]; - } - objects.forEach(function(obj) { - for (const key in obj) { - result[key] = obj[key]; - } - }); - return /** @type {T} */ (result); -} - -/** - * @typedef {object} Renderer - * @property {(text: string) => void} addText - * @property {(node: Node) => void} openNode - * @property {(node: Node) => void} closeNode - * @property {() => string} value - */ - -/** @typedef {{scope?: string, language?: string, sublanguage?: boolean}} Node */ -/** @typedef {{walk: (r: Renderer) => void}} Tree */ -/** */ - -const SPAN_CLOSE = ''; - -/** - * Determines if a node needs to be wrapped in - * - * @param {Node} node */ -const emitsWrappingTags = (node) => { - // rarely we can have a sublanguage where language is undefined - // TODO: track down why - return !!node.scope; -}; - -/** - * - * @param {string} name - * @param {{prefix:string}} options - */ -const scopeToCSSClass = (name, { prefix }) => { - // sub-language - if (name.startsWith("language:")) { - return name.replace("language:", "language-"); - } - // tiered scope: comment.line - if (name.includes(".")) { - const pieces = name.split("."); - return [ - `${prefix}${pieces.shift()}`, - ...(pieces.map((x, i) => `${x}${"_".repeat(i + 1)}`)) - ].join(" "); - } - // simple scope - return `${prefix}${name}`; -}; - -/** @type {Renderer} */ -class HTMLRenderer { - /** - * Creates a new HTMLRenderer - * - * @param {Tree} parseTree - the parse tree (must support `walk` API) - * @param {{classPrefix: string}} options - */ - constructor(parseTree, options) { - this.buffer = ""; - this.classPrefix = options.classPrefix; - parseTree.walk(this); - } - - /** - * Adds texts to the output stream - * - * @param {string} text */ - addText(text) { - this.buffer += escapeHTML(text); - } - - /** - * Adds a node open to the output stream (if needed) - * - * @param {Node} node */ - openNode(node) { - if (!emitsWrappingTags(node)) return; - - const className = scopeToCSSClass(node.scope, - { prefix: this.classPrefix }); - this.span(className); - } - - /** - * Adds a node close to the output stream (if needed) - * - * @param {Node} node */ - closeNode(node) { - if (!emitsWrappingTags(node)) return; - - this.buffer += SPAN_CLOSE; - } - - /** - * returns the accumulated buffer - */ - value() { - return this.buffer; - } - - // helpers - - /** - * Builds a span element - * - * @param {string} className */ - span(className) { - this.buffer += ``; - } -} - -/** @typedef {{scope?: string, language?: string, children: Node[]} | string} Node */ -/** @typedef {{scope?: string, language?: string, children: Node[]} } DataNode */ -/** @typedef {import('highlight.js').Emitter} Emitter */ -/** */ - -/** @returns {DataNode} */ -const newNode = (opts = {}) => { - /** @type DataNode */ - const result = { children: [] }; - Object.assign(result, opts); - return result; -}; - -class TokenTree { - constructor() { - /** @type DataNode */ - this.rootNode = newNode(); - this.stack = [this.rootNode]; - } - - get top() { - return this.stack[this.stack.length - 1]; - } - - get root() { return this.rootNode; } - - /** @param {Node} node */ - add(node) { - this.top.children.push(node); - } - - /** @param {string} scope */ - openNode(scope) { - /** @type Node */ - const node = newNode({ scope }); - this.add(node); - this.stack.push(node); - } - - closeNode() { - if (this.stack.length > 1) { - return this.stack.pop(); - } - // eslint-disable-next-line no-undefined - return undefined; - } - - closeAllNodes() { - while (this.closeNode()); - } - - toJSON() { - return JSON.stringify(this.rootNode, null, 4); - } - - /** - * @typedef { import("./html_renderer").Renderer } Renderer - * @param {Renderer} builder - */ - walk(builder) { - // this does not - return this.constructor._walk(builder, this.rootNode); - // this works - // return TokenTree._walk(builder, this.rootNode); - } - - /** - * @param {Renderer} builder - * @param {Node} node - */ - static _walk(builder, node) { - if (typeof node === "string") { - builder.addText(node); - } else if (node.children) { - builder.openNode(node); - node.children.forEach((child) => this._walk(builder, child)); - builder.closeNode(node); - } - return builder; - } - - /** - * @param {Node} node - */ - static _collapse(node) { - if (typeof node === "string") return; - if (!node.children) return; - - if (node.children.every(el => typeof el === "string")) { - // node.text = node.children.join(""); - // delete node.children; - node.children = [node.children.join("")]; - } else { - node.children.forEach((child) => { - TokenTree._collapse(child); - }); - } - } -} - -/** - Currently this is all private API, but this is the minimal API necessary - that an Emitter must implement to fully support the parser. - - Minimal interface: - - - addText(text) - - __addSublanguage(emitter, subLanguageName) - - startScope(scope) - - endScope() - - finalize() - - toHTML() - -*/ - -/** - * @implements {Emitter} - */ -class TokenTreeEmitter extends TokenTree { - /** - * @param {*} options - */ - constructor(options) { - super(); - this.options = options; - } - - /** - * @param {string} text - */ - addText(text) { - if (text === "") { return; } - - this.add(text); - } - - /** @param {string} scope */ - startScope(scope) { - this.openNode(scope); - } - - endScope() { - this.closeNode(); - } - - /** - * @param {Emitter & {root: DataNode}} emitter - * @param {string} name - */ - __addSublanguage(emitter, name) { - /** @type DataNode */ - const node = emitter.root; - if (name) node.scope = `language:${name}`; - - this.add(node); - } - - toHTML() { - const renderer = new HTMLRenderer(this, this.options); - return renderer.value(); - } - - finalize() { - this.closeAllNodes(); - return true; - } -} - -/** - * @param {string} value - * @returns {RegExp} - * */ - -/** - * @param {RegExp | string } re - * @returns {string} - */ -function source(re) { - if (!re) return null; - if (typeof re === "string") return re; - - return re.source; -} - -/** - * @param {RegExp | string } re - * @returns {string} - */ -function lookahead(re) { - return concat('(?=', re, ')'); -} - -/** - * @param {RegExp | string } re - * @returns {string} - */ -function anyNumberOfTimes(re) { - return concat('(?:', re, ')*'); -} - -/** - * @param {RegExp | string } re - * @returns {string} - */ -function optional(re) { - return concat('(?:', re, ')?'); -} - -/** - * @param {...(RegExp | string) } args - * @returns {string} - */ -function concat(...args) { - const joined = args.map((x) => source(x)).join(""); - return joined; -} - -/** - * @param { Array } args - * @returns {object} - */ -function stripOptionsFromArgs(args) { - const opts = args[args.length - 1]; - - if (typeof opts === 'object' && opts.constructor === Object) { - args.splice(args.length - 1, 1); - return opts; - } else { - return {}; - } -} - -/** @typedef { {capture?: boolean} } RegexEitherOptions */ - -/** - * Any of the passed expresssions may match - * - * Creates a huge this | this | that | that match - * @param {(RegExp | string)[] | [...(RegExp | string)[], RegexEitherOptions]} args - * @returns {string} - */ -function either(...args) { - /** @type { object & {capture?: boolean} } */ - const opts = stripOptionsFromArgs(args); - const joined = '(' - + (opts.capture ? "" : "?:") - + args.map((x) => source(x)).join("|") + ")"; - return joined; -} - -/** - * @param {RegExp | string} re - * @returns {number} - */ -function countMatchGroups(re) { - return (new RegExp(re.toString() + '|')).exec('').length - 1; -} - -/** - * Does lexeme start with a regular expression match at the beginning - * @param {RegExp} re - * @param {string} lexeme - */ -function startsWith(re, lexeme) { - const match = re && re.exec(lexeme); - return match && match.index === 0; -} - -// BACKREF_RE matches an open parenthesis or backreference. To avoid -// an incorrect parse, it additionally matches the following: -// - [...] elements, where the meaning of parentheses and escapes change -// - other escape sequences, so we do not misparse escape sequences as -// interesting elements -// - non-matching or lookahead parentheses, which do not capture. These -// follow the '(' with a '?'. -const BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./; - -// **INTERNAL** Not intended for outside usage -// join logically computes regexps.join(separator), but fixes the -// backreferences so they continue to match. -// it also places each individual regular expression into it's own -// match group, keeping track of the sequencing of those match groups -// is currently an exercise for the caller. :-) -/** - * @param {(string | RegExp)[]} regexps - * @param {{joinWith: string}} opts - * @returns {string} - */ -function _rewriteBackreferences(regexps, { joinWith }) { - let numCaptures = 0; - - return regexps.map((regex) => { - numCaptures += 1; - const offset = numCaptures; - let re = source(regex); - let out = ''; - - while (re.length > 0) { - const match = BACKREF_RE.exec(re); - if (!match) { - out += re; - break; - } - out += re.substring(0, match.index); - re = re.substring(match.index + match[0].length); - if (match[0][0] === '\\' && match[1]) { - // Adjust the backreference. - out += '\\' + String(Number(match[1]) + offset); - } else { - out += match[0]; - if (match[0] === '(') { - numCaptures++; - } - } - } - return out; - }).map(re => `(${re})`).join(joinWith); -} - -/** @typedef {import('highlight.js').Mode} Mode */ -/** @typedef {import('highlight.js').ModeCallback} ModeCallback */ - -// Common regexps -const MATCH_NOTHING_RE = /\b\B/; -const IDENT_RE = '[a-zA-Z]\\w*'; -const UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*'; -const NUMBER_RE = '\\b\\d+(\\.\\d+)?'; -const C_NUMBER_RE = '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)'; // 0x..., 0..., decimal, float -const BINARY_NUMBER_RE = '\\b(0b[01]+)'; // 0b... -const RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~'; - -/** -* @param { Partial & {binary?: string | RegExp} } opts -*/ -const SHEBANG = (opts = {}) => { - const beginShebang = /^#![ ]*\//; - if (opts.binary) { - opts.begin = concat( - beginShebang, - /.*\b/, - opts.binary, - /\b.*/); - } - return inherit$1({ - scope: 'meta', - begin: beginShebang, - end: /$/, - relevance: 0, - /** @type {ModeCallback} */ - "on:begin": (m, resp) => { - if (m.index !== 0) resp.ignoreMatch(); - } - }, opts); -}; - -// Common modes -const BACKSLASH_ESCAPE = { - begin: '\\\\[\\s\\S]', relevance: 0 -}; -const APOS_STRING_MODE = { - scope: 'string', - begin: '\'', - end: '\'', - illegal: '\\n', - contains: [BACKSLASH_ESCAPE] -}; -const QUOTE_STRING_MODE = { - scope: 'string', - begin: '"', - end: '"', - illegal: '\\n', - contains: [BACKSLASH_ESCAPE] -}; -const PHRASAL_WORDS_MODE = { - begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/ -}; -/** - * Creates a comment mode - * - * @param {string | RegExp} begin - * @param {string | RegExp} end - * @param {Mode | {}} [modeOptions] - * @returns {Partial} - */ -const COMMENT = function(begin, end, modeOptions = {}) { - const mode = inherit$1( - { - scope: 'comment', - begin, - end, - contains: [] - }, - modeOptions - ); - mode.contains.push({ - scope: 'doctag', - // hack to avoid the space from being included. the space is necessary to - // match here to prevent the plain text rule below from gobbling up doctags - begin: '[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)', - end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/, - excludeBegin: true, - relevance: 0 - }); - const ENGLISH_WORD = either( - // list of common 1 and 2 letter words in English - "I", - "a", - "is", - "so", - "us", - "to", - "at", - "if", - "in", - "it", - "on", - // note: this is not an exhaustive list of contractions, just popular ones - /[A-Za-z]+['](d|ve|re|ll|t|s|n)/, // contractions - can't we'd they're let's, etc - /[A-Za-z]+[-][a-z]+/, // `no-way`, etc. - /[A-Za-z][a-z]{2,}/ // allow capitalized words at beginning of sentences - ); - // looking like plain text, more likely to be a comment - mode.contains.push( - { - // TODO: how to include ", (, ) without breaking grammars that use these for - // comment delimiters? - // begin: /[ ]+([()"]?([A-Za-z'-]{3,}|is|a|I|so|us|[tT][oO]|at|if|in|it|on)[.]?[()":]?([.][ ]|[ ]|\))){3}/ - // --- - - // this tries to find sequences of 3 english words in a row (without any - // "programming" type syntax) this gives us a strong signal that we've - // TRULY found a comment - vs perhaps scanning with the wrong language. - // It's possible to find something that LOOKS like the start of the - // comment - but then if there is no readable text - good chance it is a - // false match and not a comment. - // - // for a visual example please see: - // https://github.com/highlightjs/highlight.js/issues/2827 - - begin: concat( - /[ ]+/, // necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */ - '(', - ENGLISH_WORD, - /[.]?[:]?([.][ ]|[ ])/, - '){3}') // look for 3 words in a row - } - ); - return mode; -}; -const C_LINE_COMMENT_MODE = COMMENT('//', '$'); -const C_BLOCK_COMMENT_MODE = COMMENT('/\\*', '\\*/'); -const HASH_COMMENT_MODE = COMMENT('#', '$'); -const NUMBER_MODE = { - scope: 'number', - begin: NUMBER_RE, - relevance: 0 -}; -const C_NUMBER_MODE = { - scope: 'number', - begin: C_NUMBER_RE, - relevance: 0 -}; -const BINARY_NUMBER_MODE = { - scope: 'number', - begin: BINARY_NUMBER_RE, - relevance: 0 -}; -const REGEXP_MODE = { - scope: "regexp", - begin: /\/(?=[^/\n]*\/)/, - end: /\/[gimuy]*/, - contains: [ - BACKSLASH_ESCAPE, - { - begin: /\[/, - end: /\]/, - relevance: 0, - contains: [BACKSLASH_ESCAPE] - } - ] -}; -const TITLE_MODE = { - scope: 'title', - begin: IDENT_RE, - relevance: 0 -}; -const UNDERSCORE_TITLE_MODE = { - scope: 'title', - begin: UNDERSCORE_IDENT_RE, - relevance: 0 -}; -const METHOD_GUARD = { - // excludes method names from keyword processing - begin: '\\.\\s*' + UNDERSCORE_IDENT_RE, - relevance: 0 -}; - -/** - * Adds end same as begin mechanics to a mode - * - * Your mode must include at least a single () match group as that first match - * group is what is used for comparison - * @param {Partial} mode - */ -const END_SAME_AS_BEGIN = function(mode) { - return Object.assign(mode, - { - /** @type {ModeCallback} */ - 'on:begin': (m, resp) => { resp.data._beginMatch = m[1]; }, - /** @type {ModeCallback} */ - 'on:end': (m, resp) => { if (resp.data._beginMatch !== m[1]) resp.ignoreMatch(); } - }); -}; - -var MODES = /*#__PURE__*/Object.freeze({ - __proto__: null, - APOS_STRING_MODE: APOS_STRING_MODE, - BACKSLASH_ESCAPE: BACKSLASH_ESCAPE, - BINARY_NUMBER_MODE: BINARY_NUMBER_MODE, - BINARY_NUMBER_RE: BINARY_NUMBER_RE, - COMMENT: COMMENT, - C_BLOCK_COMMENT_MODE: C_BLOCK_COMMENT_MODE, - C_LINE_COMMENT_MODE: C_LINE_COMMENT_MODE, - C_NUMBER_MODE: C_NUMBER_MODE, - C_NUMBER_RE: C_NUMBER_RE, - END_SAME_AS_BEGIN: END_SAME_AS_BEGIN, - HASH_COMMENT_MODE: HASH_COMMENT_MODE, - IDENT_RE: IDENT_RE, - MATCH_NOTHING_RE: MATCH_NOTHING_RE, - METHOD_GUARD: METHOD_GUARD, - NUMBER_MODE: NUMBER_MODE, - NUMBER_RE: NUMBER_RE, - PHRASAL_WORDS_MODE: PHRASAL_WORDS_MODE, - QUOTE_STRING_MODE: QUOTE_STRING_MODE, - REGEXP_MODE: REGEXP_MODE, - RE_STARTERS_RE: RE_STARTERS_RE, - SHEBANG: SHEBANG, - TITLE_MODE: TITLE_MODE, - UNDERSCORE_IDENT_RE: UNDERSCORE_IDENT_RE, - UNDERSCORE_TITLE_MODE: UNDERSCORE_TITLE_MODE -}); - -/** -@typedef {import('highlight.js').CallbackResponse} CallbackResponse -@typedef {import('highlight.js').CompilerExt} CompilerExt -*/ - -// Grammar extensions / plugins -// See: https://github.com/highlightjs/highlight.js/issues/2833 - -// Grammar extensions allow "syntactic sugar" to be added to the grammar modes -// without requiring any underlying changes to the compiler internals. - -// `compileMatch` being the perfect small example of now allowing a grammar -// author to write `match` when they desire to match a single expression rather -// than being forced to use `begin`. The extension then just moves `match` into -// `begin` when it runs. Ie, no features have been added, but we've just made -// the experience of writing (and reading grammars) a little bit nicer. - -// ------ - -// TODO: We need negative look-behind support to do this properly -/** - * Skip a match if it has a preceding dot - * - * This is used for `beginKeywords` to prevent matching expressions such as - * `bob.keyword.do()`. The mode compiler automatically wires this up as a - * special _internal_ 'on:begin' callback for modes with `beginKeywords` - * @param {RegExpMatchArray} match - * @param {CallbackResponse} response - */ -function skipIfHasPrecedingDot(match, response) { - const before = match.input[match.index - 1]; - if (before === ".") { - response.ignoreMatch(); - } -} - -/** - * - * @type {CompilerExt} - */ -function scopeClassName(mode, _parent) { - // eslint-disable-next-line no-undefined - if (mode.className !== undefined) { - mode.scope = mode.className; - delete mode.className; - } -} - -/** - * `beginKeywords` syntactic sugar - * @type {CompilerExt} - */ -function beginKeywords(mode, parent) { - if (!parent) return; - if (!mode.beginKeywords) return; - - // for languages with keywords that include non-word characters checking for - // a word boundary is not sufficient, so instead we check for a word boundary - // or whitespace - this does no harm in any case since our keyword engine - // doesn't allow spaces in keywords anyways and we still check for the boundary - // first - mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')(?!\\.)(?=\\b|\\s)'; - mode.__beforeBegin = skipIfHasPrecedingDot; - mode.keywords = mode.keywords || mode.beginKeywords; - delete mode.beginKeywords; - - // prevents double relevance, the keywords themselves provide - // relevance, the mode doesn't need to double it - // eslint-disable-next-line no-undefined - if (mode.relevance === undefined) mode.relevance = 0; -} - -/** - * Allow `illegal` to contain an array of illegal values - * @type {CompilerExt} - */ -function compileIllegal(mode, _parent) { - if (!Array.isArray(mode.illegal)) return; - - mode.illegal = either(...mode.illegal); -} - -/** - * `match` to match a single expression for readability - * @type {CompilerExt} - */ -function compileMatch(mode, _parent) { - if (!mode.match) return; - if (mode.begin || mode.end) throw new Error("begin & end are not supported with match"); - - mode.begin = mode.match; - delete mode.match; -} - -/** - * provides the default 1 relevance to all modes - * @type {CompilerExt} - */ -function compileRelevance(mode, _parent) { - // eslint-disable-next-line no-undefined - if (mode.relevance === undefined) mode.relevance = 1; -} - -// allow beforeMatch to act as a "qualifier" for the match -// the full match begin must be [beforeMatch][begin] -const beforeMatchExt = (mode, parent) => { - if (!mode.beforeMatch) return; - // starts conflicts with endsParent which we need to make sure the child - // rule is not matched multiple times - if (mode.starts) throw new Error("beforeMatch cannot be used with starts"); - - const originalMode = Object.assign({}, mode); - Object.keys(mode).forEach((key) => { delete mode[key]; }); - - mode.keywords = originalMode.keywords; - mode.begin = concat(originalMode.beforeMatch, lookahead(originalMode.begin)); - mode.starts = { - relevance: 0, - contains: [ - Object.assign(originalMode, { endsParent: true }) - ] - }; - mode.relevance = 0; - - delete originalMode.beforeMatch; -}; - -// keywords that should have no default relevance value -const COMMON_KEYWORDS = [ - 'of', - 'and', - 'for', - 'in', - 'not', - 'or', - 'if', - 'then', - 'parent', // common variable name - 'list', // common variable name - 'value' // common variable name -]; - -const DEFAULT_KEYWORD_SCOPE = "keyword"; - -/** - * Given raw keywords from a language definition, compile them. - * - * @param {string | Record | Array} rawKeywords - * @param {boolean} caseInsensitive - */ -function compileKeywords(rawKeywords, caseInsensitive, scopeName = DEFAULT_KEYWORD_SCOPE) { - /** @type {import("highlight.js/private").KeywordDict} */ - const compiledKeywords = Object.create(null); - - // input can be a string of keywords, an array of keywords, or a object with - // named keys representing scopeName (which can then point to a string or array) - if (typeof rawKeywords === 'string') { - compileList(scopeName, rawKeywords.split(" ")); - } else if (Array.isArray(rawKeywords)) { - compileList(scopeName, rawKeywords); - } else { - Object.keys(rawKeywords).forEach(function(scopeName) { - // collapse all our objects back into the parent object - Object.assign( - compiledKeywords, - compileKeywords(rawKeywords[scopeName], caseInsensitive, scopeName) - ); - }); - } - return compiledKeywords; - - // --- - - /** - * Compiles an individual list of keywords - * - * Ex: "for if when while|5" - * - * @param {string} scopeName - * @param {Array} keywordList - */ - function compileList(scopeName, keywordList) { - if (caseInsensitive) { - keywordList = keywordList.map(x => x.toLowerCase()); - } - keywordList.forEach(function(keyword) { - const pair = keyword.split('|'); - compiledKeywords[pair[0]] = [scopeName, scoreForKeyword(pair[0], pair[1])]; - }); - } -} - -/** - * Returns the proper score for a given keyword - * - * Also takes into account comment keywords, which will be scored 0 UNLESS - * another score has been manually assigned. - * @param {string} keyword - * @param {string} [providedScore] - */ -function scoreForKeyword(keyword, providedScore) { - // manual scores always win over common keywords - // so you can force a score of 1 if you really insist - if (providedScore) { - return Number(providedScore); - } - - return commonKeyword(keyword) ? 0 : 1; -} - -/** - * Determines if a given keyword is common or not - * - * @param {string} keyword */ -function commonKeyword(keyword) { - return COMMON_KEYWORDS.includes(keyword.toLowerCase()); -} - -/* - -For the reasoning behind this please see: -https://github.com/highlightjs/highlight.js/issues/2880#issuecomment-747275419 - -*/ - -/** - * @type {Record} - */ -const seenDeprecations = {}; - -/** - * @param {string} message - */ -const error = (message) => { - console.error(message); -}; - -/** - * @param {string} message - * @param {any} args - */ -const warn = (message, ...args) => { - console.log(`WARN: ${message}`, ...args); -}; - -/** - * @param {string} version - * @param {string} message - */ -const deprecated = (version, message) => { - if (seenDeprecations[`${version}/${message}`]) return; - - console.log(`Deprecated as of ${version}. ${message}`); - seenDeprecations[`${version}/${message}`] = true; -}; - -/* eslint-disable no-throw-literal */ - -/** -@typedef {import('highlight.js').CompiledMode} CompiledMode -*/ - -const MultiClassError = new Error(); - -/** - * Renumbers labeled scope names to account for additional inner match - * groups that otherwise would break everything. - * - * Lets say we 3 match scopes: - * - * { 1 => ..., 2 => ..., 3 => ... } - * - * So what we need is a clean match like this: - * - * (a)(b)(c) => [ "a", "b", "c" ] - * - * But this falls apart with inner match groups: - * - * (a)(((b)))(c) => ["a", "b", "b", "b", "c" ] - * - * Our scopes are now "out of alignment" and we're repeating `b` 3 times. - * What needs to happen is the numbers are remapped: - * - * { 1 => ..., 2 => ..., 5 => ... } - * - * We also need to know that the ONLY groups that should be output - * are 1, 2, and 5. This function handles this behavior. - * - * @param {CompiledMode} mode - * @param {Array} regexes - * @param {{key: "beginScope"|"endScope"}} opts - */ -function remapScopeNames(mode, regexes, { key }) { - let offset = 0; - const scopeNames = mode[key]; - /** @type Record */ - const emit = {}; - /** @type Record */ - const positions = {}; - - for (let i = 1; i <= regexes.length; i++) { - positions[i + offset] = scopeNames[i]; - emit[i + offset] = true; - offset += countMatchGroups(regexes[i - 1]); - } - // we use _emit to keep track of which match groups are "top-level" to avoid double - // output from inside match groups - mode[key] = positions; - mode[key]._emit = emit; - mode[key]._multi = true; -} - -/** - * @param {CompiledMode} mode - */ -function beginMultiClass(mode) { - if (!Array.isArray(mode.begin)) return; - - if (mode.skip || mode.excludeBegin || mode.returnBegin) { - error("skip, excludeBegin, returnBegin not compatible with beginScope: {}"); - throw MultiClassError; - } - - if (typeof mode.beginScope !== "object" || mode.beginScope === null) { - error("beginScope must be object"); - throw MultiClassError; - } - - remapScopeNames(mode, mode.begin, { key: "beginScope" }); - mode.begin = _rewriteBackreferences(mode.begin, { joinWith: "" }); -} - -/** - * @param {CompiledMode} mode - */ -function endMultiClass(mode) { - if (!Array.isArray(mode.end)) return; - - if (mode.skip || mode.excludeEnd || mode.returnEnd) { - error("skip, excludeEnd, returnEnd not compatible with endScope: {}"); - throw MultiClassError; - } - - if (typeof mode.endScope !== "object" || mode.endScope === null) { - error("endScope must be object"); - throw MultiClassError; - } - - remapScopeNames(mode, mode.end, { key: "endScope" }); - mode.end = _rewriteBackreferences(mode.end, { joinWith: "" }); -} - -/** - * this exists only to allow `scope: {}` to be used beside `match:` - * Otherwise `beginScope` would necessary and that would look weird - - { - match: [ /def/, /\w+/ ] - scope: { 1: "keyword" , 2: "title" } - } - - * @param {CompiledMode} mode - */ -function scopeSugar(mode) { - if (mode.scope && typeof mode.scope === "object" && mode.scope !== null) { - mode.beginScope = mode.scope; - delete mode.scope; - } -} - -/** - * @param {CompiledMode} mode - */ -function MultiClass(mode) { - scopeSugar(mode); - - if (typeof mode.beginScope === "string") { - mode.beginScope = { _wrap: mode.beginScope }; - } - if (typeof mode.endScope === "string") { - mode.endScope = { _wrap: mode.endScope }; - } - - beginMultiClass(mode); - endMultiClass(mode); -} - -/** -@typedef {import('highlight.js').Mode} Mode -@typedef {import('highlight.js').CompiledMode} CompiledMode -@typedef {import('highlight.js').Language} Language -@typedef {import('highlight.js').HLJSPlugin} HLJSPlugin -@typedef {import('highlight.js').CompiledLanguage} CompiledLanguage -*/ - -// compilation - -/** - * Compiles a language definition result - * - * Given the raw result of a language definition (Language), compiles this so - * that it is ready for highlighting code. - * @param {Language} language - * @returns {CompiledLanguage} - */ -function compileLanguage(language) { - /** - * Builds a regex with the case sensitivity of the current language - * - * @param {RegExp | string} value - * @param {boolean} [global] - */ - function langRe(value, global) { - return new RegExp( - source(value), - 'm' - + (language.case_insensitive ? 'i' : '') - + (language.unicodeRegex ? 'u' : '') - + (global ? 'g' : '') - ); - } - - /** - Stores multiple regular expressions and allows you to quickly search for - them all in a string simultaneously - returning the first match. It does - this by creating a huge (a|b|c) regex - each individual item wrapped with () - and joined by `|` - using match groups to track position. When a match is - found checking which position in the array has content allows us to figure - out which of the original regexes / match groups triggered the match. - - The match object itself (the result of `Regex.exec`) is returned but also - enhanced by merging in any meta-data that was registered with the regex. - This is how we keep track of which mode matched, and what type of rule - (`illegal`, `begin`, end, etc). - */ - class MultiRegex { - constructor() { - this.matchIndexes = {}; - // @ts-ignore - this.regexes = []; - this.matchAt = 1; - this.position = 0; - } - - // @ts-ignore - addRule(re, opts) { - opts.position = this.position++; - // @ts-ignore - this.matchIndexes[this.matchAt] = opts; - this.regexes.push([opts, re]); - this.matchAt += countMatchGroups(re) + 1; - } - - compile() { - if (this.regexes.length === 0) { - // avoids the need to check length every time exec is called - // @ts-ignore - this.exec = () => null; - } - const terminators = this.regexes.map(el => el[1]); - this.matcherRe = langRe(_rewriteBackreferences(terminators, { joinWith: '|' }), true); - this.lastIndex = 0; - } - - /** @param {string} s */ - exec(s) { - this.matcherRe.lastIndex = this.lastIndex; - const match = this.matcherRe.exec(s); - if (!match) { return null; } - - // eslint-disable-next-line no-undefined - const i = match.findIndex((el, i) => i > 0 && el !== undefined); - // @ts-ignore - const matchData = this.matchIndexes[i]; - // trim off any earlier non-relevant match groups (ie, the other regex - // match groups that make up the multi-matcher) - match.splice(0, i); - - return Object.assign(match, matchData); - } - } - - /* - Created to solve the key deficiently with MultiRegex - there is no way to - test for multiple matches at a single location. Why would we need to do - that? In the future a more dynamic engine will allow certain matches to be - ignored. An example: if we matched say the 3rd regex in a large group but - decided to ignore it - we'd need to started testing again at the 4th - regex... but MultiRegex itself gives us no real way to do that. - - So what this class creates MultiRegexs on the fly for whatever search - position they are needed. - - NOTE: These additional MultiRegex objects are created dynamically. For most - grammars most of the time we will never actually need anything more than the - first MultiRegex - so this shouldn't have too much overhead. - - Say this is our search group, and we match regex3, but wish to ignore it. - - regex1 | regex2 | regex3 | regex4 | regex5 ' ie, startAt = 0 - - What we need is a new MultiRegex that only includes the remaining - possibilities: - - regex4 | regex5 ' ie, startAt = 3 - - This class wraps all that complexity up in a simple API... `startAt` decides - where in the array of expressions to start doing the matching. It - auto-increments, so if a match is found at position 2, then startAt will be - set to 3. If the end is reached startAt will return to 0. - - MOST of the time the parser will be setting startAt manually to 0. - */ - class ResumableMultiRegex { - constructor() { - // @ts-ignore - this.rules = []; - // @ts-ignore - this.multiRegexes = []; - this.count = 0; - - this.lastIndex = 0; - this.regexIndex = 0; - } - - // @ts-ignore - getMatcher(index) { - if (this.multiRegexes[index]) return this.multiRegexes[index]; - - const matcher = new MultiRegex(); - this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts)); - matcher.compile(); - this.multiRegexes[index] = matcher; - return matcher; - } - - resumingScanAtSamePosition() { - return this.regexIndex !== 0; - } - - considerAll() { - this.regexIndex = 0; - } - - // @ts-ignore - addRule(re, opts) { - this.rules.push([re, opts]); - if (opts.type === "begin") this.count++; - } - - /** @param {string} s */ - exec(s) { - const m = this.getMatcher(this.regexIndex); - m.lastIndex = this.lastIndex; - let result = m.exec(s); - - // The following is because we have no easy way to say "resume scanning at the - // existing position but also skip the current rule ONLY". What happens is - // all prior rules are also skipped which can result in matching the wrong - // thing. Example of matching "booger": - - // our matcher is [string, "booger", number] - // - // ....booger.... - - // if "booger" is ignored then we'd really need a regex to scan from the - // SAME position for only: [string, number] but ignoring "booger" (if it - // was the first match), a simple resume would scan ahead who knows how - // far looking only for "number", ignoring potential string matches (or - // future "booger" matches that might be valid.) - - // So what we do: We execute two matchers, one resuming at the same - // position, but the second full matcher starting at the position after: - - // /--- resume first regex match here (for [number]) - // |/---- full match here for [string, "booger", number] - // vv - // ....booger.... - - // Which ever results in a match first is then used. So this 3-4 step - // process essentially allows us to say "match at this position, excluding - // a prior rule that was ignored". - // - // 1. Match "booger" first, ignore. Also proves that [string] does non match. - // 2. Resume matching for [number] - // 3. Match at index + 1 for [string, "booger", number] - // 4. If #2 and #3 result in matches, which came first? - if (this.resumingScanAtSamePosition()) { - if (result && result.index === this.lastIndex) ; else { // use the second matcher result - const m2 = this.getMatcher(0); - m2.lastIndex = this.lastIndex + 1; - result = m2.exec(s); - } - } - - if (result) { - this.regexIndex += result.position + 1; - if (this.regexIndex === this.count) { - // wrap-around to considering all matches again - this.considerAll(); - } - } - - return result; - } - } - - /** - * Given a mode, builds a huge ResumableMultiRegex that can be used to walk - * the content and find matches. - * - * @param {CompiledMode} mode - * @returns {ResumableMultiRegex} - */ - function buildModeRegex(mode) { - const mm = new ResumableMultiRegex(); - - mode.contains.forEach(term => mm.addRule(term.begin, { rule: term, type: "begin" })); - - if (mode.terminatorEnd) { - mm.addRule(mode.terminatorEnd, { type: "end" }); - } - if (mode.illegal) { - mm.addRule(mode.illegal, { type: "illegal" }); - } - - return mm; - } - - /** skip vs abort vs ignore - * - * @skip - The mode is still entered and exited normally (and contains rules apply), - * but all content is held and added to the parent buffer rather than being - * output when the mode ends. Mostly used with `sublanguage` to build up - * a single large buffer than can be parsed by sublanguage. - * - * - The mode begin ands ends normally. - * - Content matched is added to the parent mode buffer. - * - The parser cursor is moved forward normally. - * - * @abort - A hack placeholder until we have ignore. Aborts the mode (as if it - * never matched) but DOES NOT continue to match subsequent `contains` - * modes. Abort is bad/suboptimal because it can result in modes - * farther down not getting applied because an earlier rule eats the - * content but then aborts. - * - * - The mode does not begin. - * - Content matched by `begin` is added to the mode buffer. - * - The parser cursor is moved forward accordingly. - * - * @ignore - Ignores the mode (as if it never matched) and continues to match any - * subsequent `contains` modes. Ignore isn't technically possible with - * the current parser implementation. - * - * - The mode does not begin. - * - Content matched by `begin` is ignored. - * - The parser cursor is not moved forward. - */ - - /** - * Compiles an individual mode - * - * This can raise an error if the mode contains certain detectable known logic - * issues. - * @param {Mode} mode - * @param {CompiledMode | null} [parent] - * @returns {CompiledMode | never} - */ - function compileMode(mode, parent) { - const cmode = /** @type CompiledMode */ (mode); - if (mode.isCompiled) return cmode; - - [ - scopeClassName, - // do this early so compiler extensions generally don't have to worry about - // the distinction between match/begin - compileMatch, - MultiClass, - beforeMatchExt - ].forEach(ext => ext(mode, parent)); - - language.compilerExtensions.forEach(ext => ext(mode, parent)); - - // __beforeBegin is considered private API, internal use only - mode.__beforeBegin = null; - - [ - beginKeywords, - // do this later so compiler extensions that come earlier have access to the - // raw array if they wanted to perhaps manipulate it, etc. - compileIllegal, - // default to 1 relevance if not specified - compileRelevance - ].forEach(ext => ext(mode, parent)); - - mode.isCompiled = true; - - let keywordPattern = null; - if (typeof mode.keywords === "object" && mode.keywords.$pattern) { - // we need a copy because keywords might be compiled multiple times - // so we can't go deleting $pattern from the original on the first - // pass - mode.keywords = Object.assign({}, mode.keywords); - keywordPattern = mode.keywords.$pattern; - delete mode.keywords.$pattern; - } - keywordPattern = keywordPattern || /\w+/; - - if (mode.keywords) { - mode.keywords = compileKeywords(mode.keywords, language.case_insensitive); - } - - cmode.keywordPatternRe = langRe(keywordPattern, true); - - if (parent) { - if (!mode.begin) mode.begin = /\B|\b/; - cmode.beginRe = langRe(cmode.begin); - if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b/; - if (mode.end) cmode.endRe = langRe(cmode.end); - cmode.terminatorEnd = source(cmode.end) || ''; - if (mode.endsWithParent && parent.terminatorEnd) { - cmode.terminatorEnd += (mode.end ? '|' : '') + parent.terminatorEnd; - } - } - if (mode.illegal) cmode.illegalRe = langRe(/** @type {RegExp | string} */ (mode.illegal)); - if (!mode.contains) mode.contains = []; - - mode.contains = [].concat(...mode.contains.map(function(c) { - return expandOrCloneMode(c === 'self' ? mode : c); - })); - mode.contains.forEach(function(c) { compileMode(/** @type Mode */ (c), cmode); }); - - if (mode.starts) { - compileMode(mode.starts, parent); - } - - cmode.matcher = buildModeRegex(cmode); - return cmode; - } - - if (!language.compilerExtensions) language.compilerExtensions = []; - - // self is not valid at the top-level - if (language.contains && language.contains.includes('self')) { - throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation."); - } - - // we need a null object, which inherit will guarantee - language.classNameAliases = inherit$1(language.classNameAliases || {}); - - return compileMode(/** @type Mode */ (language)); -} - -/** - * Determines if a mode has a dependency on it's parent or not - * - * If a mode does have a parent dependency then often we need to clone it if - * it's used in multiple places so that each copy points to the correct parent, - * where-as modes without a parent can often safely be re-used at the bottom of - * a mode chain. - * - * @param {Mode | null} mode - * @returns {boolean} - is there a dependency on the parent? - * */ -function dependencyOnParent(mode) { - if (!mode) return false; - - return mode.endsWithParent || dependencyOnParent(mode.starts); -} - -/** - * Expands a mode or clones it if necessary - * - * This is necessary for modes with parental dependenceis (see notes on - * `dependencyOnParent`) and for nodes that have `variants` - which must then be - * exploded into their own individual modes at compile time. - * - * @param {Mode} mode - * @returns {Mode | Mode[]} - * */ -function expandOrCloneMode(mode) { - if (mode.variants && !mode.cachedVariants) { - mode.cachedVariants = mode.variants.map(function(variant) { - return inherit$1(mode, { variants: null }, variant); - }); - } - - // EXPAND - // if we have variants then essentially "replace" the mode with the variants - // this happens in compileMode, where this function is called from - if (mode.cachedVariants) { - return mode.cachedVariants; - } - - // CLONE - // if we have dependencies on parents then we need a unique - // instance of ourselves, so we can be reused with many - // different parents without issue - if (dependencyOnParent(mode)) { - return inherit$1(mode, { starts: mode.starts ? inherit$1(mode.starts) : null }); - } - - if (Object.isFrozen(mode)) { - return inherit$1(mode); - } - - // no special dependency issues, just return ourselves - return mode; -} - -var version = "11.9.0"; - -class HTMLInjectionError extends Error { - constructor(reason, html) { - super(reason); - this.name = "HTMLInjectionError"; - this.html = html; - } -} - -/* -Syntax highlighting with language autodetection. -https://highlightjs.org/ -*/ - - - -/** -@typedef {import('highlight.js').Mode} Mode -@typedef {import('highlight.js').CompiledMode} CompiledMode -@typedef {import('highlight.js').CompiledScope} CompiledScope -@typedef {import('highlight.js').Language} Language -@typedef {import('highlight.js').HLJSApi} HLJSApi -@typedef {import('highlight.js').HLJSPlugin} HLJSPlugin -@typedef {import('highlight.js').PluginEvent} PluginEvent -@typedef {import('highlight.js').HLJSOptions} HLJSOptions -@typedef {import('highlight.js').LanguageFn} LanguageFn -@typedef {import('highlight.js').HighlightedHTMLElement} HighlightedHTMLElement -@typedef {import('highlight.js').BeforeHighlightContext} BeforeHighlightContext -@typedef {import('highlight.js/private').MatchType} MatchType -@typedef {import('highlight.js/private').KeywordData} KeywordData -@typedef {import('highlight.js/private').EnhancedMatch} EnhancedMatch -@typedef {import('highlight.js/private').AnnotatedError} AnnotatedError -@typedef {import('highlight.js').AutoHighlightResult} AutoHighlightResult -@typedef {import('highlight.js').HighlightOptions} HighlightOptions -@typedef {import('highlight.js').HighlightResult} HighlightResult -*/ - - -const escape = escapeHTML; -const inherit = inherit$1; -const NO_MATCH = Symbol("nomatch"); -const MAX_KEYWORD_HITS = 7; - -/** - * @param {any} hljs - object that is extended (legacy) - * @returns {HLJSApi} - */ -const HLJS = function(hljs) { - // Global internal variables used within the highlight.js library. - /** @type {Record} */ - const languages = Object.create(null); - /** @type {Record} */ - const aliases = Object.create(null); - /** @type {HLJSPlugin[]} */ - const plugins = []; - - // safe/production mode - swallows more errors, tries to keep running - // even if a single syntax or parse hits a fatal error - let SAFE_MODE = true; - const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?"; - /** @type {Language} */ - const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: 'Plain text', contains: [] }; - - // Global options used when within external APIs. This is modified when - // calling the `hljs.configure` function. - /** @type HLJSOptions */ - let options = { - ignoreUnescapedHTML: false, - throwUnescapedHTML: false, - noHighlightRe: /^(no-?highlight)$/i, - languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i, - classPrefix: 'hljs-', - cssSelector: 'pre code', - languages: null, - // beta configuration options, subject to change, welcome to discuss - // https://github.com/highlightjs/highlight.js/issues/1086 - __emitter: TokenTreeEmitter - }; - - /* Utility functions */ - - /** - * Tests a language name to see if highlighting should be skipped - * @param {string} languageName - */ - function shouldNotHighlight(languageName) { - return options.noHighlightRe.test(languageName); - } - - /** - * @param {HighlightedHTMLElement} block - the HTML element to determine language for - */ - function blockLanguage(block) { - let classes = block.className + ' '; - - classes += block.parentNode ? block.parentNode.className : ''; - - // language-* takes precedence over non-prefixed class names. - const match = options.languageDetectRe.exec(classes); - if (match) { - const language = getLanguage(match[1]); - if (!language) { - warn(LANGUAGE_NOT_FOUND.replace("{}", match[1])); - warn("Falling back to no-highlight mode for this block.", block); - } - return language ? match[1] : 'no-highlight'; - } - - return classes - .split(/\s+/) - .find((_class) => shouldNotHighlight(_class) || getLanguage(_class)); - } - - /** - * Core highlighting function. - * - * OLD API - * highlight(lang, code, ignoreIllegals, continuation) - * - * NEW API - * highlight(code, {lang, ignoreIllegals}) - * - * @param {string} codeOrLanguageName - the language to use for highlighting - * @param {string | HighlightOptions} optionsOrCode - the code to highlight - * @param {boolean} [ignoreIllegals] - whether to ignore illegal matches, default is to bail - * - * @returns {HighlightResult} Result - an object that represents the result - * @property {string} language - the language name - * @property {number} relevance - the relevance score - * @property {string} value - the highlighted HTML code - * @property {string} code - the original raw code - * @property {CompiledMode} top - top of the current mode stack - * @property {boolean} illegal - indicates whether any illegal matches were found - */ - function highlight(codeOrLanguageName, optionsOrCode, ignoreIllegals) { - let code = ""; - let languageName = ""; - if (typeof optionsOrCode === "object") { - code = codeOrLanguageName; - ignoreIllegals = optionsOrCode.ignoreIllegals; - languageName = optionsOrCode.language; - } else { - // old API - deprecated("10.7.0", "highlight(lang, code, ...args) has been deprecated."); - deprecated("10.7.0", "Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"); - languageName = codeOrLanguageName; - code = optionsOrCode; - } - - // https://github.com/highlightjs/highlight.js/issues/3149 - // eslint-disable-next-line no-undefined - if (ignoreIllegals === undefined) { ignoreIllegals = true; } - - /** @type {BeforeHighlightContext} */ - const context = { - code, - language: languageName - }; - // the plugin can change the desired language or the code to be highlighted - // just be changing the object it was passed - fire("before:highlight", context); - - // a before plugin can usurp the result completely by providing it's own - // in which case we don't even need to call highlight - const result = context.result - ? context.result - : _highlight(context.language, context.code, ignoreIllegals); - - result.code = context.code; - // the plugin can change anything in result to suite it - fire("after:highlight", result); - - return result; - } - - /** - * private highlight that's used internally and does not fire callbacks - * - * @param {string} languageName - the language to use for highlighting - * @param {string} codeToHighlight - the code to highlight - * @param {boolean?} [ignoreIllegals] - whether to ignore illegal matches, default is to bail - * @param {CompiledMode?} [continuation] - current continuation mode, if any - * @returns {HighlightResult} - result of the highlight operation - */ - function _highlight(languageName, codeToHighlight, ignoreIllegals, continuation) { - const keywordHits = Object.create(null); - - /** - * Return keyword data if a match is a keyword - * @param {CompiledMode} mode - current mode - * @param {string} matchText - the textual match - * @returns {KeywordData | false} - */ - function keywordData(mode, matchText) { - return mode.keywords[matchText]; - } - - function processKeywords() { - if (!top.keywords) { - emitter.addText(modeBuffer); - return; - } - - let lastIndex = 0; - top.keywordPatternRe.lastIndex = 0; - let match = top.keywordPatternRe.exec(modeBuffer); - let buf = ""; - - while (match) { - buf += modeBuffer.substring(lastIndex, match.index); - const word = language.case_insensitive ? match[0].toLowerCase() : match[0]; - const data = keywordData(top, word); - if (data) { - const [kind, keywordRelevance] = data; - emitter.addText(buf); - buf = ""; - - keywordHits[word] = (keywordHits[word] || 0) + 1; - if (keywordHits[word] <= MAX_KEYWORD_HITS) relevance += keywordRelevance; - if (kind.startsWith("_")) { - // _ implied for relevance only, do not highlight - // by applying a class name - buf += match[0]; - } else { - const cssClass = language.classNameAliases[kind] || kind; - emitKeyword(match[0], cssClass); - } - } else { - buf += match[0]; - } - lastIndex = top.keywordPatternRe.lastIndex; - match = top.keywordPatternRe.exec(modeBuffer); - } - buf += modeBuffer.substring(lastIndex); - emitter.addText(buf); - } - - function processSubLanguage() { - if (modeBuffer === "") return; - /** @type HighlightResult */ - let result = null; - - if (typeof top.subLanguage === 'string') { - if (!languages[top.subLanguage]) { - emitter.addText(modeBuffer); - return; - } - result = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage]); - continuations[top.subLanguage] = /** @type {CompiledMode} */ (result._top); - } else { - result = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null); - } - - // Counting embedded language score towards the host language may be disabled - // with zeroing the containing mode relevance. Use case in point is Markdown that - // allows XML everywhere and makes every XML snippet to have a much larger Markdown - // score. - if (top.relevance > 0) { - relevance += result.relevance; - } - emitter.__addSublanguage(result._emitter, result.language); - } - - function processBuffer() { - if (top.subLanguage != null) { - processSubLanguage(); - } else { - processKeywords(); - } - modeBuffer = ''; - } - - /** - * @param {string} text - * @param {string} scope - */ - function emitKeyword(keyword, scope) { - if (keyword === "") return; - - emitter.startScope(scope); - emitter.addText(keyword); - emitter.endScope(); - } - - /** - * @param {CompiledScope} scope - * @param {RegExpMatchArray} match - */ - function emitMultiClass(scope, match) { - let i = 1; - const max = match.length - 1; - while (i <= max) { - if (!scope._emit[i]) { i++; continue; } - const klass = language.classNameAliases[scope[i]] || scope[i]; - const text = match[i]; - if (klass) { - emitKeyword(text, klass); - } else { - modeBuffer = text; - processKeywords(); - modeBuffer = ""; - } - i++; - } - } - - /** - * @param {CompiledMode} mode - new mode to start - * @param {RegExpMatchArray} match - */ - function startNewMode(mode, match) { - if (mode.scope && typeof mode.scope === "string") { - emitter.openNode(language.classNameAliases[mode.scope] || mode.scope); - } - if (mode.beginScope) { - // beginScope just wraps the begin match itself in a scope - if (mode.beginScope._wrap) { - emitKeyword(modeBuffer, language.classNameAliases[mode.beginScope._wrap] || mode.beginScope._wrap); - modeBuffer = ""; - } else if (mode.beginScope._multi) { - // at this point modeBuffer should just be the match - emitMultiClass(mode.beginScope, match); - modeBuffer = ""; - } - } - - top = Object.create(mode, { parent: { value: top } }); - return top; - } - - /** - * @param {CompiledMode } mode - the mode to potentially end - * @param {RegExpMatchArray} match - the latest match - * @param {string} matchPlusRemainder - match plus remainder of content - * @returns {CompiledMode | void} - the next mode, or if void continue on in current mode - */ - function endOfMode(mode, match, matchPlusRemainder) { - let matched = startsWith(mode.endRe, matchPlusRemainder); - - if (matched) { - if (mode["on:end"]) { - const resp = new Response(mode); - mode["on:end"](match, resp); - if (resp.isMatchIgnored) matched = false; - } - - if (matched) { - while (mode.endsParent && mode.parent) { - mode = mode.parent; - } - return mode; - } - } - // even if on:end fires an `ignore` it's still possible - // that we might trigger the end node because of a parent mode - if (mode.endsWithParent) { - return endOfMode(mode.parent, match, matchPlusRemainder); - } - } - - /** - * Handle matching but then ignoring a sequence of text - * - * @param {string} lexeme - string containing full match text - */ - function doIgnore(lexeme) { - if (top.matcher.regexIndex === 0) { - // no more regexes to potentially match here, so we move the cursor forward one - // space - modeBuffer += lexeme[0]; - return 1; - } else { - // no need to move the cursor, we still have additional regexes to try and - // match at this very spot - resumeScanAtSamePosition = true; - return 0; - } - } - - /** - * Handle the start of a new potential mode match - * - * @param {EnhancedMatch} match - the current match - * @returns {number} how far to advance the parse cursor - */ - function doBeginMatch(match) { - const lexeme = match[0]; - const newMode = match.rule; - - const resp = new Response(newMode); - // first internal before callbacks, then the public ones - const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]]; - for (const cb of beforeCallbacks) { - if (!cb) continue; - cb(match, resp); - if (resp.isMatchIgnored) return doIgnore(lexeme); - } - - if (newMode.skip) { - modeBuffer += lexeme; - } else { - if (newMode.excludeBegin) { - modeBuffer += lexeme; - } - processBuffer(); - if (!newMode.returnBegin && !newMode.excludeBegin) { - modeBuffer = lexeme; - } - } - startNewMode(newMode, match); - return newMode.returnBegin ? 0 : lexeme.length; - } - - /** - * Handle the potential end of mode - * - * @param {RegExpMatchArray} match - the current match - */ - function doEndMatch(match) { - const lexeme = match[0]; - const matchPlusRemainder = codeToHighlight.substring(match.index); - - const endMode = endOfMode(top, match, matchPlusRemainder); - if (!endMode) { return NO_MATCH; } - - const origin = top; - if (top.endScope && top.endScope._wrap) { - processBuffer(); - emitKeyword(lexeme, top.endScope._wrap); - } else if (top.endScope && top.endScope._multi) { - processBuffer(); - emitMultiClass(top.endScope, match); - } else if (origin.skip) { - modeBuffer += lexeme; - } else { - if (!(origin.returnEnd || origin.excludeEnd)) { - modeBuffer += lexeme; - } - processBuffer(); - if (origin.excludeEnd) { - modeBuffer = lexeme; - } - } - do { - if (top.scope) { - emitter.closeNode(); - } - if (!top.skip && !top.subLanguage) { - relevance += top.relevance; - } - top = top.parent; - } while (top !== endMode.parent); - if (endMode.starts) { - startNewMode(endMode.starts, match); - } - return origin.returnEnd ? 0 : lexeme.length; - } - - function processContinuations() { - const list = []; - for (let current = top; current !== language; current = current.parent) { - if (current.scope) { - list.unshift(current.scope); - } - } - list.forEach(item => emitter.openNode(item)); - } - - /** @type {{type?: MatchType, index?: number, rule?: Mode}}} */ - let lastMatch = {}; - - /** - * Process an individual match - * - * @param {string} textBeforeMatch - text preceding the match (since the last match) - * @param {EnhancedMatch} [match] - the match itself - */ - function processLexeme(textBeforeMatch, match) { - const lexeme = match && match[0]; - - // add non-matched text to the current mode buffer - modeBuffer += textBeforeMatch; - - if (lexeme == null) { - processBuffer(); - return 0; - } - - // we've found a 0 width match and we're stuck, so we need to advance - // this happens when we have badly behaved rules that have optional matchers to the degree that - // sometimes they can end up matching nothing at all - // Ref: https://github.com/highlightjs/highlight.js/issues/2140 - if (lastMatch.type === "begin" && match.type === "end" && lastMatch.index === match.index && lexeme === "") { - // spit the "skipped" character that our regex choked on back into the output sequence - modeBuffer += codeToHighlight.slice(match.index, match.index + 1); - if (!SAFE_MODE) { - /** @type {AnnotatedError} */ - const err = new Error(`0 width match regex (${languageName})`); - err.languageName = languageName; - err.badRule = lastMatch.rule; - throw err; - } - return 1; - } - lastMatch = match; - - if (match.type === "begin") { - return doBeginMatch(match); - } else if (match.type === "illegal" && !ignoreIllegals) { - // illegal match, we do not continue processing - /** @type {AnnotatedError} */ - const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.scope || '') + '"'); - err.mode = top; - throw err; - } else if (match.type === "end") { - const processed = doEndMatch(match); - if (processed !== NO_MATCH) { - return processed; - } - } - - // edge case for when illegal matches $ (end of line) which is technically - // a 0 width match but not a begin/end match so it's not caught by the - // first handler (when ignoreIllegals is true) - if (match.type === "illegal" && lexeme === "") { - // advance so we aren't stuck in an infinite loop - return 1; - } - - // infinite loops are BAD, this is a last ditch catch all. if we have a - // decent number of iterations yet our index (cursor position in our - // parsing) still 3x behind our index then something is very wrong - // so we bail - if (iterations > 100000 && iterations > match.index * 3) { - const err = new Error('potential infinite loop, way more iterations than matches'); - throw err; - } - - /* - Why might be find ourselves here? An potential end match that was - triggered but could not be completed. IE, `doEndMatch` returned NO_MATCH. - (this could be because a callback requests the match be ignored, etc) - - This causes no real harm other than stopping a few times too many. - */ - - modeBuffer += lexeme; - return lexeme.length; - } - - const language = getLanguage(languageName); - if (!language) { - error(LANGUAGE_NOT_FOUND.replace("{}", languageName)); - throw new Error('Unknown language: "' + languageName + '"'); - } - - const md = compileLanguage(language); - let result = ''; - /** @type {CompiledMode} */ - let top = continuation || md; - /** @type Record */ - const continuations = {}; // keep continuations for sub-languages - const emitter = new options.__emitter(options); - processContinuations(); - let modeBuffer = ''; - let relevance = 0; - let index = 0; - let iterations = 0; - let resumeScanAtSamePosition = false; - - try { - if (!language.__emitTokens) { - top.matcher.considerAll(); - - for (;;) { - iterations++; - if (resumeScanAtSamePosition) { - // only regexes not matched previously will now be - // considered for a potential match - resumeScanAtSamePosition = false; - } else { - top.matcher.considerAll(); - } - top.matcher.lastIndex = index; - - const match = top.matcher.exec(codeToHighlight); - // console.log("match", match[0], match.rule && match.rule.begin) - - if (!match) break; - - const beforeMatch = codeToHighlight.substring(index, match.index); - const processedCount = processLexeme(beforeMatch, match); - index = match.index + processedCount; - } - processLexeme(codeToHighlight.substring(index)); - } else { - language.__emitTokens(codeToHighlight, emitter); - } - - emitter.finalize(); - result = emitter.toHTML(); - - return { - language: languageName, - value: result, - relevance, - illegal: false, - _emitter: emitter, - _top: top - }; - } catch (err) { - if (err.message && err.message.includes('Illegal')) { - return { - language: languageName, - value: escape(codeToHighlight), - illegal: true, - relevance: 0, - _illegalBy: { - message: err.message, - index, - context: codeToHighlight.slice(index - 100, index + 100), - mode: err.mode, - resultSoFar: result - }, - _emitter: emitter - }; - } else if (SAFE_MODE) { - return { - language: languageName, - value: escape(codeToHighlight), - illegal: false, - relevance: 0, - errorRaised: err, - _emitter: emitter, - _top: top - }; - } else { - throw err; - } - } - } - - /** - * returns a valid highlight result, without actually doing any actual work, - * auto highlight starts with this and it's possible for small snippets that - * auto-detection may not find a better match - * @param {string} code - * @returns {HighlightResult} - */ - function justTextHighlightResult(code) { - const result = { - value: escape(code), - illegal: false, - relevance: 0, - _top: PLAINTEXT_LANGUAGE, - _emitter: new options.__emitter(options) - }; - result._emitter.addText(code); - return result; - } - - /** - Highlighting with language detection. Accepts a string with the code to - highlight. Returns an object with the following properties: - - - language (detected language) - - relevance (int) - - value (an HTML string with highlighting markup) - - secondBest (object with the same structure for second-best heuristically - detected language, may be absent) - - @param {string} code - @param {Array} [languageSubset] - @returns {AutoHighlightResult} - */ - function highlightAuto(code, languageSubset) { - languageSubset = languageSubset || options.languages || Object.keys(languages); - const plaintext = justTextHighlightResult(code); - - const results = languageSubset.filter(getLanguage).filter(autoDetection).map(name => - _highlight(name, code, false) - ); - results.unshift(plaintext); // plaintext is always an option - - const sorted = results.sort((a, b) => { - // sort base on relevance - if (a.relevance !== b.relevance) return b.relevance - a.relevance; - - // always award the tie to the base language - // ie if C++ and Arduino are tied, it's more likely to be C++ - if (a.language && b.language) { - if (getLanguage(a.language).supersetOf === b.language) { - return 1; - } else if (getLanguage(b.language).supersetOf === a.language) { - return -1; - } - } - - // otherwise say they are equal, which has the effect of sorting on - // relevance while preserving the original ordering - which is how ties - // have historically been settled, ie the language that comes first always - // wins in the case of a tie - return 0; - }); - - const [best, secondBest] = sorted; - - /** @type {AutoHighlightResult} */ - const result = best; - result.secondBest = secondBest; - - return result; - } - - /** - * Builds new class name for block given the language name - * - * @param {HTMLElement} element - * @param {string} [currentLang] - * @param {string} [resultLang] - */ - function updateClassName(element, currentLang, resultLang) { - const language = (currentLang && aliases[currentLang]) || resultLang; - - element.classList.add("hljs"); - element.classList.add(`language-${language}`); - } - - /** - * Applies highlighting to a DOM node containing code. - * - * @param {HighlightedHTMLElement} element - the HTML element to highlight - */ - function highlightElement(element) { - /** @type HTMLElement */ - let node = null; - const language = blockLanguage(element); - - if (shouldNotHighlight(language)) return; - - fire("before:highlightElement", - { el: element, language }); - - if (element.dataset.highlighted) { - console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", element); - return; - } - - // we should be all text, no child nodes (unescaped HTML) - this is possibly - // an HTML injection attack - it's likely too late if this is already in - // production (the code has likely already done its damage by the time - // we're seeing it)... but we yell loudly about this so that hopefully it's - // more likely to be caught in development before making it to production - if (element.children.length > 0) { - if (!options.ignoreUnescapedHTML) { - console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."); - console.warn("https://github.com/highlightjs/highlight.js/wiki/security"); - console.warn("The element with unescaped HTML:"); - console.warn(element); - } - if (options.throwUnescapedHTML) { - const err = new HTMLInjectionError( - "One of your code blocks includes unescaped HTML.", - element.innerHTML - ); - throw err; - } - } - - node = element; - const text = node.textContent; - const result = language ? highlight(text, { language, ignoreIllegals: true }) : highlightAuto(text); - - element.innerHTML = result.value; - element.dataset.highlighted = "yes"; - updateClassName(element, language, result.language); - element.result = { - language: result.language, - // TODO: remove with version 11.0 - re: result.relevance, - relevance: result.relevance - }; - if (result.secondBest) { - element.secondBest = { - language: result.secondBest.language, - relevance: result.secondBest.relevance - }; - } - - fire("after:highlightElement", { el: element, result, text }); - } - - /** - * Updates highlight.js global options with the passed options - * - * @param {Partial} userOptions - */ - function configure(userOptions) { - options = inherit(options, userOptions); - } - - // TODO: remove v12, deprecated - const initHighlighting = () => { - highlightAll(); - deprecated("10.6.0", "initHighlighting() deprecated. Use highlightAll() now."); - }; - - // TODO: remove v12, deprecated - function initHighlightingOnLoad() { - highlightAll(); - deprecated("10.6.0", "initHighlightingOnLoad() deprecated. Use highlightAll() now."); - } - - let wantsHighlight = false; - - /** - * auto-highlights all pre>code elements on the page - */ - function highlightAll() { - // if we are called too early in the loading process - if (document.readyState === "loading") { - wantsHighlight = true; - return; - } - - const blocks = document.querySelectorAll(options.cssSelector); - blocks.forEach(highlightElement); - } - - function boot() { - // if a highlight was requested before DOM was loaded, do now - if (wantsHighlight) highlightAll(); - } - - // make sure we are in the browser environment - if (typeof window !== 'undefined' && window.addEventListener) { - window.addEventListener('DOMContentLoaded', boot, false); - } - - /** - * Register a language grammar module - * - * @param {string} languageName - * @param {LanguageFn} languageDefinition - */ - function registerLanguage(languageName, languageDefinition) { - let lang = null; - try { - lang = languageDefinition(hljs); - } catch (error$1) { - error("Language definition for '{}' could not be registered.".replace("{}", languageName)); - // hard or soft error - if (!SAFE_MODE) { throw error$1; } else { error(error$1); } - // languages that have serious errors are replaced with essentially a - // "plaintext" stand-in so that the code blocks will still get normal - // css classes applied to them - and one bad language won't break the - // entire highlighter - lang = PLAINTEXT_LANGUAGE; - } - // give it a temporary name if it doesn't have one in the meta-data - if (!lang.name) lang.name = languageName; - languages[languageName] = lang; - lang.rawDefinition = languageDefinition.bind(null, hljs); - - if (lang.aliases) { - registerAliases(lang.aliases, { languageName }); - } - } - - /** - * Remove a language grammar module - * - * @param {string} languageName - */ - function unregisterLanguage(languageName) { - delete languages[languageName]; - for (const alias of Object.keys(aliases)) { - if (aliases[alias] === languageName) { - delete aliases[alias]; - } - } - } - - /** - * @returns {string[]} List of language internal names - */ - function listLanguages() { - return Object.keys(languages); - } - - /** - * @param {string} name - name of the language to retrieve - * @returns {Language | undefined} - */ - function getLanguage(name) { - name = (name || '').toLowerCase(); - return languages[name] || languages[aliases[name]]; - } - - /** - * - * @param {string|string[]} aliasList - single alias or list of aliases - * @param {{languageName: string}} opts - */ - function registerAliases(aliasList, { languageName }) { - if (typeof aliasList === 'string') { - aliasList = [aliasList]; - } - aliasList.forEach(alias => { aliases[alias.toLowerCase()] = languageName; }); - } - - /** - * Determines if a given language has auto-detection enabled - * @param {string} name - name of the language - */ - function autoDetection(name) { - const lang = getLanguage(name); - return lang && !lang.disableAutodetect; - } - - /** - * Upgrades the old highlightBlock plugins to the new - * highlightElement API - * @param {HLJSPlugin} plugin - */ - function upgradePluginAPI(plugin) { - // TODO: remove with v12 - if (plugin["before:highlightBlock"] && !plugin["before:highlightElement"]) { - plugin["before:highlightElement"] = (data) => { - plugin["before:highlightBlock"]( - Object.assign({ block: data.el }, data) - ); - }; - } - if (plugin["after:highlightBlock"] && !plugin["after:highlightElement"]) { - plugin["after:highlightElement"] = (data) => { - plugin["after:highlightBlock"]( - Object.assign({ block: data.el }, data) - ); - }; - } - } - - /** - * @param {HLJSPlugin} plugin - */ - function addPlugin(plugin) { - upgradePluginAPI(plugin); - plugins.push(plugin); - } - - /** - * @param {HLJSPlugin} plugin - */ - function removePlugin(plugin) { - const index = plugins.indexOf(plugin); - if (index !== -1) { - plugins.splice(index, 1); - } - } - - /** - * - * @param {PluginEvent} event - * @param {any} args - */ - function fire(event, args) { - const cb = event; - plugins.forEach(function(plugin) { - if (plugin[cb]) { - plugin[cb](args); - } - }); - } - - /** - * DEPRECATED - * @param {HighlightedHTMLElement} el - */ - function deprecateHighlightBlock(el) { - deprecated("10.7.0", "highlightBlock will be removed entirely in v12.0"); - deprecated("10.7.0", "Please use highlightElement now."); - - return highlightElement(el); - } - - /* Interface definition */ - Object.assign(hljs, { - highlight, - highlightAuto, - highlightAll, - highlightElement, - // TODO: Remove with v12 API - highlightBlock: deprecateHighlightBlock, - configure, - initHighlighting, - initHighlightingOnLoad, - registerLanguage, - unregisterLanguage, - listLanguages, - getLanguage, - registerAliases, - autoDetection, - inherit, - addPlugin, - removePlugin - }); - - hljs.debugMode = function() { SAFE_MODE = false; }; - hljs.safeMode = function() { SAFE_MODE = true; }; - hljs.versionString = version; - - hljs.regex = { - concat: concat, - lookahead: lookahead, - either: either, - optional: optional, - anyNumberOfTimes: anyNumberOfTimes - }; - - for (const key in MODES) { - // @ts-ignore - if (typeof MODES[key] === "object") { - // @ts-ignore - deepFreeze(MODES[key]); - } - } - - // merge all the modes/regexes into our main object - Object.assign(hljs, MODES); - - return hljs; -}; - -// Other names for the variable may break build script -const highlight = HLJS({}); - -// returns a new instance of the highlighter to be used for extensions -// check https://github.com/wooorm/lowlight/issues/47 -highlight.newInstance = () => HLJS({}); - -module.exports = highlight; -highlight.HighlightJS = highlight; -highlight.default = highlight; - - -/***/ }), - -/***/ "./node_modules/highlight.js/es/core.js": -/*!**********************************************!*\ - !*** ./node_modules/highlight.js/es/core.js ***! - \**********************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ HighlightJS: () => (/* reexport default export from named module */ _lib_core_js__WEBPACK_IMPORTED_MODULE_0__), -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var _lib_core_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/core.js */ "./node_modules/highlight.js/lib/core.js"); -// https://nodejs.org/api/packages.html#packages_writing_dual_packages_while_avoiding_or_minimizing_hazards - - -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_lib_core_js__WEBPACK_IMPORTED_MODULE_0__); - - -/***/ }), - -/***/ "./node_modules/highlight.js/es/languages/r.js": -/*!*****************************************************!*\ - !*** ./node_modules/highlight.js/es/languages/r.js ***! - \*****************************************************/ -/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (/* binding */ r) -/* harmony export */ }); -/* -Language: R -Description: R is a free software environment for statistical computing and graphics. -Author: Joe Cheng -Contributors: Konrad Rudolph -Website: https://www.r-project.org -Category: common,scientific -*/ - -/** @type LanguageFn */ -function r(hljs) { - const regex = hljs.regex; - // Identifiers in R cannot start with `_`, but they can start with `.` if it - // is not immediately followed by a digit. - // R also supports quoted identifiers, which are near-arbitrary sequences - // delimited by backticks (`…`), which may contain escape sequences. These are - // handled in a separate mode. See `test/markup/r/names.txt` for examples. - // FIXME: Support Unicode identifiers. - const IDENT_RE = /(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/; - const NUMBER_TYPES_RE = regex.either( - // Special case: only hexadecimal binary powers can contain fractions - /0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/, - // Hexadecimal numbers without fraction and optional binary power - /0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/, - // Decimal numbers - /(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/ - ); - const OPERATORS_RE = /[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/; - const PUNCTUATION_RE = regex.either( - /[()]/, - /[{}]/, - /\[\[/, - /[[\]]/, - /\\/, - /,/ - ); - - return { - name: 'R', - - keywords: { - $pattern: IDENT_RE, - keyword: - 'function if in break next repeat else for while', - literal: - 'NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 ' - + 'NA_character_|10 NA_complex_|10', - built_in: - // Builtin constants - 'LETTERS letters month.abb month.name pi T F ' - // Primitive functions - // These are all the functions in `base` that are implemented as a - // `.Primitive`, minus those functions that are also keywords. - + 'abs acos acosh all any anyNA Arg as.call as.character ' - + 'as.complex as.double as.environment as.integer as.logical ' - + 'as.null.default as.numeric as.raw asin asinh atan atanh attr ' - + 'attributes baseenv browser c call ceiling class Conj cos cosh ' - + 'cospi cummax cummin cumprod cumsum digamma dim dimnames ' - + 'emptyenv exp expression floor forceAndCall gamma gc.time ' - + 'globalenv Im interactive invisible is.array is.atomic is.call ' - + 'is.character is.complex is.double is.environment is.expression ' - + 'is.finite is.function is.infinite is.integer is.language ' - + 'is.list is.logical is.matrix is.na is.name is.nan is.null ' - + 'is.numeric is.object is.pairlist is.raw is.recursive is.single ' - + 'is.symbol lazyLoadDBfetch length lgamma list log max min ' - + 'missing Mod names nargs nzchar oldClass on.exit pos.to.env ' - + 'proc.time prod quote range Re rep retracemem return round ' - + 'seq_along seq_len seq.int sign signif sin sinh sinpi sqrt ' - + 'standardGeneric substitute sum switch tan tanh tanpi tracemem ' - + 'trigamma trunc unclass untracemem UseMethod xtfrm', - }, - - contains: [ - // Roxygen comments - hljs.COMMENT( - /#'/, - /$/, - { contains: [ - { - // Handle `@examples` separately to cause all subsequent code - // until the next `@`-tag on its own line to be kept as-is, - // preventing highlighting. This code is example R code, so nested - // doctags shouldn’t be treated as such. See - // `test/markup/r/roxygen.txt` for an example. - scope: 'doctag', - match: /@examples/, - starts: { - end: regex.lookahead(regex.either( - // end if another doc comment - /\n^#'\s*(?=@[a-zA-Z]+)/, - // or a line with no comment - /\n^(?!#')/ - )), - endsParent: true - } - }, - { - // Handle `@param` to highlight the parameter name following - // after. - scope: 'doctag', - begin: '@param', - end: /$/, - contains: [ - { - scope: 'variable', - variants: [ - { match: IDENT_RE }, - { match: /`(?:\\.|[^`\\])+`/ } - ], - endsParent: true - } - ] - }, - { - scope: 'doctag', - match: /@[a-zA-Z]+/ - }, - { - scope: 'keyword', - match: /\\[a-zA-Z]+/ - } - ] } - ), - - hljs.HASH_COMMENT_MODE, - - { - scope: 'string', - contains: [ hljs.BACKSLASH_ESCAPE ], - variants: [ - hljs.END_SAME_AS_BEGIN({ - begin: /[rR]"(-*)\(/, - end: /\)(-*)"/ - }), - hljs.END_SAME_AS_BEGIN({ - begin: /[rR]"(-*)\{/, - end: /\}(-*)"/ - }), - hljs.END_SAME_AS_BEGIN({ - begin: /[rR]"(-*)\[/, - end: /\](-*)"/ - }), - hljs.END_SAME_AS_BEGIN({ - begin: /[rR]'(-*)\(/, - end: /\)(-*)'/ - }), - hljs.END_SAME_AS_BEGIN({ - begin: /[rR]'(-*)\{/, - end: /\}(-*)'/ - }), - hljs.END_SAME_AS_BEGIN({ - begin: /[rR]'(-*)\[/, - end: /\](-*)'/ - }), - { - begin: '"', - end: '"', - relevance: 0 - }, - { - begin: "'", - end: "'", - relevance: 0 - } - ], - }, - - // Matching numbers immediately following punctuation and operators is - // tricky since we need to look at the character ahead of a number to - // ensure the number is not part of an identifier, and we cannot use - // negative look-behind assertions. So instead we explicitly handle all - // possible combinations of (operator|punctuation), number. - // TODO: replace with negative look-behind when available - // { begin: /(? { -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = (module) => { -/******/ var getter = module && module.__esModule ? -/******/ () => (module['default']) : -/******/ () => (module); -/******/ __webpack_require__.d(getter, { a: getter }); -/******/ return getter; -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/define property getters */ -/******/ (() => { -/******/ // define getter functions for harmony exports -/******/ __webpack_require__.d = (exports, definition) => { -/******/ for(var key in definition) { -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); -/******/ } -/******/ } -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ (() => { -/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) -/******/ })(); -/******/ -/******/ /* webpack/runtime/make namespace object */ -/******/ (() => { -/******/ // define __esModule on exports -/******/ __webpack_require__.r = (exports) => { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ })(); -/******/ -/************************************************************************/ -var __webpack_exports__ = {}; -// This entry need to be wrapped in an IIFE because it need to be in strict mode. -(() => { -"use strict"; -/*!************************!*\ - !*** ./srcjs/index.js ***! - \************************/ -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var shiny__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! shiny */ "shiny"); -/* harmony import */ var shiny__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(shiny__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _copy_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./copy.js */ "./srcjs/copy.js"); -/* harmony import */ var _hl_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./hl.js */ "./srcjs/hl.js"); -/* harmony import */ var _shiny_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shiny.js */ "./srcjs/shiny.js"); - - - - - -})(); - -/******/ })() -; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7O0FBQU87QUFDUDtBQUNBO0FBQ0E7O0FBRUE7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7O0FB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CBlZGl0YWJsZSA9ICQoZXZlbnQuY3VycmVudFRhcmdldCkuaGFzQ2xhc3MoXCJldGlkYWJsZVwiKTtcblxuICAgICRibG9ja3MuZWFjaCgoaW5kZXgsIGJsb2NrKSA9PiB7XG4gICAgICBjb25zdCAkYmxvY2sgPSAkKGJsb2NrKTtcblxuICAgICAgaWYgKGVkaXRhYmxlKSB7XG4gICAgICAgICRibG9jay5yZW1vdmVDbGFzcyhcImQtbm9uZVwiKTtcbiAgICAgICAgJGJsb2NrLmZpbmQoXCIuYmxvY2staW5wdXRzXCIpLnJlbW92ZUNsYXNzKFwiZC1ub25lXCIpO1xuICAgICAgICAkYmxvY2suZmluZChcIi5ibG9jay1pbnB1dHNcIikudHJpZ2dlcihcInNob3duXCIpO1xuXG4gICAgICAgIGlmIChpbmRleCA9PSAoJGJsb2Nrcy5sZW5ndGggLSAxKSkge1xuICAgICAgICAgICRibG9jay5maW5kKFwiLmJsb2NrLW91dHB1dFwiKS5hZGRDbGFzcyhcInNob3dcIik7XG4gICAgICAgICAgJGJsb2NrLmZpbmQoXCIuYmxvY2stb3V0cHV0XCIpLnJlbW92ZUNsYXNzKFwiZC1ub25lXCIpO1xuICAgICAgICAgICRibG9jay5maW5kKFwiLmJsb2NrLW91dHB1dFwiKS50cmlnZ2VyKFwic2hvd25cIik7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuO1xuICAgICAgfVxuXG4gICAgICAkYmxvY2suZmluZChcIi5ibG9jay1pbnB1dHNcIikuYWRkQ2xhc3MoXCJkLW5vbmVcIik7XG4gICAgICAkYmxvY2suZmluZChcIi5ibG9jay1pbnB1dHNcIikudHJpZ2dlcihcImhpZGRlblwiKTtcblxuICAgICAgaWYgKGluZGV4ID09ICgkYmxvY2tzLmxlbmd0aCAtIDEpKSB7XG4gICAgICAgICRibG9jay5yZW1vdmVDbGFzcyhcImQtbm9uZVwiKTtcblxuICAgICAgICAkYmxvY2suZmluZChcIi5ibG9jay1vdXRwdXRcIikuYWRk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biAgICAgIGlmIChlcnIubWVzc2FnZSAmJiBlcnIubWVzc2FnZS5pbmNsdWRlcygnSWxsZWdhbCcpKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgbGFuZ3VhZ2U6IGxhbmd1YWdlTmFtZSxcbiAgICAgICAgICB2YWx1ZTogZXNjYXBlKGNvZGVUb0hpZ2hsaWdodCksXG4gICAgICAgICAgaWxsZWdhbDogdHJ1ZSxcbiAgICAgICAgICByZWxldmFuY2U6IDAsXG4gICAgICAgICAgX2lsbGVnYWxCeToge1xuICAgICAgICAgICAgbWVzc2FnZTogZXJyLm1lc3NhZ2UsXG4gICAgICAgICAgICBpbmRleCxcbiAgICAgICAgICAgIGNvbnRleHQ6IGNvZGVUb0hpZ2hsaWdodC5zbGljZShpbmRleCAtIDEwMCwgaW5kZXggKyAxMDApLFxuICAgICAgICAgICAgbW9kZTogZXJyLm1vZGUsXG4gICAgICAgICAgICByZXN1bHRTb0ZhcjogcmVzdWx0XG4gICAgICAgICAgfSxcbiAgICAgICAgICBfZW1pdHRlcjogZW1pdHRlclxuICAgICAgICB9O1xuICAgICAgfSBlbHNlIGlmIChTQUZFX01PREUpIHtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICBsYW5ndWFnZTogbGFuZ3VhZ2VOYW1lLFxuICAgICAgICAgIHZhbHVlOiBlc2NhcGUoY29kZVRvSGlnaGxpZ2h0KSxcbiAgICAgICAgICBpbGxlZ2FsOiBmYWxzZSxcbiAgICAgICAgICByZWxldmFuY2U6IDAsXG4gICAgICAgICAgZXJyb3JSYWlzZWQ6IGVycixcbiAgICAgICAgICBfZW1pdHRlcjogZW1pdHRlcixcbiAgICAgICAgICBfdG9wOiB0b3BcbiAgICAgICAgfTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHRocm93IGVycjtcbiAgICAgIH1cbiAgICB9XG4gIH1cblxuICAvKipcbiAgICogcmV0dXJucyBhIHZhbGlkIGhpZ2hsaWdodCByZXN1bHQs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FjZW1lbSAnXG4gICAgICAgICsgJ3RyaWdhbW1hIHRydW5jIHVuY2xhc3MgdW50cmFjZW1lbSBVc2VNZXRob2QgeHRmcm0nLFxuICAgIH0sXG5cbiAgICBjb250YWluczogW1xuICAgICAgLy8gUm94eWdlbiBjb21tZW50c1xuICAgICAgaGxqcy5DT01NRU5UKFxuICAgICAgICAvIycvLFxuICAgICAgICAvJC8sXG4gICAgICAgIHsgY29udGFpbnM6IFtcbiAgICAgICAgICB7XG4gICAgICAgICAgICAvLyBIYW5kbGUgYEBleGFtcGxlc2Agc2VwYXJhdGVseSB0byBjYXVzZSBhbGwgc3Vic2VxdWVudCBjb2RlXG4gICAgICAgICAgICAvLyB1bnRpbCB0aGUgbmV4dCBgQGAtdGFnIG9uIGl0cyBvd24gbGluZSB0byBiZSBrZXB0IGFzLWlzLFxuICAgICAgICAgICAgLy8gcHJldmVudGluZyBoaWdobGlnaHRpbmcuIFRoaXMgY29kZSBpcyBleGFtcGxlIFIgY29kZSwgc28gbmVzdGVkXG4gICAgICAgICAgICAvLyBkb2N0YWdzIHNob3VsZG7igJl0IGJlIHRyZWF0ZWQgYXMgc3VjaC4gU2VlXG4gICAgICAgICAgICAvLyBgdGVzdC9tYXJrdXAvci9yb3h5Z2VuLnR4dGAgZm9yIGFuIGV4YW1wbGUuXG4gICAgICAgICAgICBzY29wZTogJ2RvY3RhZycsXG4gICAgICAgICAgICBtYXRjaDogL0BleGFtcGxlcy8sXG4gICAgICAgICAgICBzdGFydHM6IHtcbiAgICAgICAgICAgICAgZW5kOiByZWdleC5sb29rYWhlYWQocmVnZXguZWl0aGVyKFxuICAgICAgICAgICAgICAgIC8vIGVuZCBpZiBhbm90aGVyIGRvYyBjb21tZW50XG4gICAgICAgICAgICAgICAgL1xcbl4jJ1xccyooPz1AW2EtekEtWl0rKS8sXG4gICAgICAgICAgICAgICAgLy8gb3IgYSBsaW5lIHdpdGggbm8gY29tbWVudFxuICAgICAgICAgICAgICAgIC9cXG5eKD8hIycpL1xuICAgICAgICAgICAgICApKSxcbiAgICAgICAgICAgICAgZW5kc1BhcmVudDogdHJ1ZVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAge1xuICAgICAgICAgICAgLy8gSGFuZGxlIGBAcGFyYW1gIHRvIGhpZ2hsaWdodCB0aGUgcGFyYW1ldGVyIG5hbWUgZm9sbG93aW5nXG4gICAgICAgICAgICAvLyBhZnRlci5cbiAgICAgICAgICAgIHNjb3BlOiAnZG9jdGFnJyxcbiAgICAgICAgICAgIGJlZ2luOiAnQHBhcmFtJyxcbiAgICAgICAgICAgIGVuZDogLyQvLFxuICAgICAgICAgICAgY29udGFpbnM6IFtcbiAgICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgIHNjb3BlOiAndmFyaWFibGUnLFxuICAgICAgICAgICAgICAgIHZhcmlhbnRzOiBbXG4gICAgICAgICAgICAgICAgICB7IG1hdGNoOiBJREVOVF9SRSB9LFxuICAgICAgICAgICAgICAgICAgeyBtYXRjaDogL2AoPzpcXFxcLnxbXmBcXFxcXSkrYC8gfVxuICAgICAgICAgICAgICAgIF0sXG4gICAgICAgICAgICAgICAgZW5kc1BhcmVudDogdHJ1ZVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICBdXG4gICAgICAgICAgfSxcbiAgICAgICAgICB7XG4gICAgICAgICAgICBzY29wZTogJ2RvY3RhZycsXG4gICAgICAgICAgICBtYXRjaDogL0BbYS16QS1aXSsvXG4gICAgICAgICAgfSxcbiAgICAgICAgICB7XG4gICAgICAgICAgICBzY29wZTogJ2tleXdvcmQnLFxuICAgICAgICAgICAgbWF0Y2g6IC9cXFxcW2EtekEtWl0rL1xuICAgICAgICAgIH1cbiAgICAgICAgXSB9XG4gICAgICApLFxuXG4gICAgICBobGpzLkhBU0hfQ09NTUVOVF9NT0RFLFxuXG4gICAgICB7XG4gICAgICAgIHNjb3BlOiAnc3RyaW5nJyxcbiAgICAgICAgY29udGFpbnM6IFsgaGxqcy5CQUNLU0xBU0hfRVNDQVBFIF0sXG4gICAgICAgIHZhcmlhbnRzOiBbXG4gICAgICAgICAgaGxqcy5FTkRfU0FNRV9BU19CRUdJTih7XG4gICAgICAgICAgICBiZWdpbjogL1tyUl1cIigtKilcXCgvLFxuICAgICAgICAgICAgZW5kOiAvXFwpKC0qKVwiL1xuICAgICAgICAgIH0pLFxuICAgICAgICAgIGhsanMuRU5EX1NBTUVfQVNfQkVHSU4oe1xuICAgICAgICAgICAgYmVnaW46IC9bclJdXCIoLSopXFx7LyxcbiAgICAgICAgICAgIGVuZDogL1xcfSgtKilcIi9cbiAgICAgICAgICB9KSxcbiAgICAgICAgICBobGpzLkVORF9TQU1FX0FTX0JFR0lOKHtcbiAgICAgICAgICAgIGJlZ2luOiAvW3JSXVwiKC0qKVxcWy8sXG4gICAgICAgICAgICBlbmQ6IC9cXF0oLSopXCIvXG4gICAgICAgICAgfSksXG4gICAgICAgICAgaGxqcy5FTkRfU0FNRV9BU19CRUdJTih7XG4gICAgICAgICAgICBiZWdpbjogL1tyUl0nKC0qKVxcKC8sXG4gICAgICAgICAgICBlbmQ6IC9cXCkoLSopJy9cbiAgICAgICAgICB9KSxcbiAgICAgICAgICBobGpzLkVORF9TQU1FX0FTX0JFR0lOKHtcbiAgICAgICAgICAgIGJlZ2luOiAvW3JSXScoLSopXFx7LyxcbiAgICAgICAgICAgIGVuZDogL1xcfSgtKiknL1xuICAgICAgICAgIH0pLFxuICAgICAgICAgIGhsanMuRU5EX1NBTUVfQVNfQkVHSU4oe1xuICAgICAgICAgICAgYmVnaW46IC9bclJdJygtKilcXFsvLFxuICAgICAgICAgICAgZW5kOiAvXFxdKC0qKScvXG4gICAgICAgICAgfSksXG4gICAgICAgICAge1xuICAgICAgICAgICAgYmVnaW46ICdcIicsXG4gICAgICAgICAgICBlbmQ6ICdcIicsXG4gICAgICAgICAgICByZWxldmFuY2U6IDBcbiAgICAgICAgICB9LFxuICAgICAgICAgIHtcbiAgICAgICAgICAgIGJlZ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U6IDAsXG4gICAgICAgIHZhcmlhbnRzOiBbXG4gICAgICAgICAge1xuICAgICAgICAgICAgc2NvcGU6IHtcbiAgICAgICAgICAgICAgMTogJ29wZXJhdG9yJyxcbiAgICAgICAgICAgICAgMjogJ251bWJlcidcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBtYXRjaDogW1xuICAgICAgICAgICAgICBPUEVSQVRPUlNfUkUsXG4gICAgICAgICAgICAgIE5VTUJFUl9UWVBFU19SRVxuICAgICAgICAgICAgXVxuICAgICAgICAgIH0sXG4gICAgICAgICAge1xuICAgICAgICAgICAgc2NvcGU6IHtcbiAgICAgICAgICAgICAgMTogJ29wZXJhdG9yJyxcbiAgICAgICAgICAgICAgMjogJ251bWJlcidcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBtYXRjaDogW1xuICAgICAgICAgICAgICAvJVteJV0qJS8sXG4gICAgICAgICAgICAgIE5VTUJFUl9UWVBFU19SRVxuICAgICAgICAgICAgXVxuICAgICAgICAgIH0sXG4gICAgICAgICAge1xuICAgICAgICAgICAgc2NvcGU6IHtcbiAgICAgICAgICAgICAgMTogJ3B1bmN0dWF0aW9uJyxcbiAgICAgICAgICAgICAgMjogJ251bWJlcidcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBtYXRjaDogW1xuICAgICAgICAgICAgICBQVU5DVFVBVElPTl9SRSxcbiAgICAgICAgICAgICAgTlVNQkVSX1RZUEVTX1JFXG4gICAgICAgICAgICBdXG4gICAgICAgICAgfSxcbiAgICAgICAgICB7XG4gICAgICAgICAgICBzY29wZTogeyAyOiAnbnVtYmVyJyB9LFxuICAgICAgICAgICAgbWF0Y2g6IFtcbiAgICAgICAgICAgICAgL1teYS16QS1aMC05Ll9dfF4vLCAvLyBub3QgcGFydCBvZiBhbiBpZGVudGlmaWVyLCBvciBzdGFydCBvZiBkb2N1bWVudFxuICAgICAgICAgICAgICBOVU1CRVJfVFlQRVNfUkVcbiAgICAgICAgICAgIF1cbiAgICAgICAgICB9XG4gICAgICAgIF1cbiAgICAgIH0sXG5cbiAgICAgIC8vIE9wZXJhdG9ycy9wdW5jdHVhdGlvbiB3aGVuIHRoZXkncmUgbm90IGRpcmVjdGx5IGZvbGxvd2VkIGJ5IG51bWJlcnNcbiAgICAgIHtcbiAgICAgICAgLy8gUmVsZXZhbmNlIGJvb3N0IGZvciB0aGUgbW9zdCBjb21tb24gYXNzaWdubWVudCBmb3JtLlxuICAgICAgICBzY29wZTogeyAzOiAnb3BlcmF0b3InIH0sXG4gICAgICAgIG1hdGNoOiBbXG4gICAgICAgICAgSURFTlRfUkUsXG4gICAgICAgICAgL1xccysvLFxuICAgICAgICAgIC88LS8sXG4gICAgICAgICAgL1xccysvXG4gICAgICAgIF1cbiAgICAgIH0sXG5cbiAgICAgIHtcbiAgICAgICAgc2NvcGU6ICdvcGVyYXRvcicsXG4gICAgICAgIHJlbGV2YW5jZTogMCxcbiAgICAgICAgdmFyaWFudHM6IFtcbiAgICAgICAgICB7IG1hdGNoOiBPUEVSQVRPUlNfUkUgfSxcbiAgICAgICAgICB7IG1hdGNoOiAvJVteJV0qJS8gfVxuICAgICAgICBdXG4gICAgICB9LFxuXG4gICAgICB7XG4gICAgICAgIHNjb3BlOiAncHVuY3R1YXRpb24nLFxuICAgICAgICByZWxldmFuY2U6IDAsXG4gICAgICAgIG1hdGNoOiBQVU5DVFVBVElPTl9SRVxuICAgICAgfSxcblxuICAgICAge1xuICAgICAgICAvLyBFc2NhcGVkIGlkZW50aWZpZXJcbiAgICAgICAgYmVnaW46ICdgJyxcbiAgICAgICAgZW5kOiAnYCcsXG4gICAgICAgIGNvbnRhaW5zOiBbIHsgYmVnaW46IC9cXFxcLi8gfSBdXG4gICAgICB9XG4gICAgXVxuICB9O1xufVxuXG5leHBvcnQgeyByIGFzIGRlZmF1bHQgfTtcbiIsIi8vIFRoZSBtb2R1bGUgY2FjaGVcbnZhciBfX3dlYnBhY2tfbW9kdWxlX2NhY2hlX18gPSB7fTtcblxuL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XCJzaGlueVwiO1xuaW1wb3J0IFwiLi9jb3B5LmpzXCI7XG5pbXBvcnQgXCIuL2hsLmpzXCI7XG5pbXBvcnQgXCIuL3NoaW55LmpzXCI7XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0= \ No newline at end of file +(()=>{var e={390:e=>{function n(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach((t=>{const i=e[t],o=typeof i;"object"!==o&&"function"!==o||Object.isFrozen(i)||n(i)})),e}class t{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function i(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function o(e,...n){const t=Object.create(null);for(const n in e)t[n]=e[n];return n.forEach((function(e){for(const n in e)t[n]=e[n]})),t}const s=e=>!!e.scope;class r{constructor(e,n){this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!s(e))return;const n=((e,{prefix:n})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const t=e.split(".");return[`${n}${t.shift()}`,...t.map(((e,n)=>`${e}${"_".repeat(n+1)}`))].join(" ")}return`${n}${e}`})(e.scope,{prefix:this.classPrefix});this.span(n)}closeNode(e){s(e)&&(this.buffer+="")}value(){return this.buffer}span(e){this.buffer+=``}}const a=(e={})=>{const n={children:[]};return Object.assign(n,e),n};class c{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const n=a({scope:e});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){return"string"==typeof n?e.addText(n):n.children&&(e.openNode(n),n.children.forEach((n=>this._walk(e,n))),e.closeNode(n)),e}static _collapse(e){"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{c._collapse(e)})))}}class l extends c{constructor(e){super(),this.options=e}addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,n){const t=e.root;n&&(t.scope=`language:${n}`),this.add(t)}toHTML(){return new r(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function u(e){return e?"string"==typeof e?e:e.source:null}function d(e){return f("(?=",e,")")}function g(e){return f("(?:",e,")*")}function h(e){return f("(?:",e,")?")}function f(...e){return e.map((e=>u(e))).join("")}function p(...e){const n=function(e){const n=e[e.length-1];return"object"==typeof n&&n.constructor===Object?(e.splice(e.length-1,1),n):{}}(e);return"("+(n.capture?"":"?:")+e.map((e=>u(e))).join("|")+")"}function b(e){return new RegExp(e.toString()+"|").exec("").length-1}const m=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function E(e,{joinWith:n}){let t=0;return e.map((e=>{t+=1;const n=t;let i=u(e),o="";for(;i.length>0;){const e=m.exec(i);if(!e){o+=i;break}o+=i.substring(0,e.index),i=i.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?o+="\\"+String(Number(e[1])+n):(o+=e[0],"("===e[0]&&t++)}return o})).map((e=>`(${e})`)).join(n)}const x="[a-zA-Z]\\w*",_="[a-zA-Z_]\\w*",w="\\b\\d+(\\.\\d+)?",k="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",y="\\b(0b[01]+)",v={begin:"\\\\[\\s\\S]",relevance:0},A={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[v]},N={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[v]},S=function(e,n,t={}){const i=o({scope:"comment",begin:e,end:n,contains:[]},t);i.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const s=p("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return i.contains.push({begin:f(/[ ]+/,"(",s,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),i},M=S("//","$"),O=S("/\\*","\\*/"),R=S("#","$"),T={scope:"number",begin:w,relevance:0},$={scope:"number",begin:k,relevance:0},I={scope:"number",begin:y,relevance:0},j={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[v,{begin:/\[/,end:/\]/,relevance:0,contains:[v]}]},C={scope:"title",begin:x,relevance:0},L={scope:"title",begin:_,relevance:0},B={begin:"\\.\\s*"+_,relevance:0};var D=Object.freeze({__proto__:null,APOS_STRING_MODE:A,BACKSLASH_ESCAPE:v,BINARY_NUMBER_MODE:I,BINARY_NUMBER_RE:y,COMMENT:S,C_BLOCK_COMMENT_MODE:O,C_LINE_COMMENT_MODE:M,C_NUMBER_MODE:$,C_NUMBER_RE:k,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,n)=>{n.data._beginMatch=e[1]},"on:end":(e,n)=>{n.data._beginMatch!==e[1]&&n.ignoreMatch()}})},HASH_COMMENT_MODE:R,IDENT_RE:x,MATCH_NOTHING_RE:/\b\B/,METHOD_GUARD:B,NUMBER_MODE:T,NUMBER_RE:w,PHRASAL_WORDS_MODE:{begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},QUOTE_STRING_MODE:N,REGEXP_MODE:j,RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{const n=/^#![ ]*\//;return e.binary&&(e.begin=f(n,/.*\b/,e.binary,/\b.*/)),o({scope:"meta",begin:n,end:/$/,relevance:0,"on:begin":(e,n)=>{0!==e.index&&n.ignoreMatch()}},e)},TITLE_MODE:C,UNDERSCORE_IDENT_RE:_,UNDERSCORE_TITLE_MODE:L});function H(e,n){"."===e.input[e.index-1]&&n.ignoreMatch()}function P(e,n){void 0!==e.className&&(e.scope=e.className,delete e.className)}function z(e,n){n&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=H,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,void 0===e.relevance&&(e.relevance=0))}function U(e,n){Array.isArray(e.illegal)&&(e.illegal=p(...e.illegal))}function G(e,n){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function Z(e,n){void 0===e.relevance&&(e.relevance=1)}const F=(e,n)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const t=Object.assign({},e);Object.keys(e).forEach((n=>{delete e[n]})),e.keywords=t.keywords,e.begin=f(t.beforeMatch,d(t.begin)),e.starts={relevance:0,contains:[Object.assign(t,{endsParent:!0})]},e.relevance=0,delete t.beforeMatch},W=["of","and","for","in","not","or","if","then","parent","list","value"],X="keyword";function K(e,n,t=X){const i=Object.create(null);return"string"==typeof e?o(t,e.split(" ")):Array.isArray(e)?o(t,e):Object.keys(e).forEach((function(t){Object.assign(i,K(e[t],n,t))})),i;function o(e,t){n&&(t=t.map((e=>e.toLowerCase()))),t.forEach((function(n){const t=n.split("|");i[t[0]]=[e,q(t[0],t[1])]}))}}function q(e,n){return n?Number(n):function(e){return W.includes(e.toLowerCase())}(e)?0:1}const V={},J=e=>{console.error(e)},Y=(e,...n)=>{console.log(`WARN: ${e}`,...n)},Q=(e,n)=>{V[`${e}/${n}`]||(console.log(`Deprecated as of ${e}. ${n}`),V[`${e}/${n}`]=!0)},ee=new Error;function ne(e,n,{key:t}){let i=0;const o=e[t],s={},r={};for(let e=1;e<=n.length;e++)r[e+i]=o[e],s[e+i]=!0,i+=b(n[e-1]);e[t]=r,e[t]._emit=s,e[t]._multi=!0}function te(e){!function(e){e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,delete e.scope)}(e),"string"==typeof e.beginScope&&(e.beginScope={_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope}),function(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw J("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ee;if("object"!=typeof e.beginScope||null===e.beginScope)throw J("beginScope must be object"),ee;ne(e,e.begin,{key:"beginScope"}),e.begin=E(e.begin,{joinWith:""})}}(e),function(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw J("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ee;if("object"!=typeof e.endScope||null===e.endScope)throw J("endScope must be object"),ee;ne(e,e.end,{key:"endScope"}),e.end=E(e.end,{joinWith:""})}}(e)}function ie(e){function n(n,t){return new RegExp(u(n),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(t?"g":""))}class t{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,n){n.position=this.position++,this.matchIndexes[this.matchAt]=n,this.regexes.push([n,e]),this.matchAt+=b(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);const e=this.regexes.map((e=>e[1]));this.matcherRe=n(E(e,{joinWith:"|"}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;const n=this.matcherRe.exec(e);if(!n)return null;const t=n.findIndex(((e,n)=>n>0&&void 0!==e)),i=this.matchIndexes[t];return n.splice(0,t),Object.assign(n,i)}}class i{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];const n=new t;return this.rules.slice(e).forEach((([e,t])=>n.addRule(e,t))),n.compile(),this.multiRegexes[e]=n,n}resumingScanAtSamePosition(){return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,n){this.rules.push([e,n]),"begin"===n.type&&this.count++}exec(e){const n=this.getMatcher(this.regexIndex);n.lastIndex=this.lastIndex;let t=n.exec(e);if(this.resumingScanAtSamePosition())if(t&&t.index===this.lastIndex);else{const n=this.getMatcher(0);n.lastIndex=this.lastIndex+1,t=n.exec(e)}return t&&(this.regexIndex+=t.position+1,this.regexIndex===this.count&&this.considerAll()),t}}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=o(e.classNameAliases||{}),function t(s,r){const a=s;if(s.isCompiled)return a;[P,G,te,F].forEach((e=>e(s,r))),e.compilerExtensions.forEach((e=>e(s,r))),s.__beforeBegin=null,[z,U,Z].forEach((e=>e(s,r))),s.isCompiled=!0;let c=null;return"object"==typeof s.keywords&&s.keywords.$pattern&&(s.keywords=Object.assign({},s.keywords),c=s.keywords.$pattern,delete s.keywords.$pattern),c=c||/\w+/,s.keywords&&(s.keywords=K(s.keywords,e.case_insensitive)),a.keywordPatternRe=n(c,!0),r&&(s.begin||(s.begin=/\B|\b/),a.beginRe=n(a.begin),s.end||s.endsWithParent||(s.end=/\B|\b/),s.end&&(a.endRe=n(a.end)),a.terminatorEnd=u(a.end)||"",s.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(s.end?"|":"")+r.terminatorEnd)),s.illegal&&(a.illegalRe=n(s.illegal)),s.contains||(s.contains=[]),s.contains=[].concat(...s.contains.map((function(e){return function(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((function(n){return o(e,{variants:null},n)}))),e.cachedVariants?e.cachedVariants:oe(e)?o(e,{starts:e.starts?o(e.starts):null}):Object.isFrozen(e)?o(e):e}("self"===e?s:e)}))),s.contains.forEach((function(e){t(e,a)})),s.starts&&t(s.starts,r),a.matcher=function(e){const n=new i;return e.contains.forEach((e=>n.addRule(e.begin,{rule:e,type:"begin"}))),e.terminatorEnd&&n.addRule(e.terminatorEnd,{type:"end"}),e.illegal&&n.addRule(e.illegal,{type:"illegal"}),n}(a),a}(e)}function oe(e){return!!e&&(e.endsWithParent||oe(e.starts))}class se extends Error{constructor(e,n){super(e),this.name="HTMLInjectionError",this.html=n}}const re=i,ae=o,ce=Symbol("nomatch"),le=function(e){const i=Object.create(null),o=Object.create(null),s=[];let r=!0;const a="Could not find the language '{}', did you forget to load/include a language module?",c={disableAutodetect:!0,name:"Plain text",contains:[]};let u={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:l};function b(e){return u.noHighlightRe.test(e)}function m(e,n,t){let i="",o="";"object"==typeof n?(i=e,t=n.ignoreIllegals,o=n.language):(Q("10.7.0","highlight(lang, code, ...args) has been deprecated."),Q("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),o=e,i=n),void 0===t&&(t=!0);const s={code:i,language:o};N("before:highlight",s);const r=s.result?s.result:E(s.language,s.code,t);return r.code=s.code,N("after:highlight",r),r}function E(e,n,o,s){const c=Object.create(null);function l(){if(!N.keywords)return void M.addText(O);let e=0;N.keywordPatternRe.lastIndex=0;let n=N.keywordPatternRe.exec(O),t="";for(;n;){t+=O.substring(e,n.index);const o=k.case_insensitive?n[0].toLowerCase():n[0],s=(i=o,N.keywords[i]);if(s){const[e,i]=s;if(M.addText(t),t="",c[o]=(c[o]||0)+1,c[o]<=7&&(R+=i),e.startsWith("_"))t+=n[0];else{const t=k.classNameAliases[e]||e;g(n[0],t)}}else t+=n[0];e=N.keywordPatternRe.lastIndex,n=N.keywordPatternRe.exec(O)}var i;t+=O.substring(e),M.addText(t)}function d(){null!=N.subLanguage?function(){if(""===O)return;let e=null;if("string"==typeof N.subLanguage){if(!i[N.subLanguage])return void M.addText(O);e=E(N.subLanguage,O,!0,S[N.subLanguage]),S[N.subLanguage]=e._top}else e=x(O,N.subLanguage.length?N.subLanguage:null);N.relevance>0&&(R+=e.relevance),M.__addSublanguage(e._emitter,e.language)}():l(),O=""}function g(e,n){""!==e&&(M.startScope(n),M.addText(e),M.endScope())}function h(e,n){let t=1;const i=n.length-1;for(;t<=i;){if(!e._emit[t]){t++;continue}const i=k.classNameAliases[e[t]]||e[t],o=n[t];i?g(o,i):(O=o,l(),O=""),t++}}function f(e,n){return e.scope&&"string"==typeof e.scope&&M.openNode(k.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(g(O,k.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),O=""):e.beginScope._multi&&(h(e.beginScope,n),O="")),N=Object.create(e,{parent:{value:N}}),N}function p(e,n,i){let o=function(e,n){const t=e&&e.exec(n);return t&&0===t.index}(e.endRe,i);if(o){if(e["on:end"]){const i=new t(e);e["on:end"](n,i),i.isMatchIgnored&&(o=!1)}if(o){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return p(e.parent,n,i)}function b(e){return 0===N.matcher.regexIndex?(O+=e[0],1):(I=!0,0)}function m(e){const t=e[0],i=n.substring(e.index),o=p(N,e,i);if(!o)return ce;const s=N;N.endScope&&N.endScope._wrap?(d(),g(t,N.endScope._wrap)):N.endScope&&N.endScope._multi?(d(),h(N.endScope,e)):s.skip?O+=t:(s.returnEnd||s.excludeEnd||(O+=t),d(),s.excludeEnd&&(O=t));do{N.scope&&M.closeNode(),N.skip||N.subLanguage||(R+=N.relevance),N=N.parent}while(N!==o.parent);return o.starts&&f(o.starts,e),s.returnEnd?0:t.length}let _={};function w(i,s){const a=s&&s[0];if(O+=i,null==a)return d(),0;if("begin"===_.type&&"end"===s.type&&_.index===s.index&&""===a){if(O+=n.slice(s.index,s.index+1),!r){const n=new Error(`0 width match regex (${e})`);throw n.languageName=e,n.badRule=_.rule,n}return 1}if(_=s,"begin"===s.type)return function(e){const n=e[0],i=e.rule,o=new t(i),s=[i.__beforeBegin,i["on:begin"]];for(const t of s)if(t&&(t(e,o),o.isMatchIgnored))return b(n);return i.skip?O+=n:(i.excludeBegin&&(O+=n),d(),i.returnBegin||i.excludeBegin||(O=n)),f(i,e),i.returnBegin?0:n.length}(s);if("illegal"===s.type&&!o){const e=new Error('Illegal lexeme "'+a+'" for mode "'+(N.scope||"")+'"');throw e.mode=N,e}if("end"===s.type){const e=m(s);if(e!==ce)return e}if("illegal"===s.type&&""===a)return 1;if($>1e5&&$>3*s.index)throw new Error("potential infinite loop, way more iterations than matches");return O+=a,a.length}const k=y(e);if(!k)throw J(a.replace("{}",e)),new Error('Unknown language: "'+e+'"');const v=ie(k);let A="",N=s||v;const S={},M=new u.__emitter(u);!function(){const e=[];for(let n=N;n!==k;n=n.parent)n.scope&&e.unshift(n.scope);e.forEach((e=>M.openNode(e)))}();let O="",R=0,T=0,$=0,I=!1;try{if(k.__emitTokens)k.__emitTokens(n,M);else{for(N.matcher.considerAll();;){$++,I?I=!1:N.matcher.considerAll(),N.matcher.lastIndex=T;const e=N.matcher.exec(n);if(!e)break;const t=w(n.substring(T,e.index),e);T=e.index+t}w(n.substring(T))}return M.finalize(),A=M.toHTML(),{language:e,value:A,relevance:R,illegal:!1,_emitter:M,_top:N}}catch(t){if(t.message&&t.message.includes("Illegal"))return{language:e,value:re(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:T,context:n.slice(T-100,T+100),mode:t.mode,resultSoFar:A},_emitter:M};if(r)return{language:e,value:re(n),illegal:!1,relevance:0,errorRaised:t,_emitter:M,_top:N};throw t}}function x(e,n){n=n||u.languages||Object.keys(i);const t=function(e){const n={value:re(e),illegal:!1,relevance:0,_top:c,_emitter:new u.__emitter(u)};return n._emitter.addText(e),n}(e),o=n.filter(y).filter(A).map((n=>E(n,e,!1)));o.unshift(t);const s=o.sort(((e,n)=>{if(e.relevance!==n.relevance)return n.relevance-e.relevance;if(e.language&&n.language){if(y(e.language).supersetOf===n.language)return 1;if(y(n.language).supersetOf===e.language)return-1}return 0})),[r,a]=s,l=r;return l.secondBest=a,l}function _(e){let n=null;const t=function(e){let n=e.className+" ";n+=e.parentNode?e.parentNode.className:"";const t=u.languageDetectRe.exec(n);if(t){const n=y(t[1]);return n||(Y(a.replace("{}",t[1])),Y("Falling back to no-highlight mode for this block.",e)),n?t[1]:"no-highlight"}return n.split(/\s+/).find((e=>b(e)||y(e)))}(e);if(b(t))return;if(N("before:highlightElement",{el:e,language:t}),e.dataset.highlighted)return void console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);if(e.children.length>0&&(u.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(e)),u.throwUnescapedHTML))throw new se("One of your code blocks includes unescaped HTML.",e.innerHTML);n=e;const i=n.textContent,s=t?m(i,{language:t,ignoreIllegals:!0}):x(i);e.innerHTML=s.value,e.dataset.highlighted="yes",function(e,n,t){const i=n&&o[n]||t;e.classList.add("hljs"),e.classList.add(`language-${i}`)}(e,t,s.language),e.result={language:s.language,re:s.relevance,relevance:s.relevance},s.secondBest&&(e.secondBest={language:s.secondBest.language,relevance:s.secondBest.relevance}),N("after:highlightElement",{el:e,result:s,text:i})}let w=!1;function k(){"loading"!==document.readyState?document.querySelectorAll(u.cssSelector).forEach(_):w=!0}function y(e){return e=(e||"").toLowerCase(),i[e]||i[o[e]]}function v(e,{languageName:n}){"string"==typeof e&&(e=[e]),e.forEach((e=>{o[e.toLowerCase()]=n}))}function A(e){const n=y(e);return n&&!n.disableAutodetect}function N(e,n){const t=e;s.forEach((function(e){e[t]&&e[t](n)}))}"undefined"!=typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",(function(){w&&k()}),!1),Object.assign(e,{highlight:m,highlightAuto:x,highlightAll:k,highlightElement:_,highlightBlock:function(e){return Q("10.7.0","highlightBlock will be removed entirely in v12.0"),Q("10.7.0","Please use highlightElement now."),_(e)},configure:function(e){u=ae(u,e)},initHighlighting:()=>{k(),Q("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")},initHighlightingOnLoad:function(){k(),Q("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")},registerLanguage:function(n,t){let o=null;try{o=t(e)}catch(e){if(J("Language definition for '{}' could not be registered.".replace("{}",n)),!r)throw e;J(e),o=c}o.name||(o.name=n),i[n]=o,o.rawDefinition=t.bind(null,e),o.aliases&&v(o.aliases,{languageName:n})},unregisterLanguage:function(e){delete i[e];for(const n of Object.keys(o))o[n]===e&&delete o[n]},listLanguages:function(){return Object.keys(i)},getLanguage:y,registerAliases:v,autoDetection:A,inherit:ae,addPlugin:function(e){!function(e){e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=n=>{e["before:highlightBlock"](Object.assign({block:n.el},n))}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=n=>{e["after:highlightBlock"](Object.assign({block:n.el},n))})}(e),s.push(e)},removePlugin:function(e){const n=s.indexOf(e);-1!==n&&s.splice(n,1)}}),e.debugMode=function(){r=!1},e.safeMode=function(){r=!0},e.versionString="11.9.0",e.regex={concat:f,lookahead:d,either:p,optional:h,anyNumberOfTimes:g};for(const e in D)"object"==typeof D[e]&&n(D[e]);return Object.assign(e,D),e},ue=le({});ue.newInstance=()=>le({}),e.exports=ue,ue.HighlightJS=ue,ue.default=ue}},n={};function t(i){var o=n[i];if(void 0!==o)return o.exports;var s=n[i]={exports:{}};return e[i](s,s.exports,t),s.exports}(()=>{"use strict";Shiny;const e=t(390);e.registerLanguage("r",(function(e){const n=e.regex,t=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,i=n.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),o=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,s=n.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:t,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:n.lookahead(n.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:t},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[o,i]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,i]},{scope:{1:"punctuation",2:"number"},match:[s,i]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,i]}]},{scope:{3:"operator"},match:[t,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:o},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:s},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}})),$((()=>{$(document).on("shiny:value",(n=>{n.name.match(/-code$/)&&($(`#${n.name}`).addClass("language-r"),setTimeout((()=>{e.highlightElement(document.getElementById(n.name))}),250))}))}));const n=()=>{$(".block-copy-code").each(((e,n)=>{$(n).off("click"),$(n).on("click",(e=>{var n;n=$(e.target).closest("div").find("pre"),navigator.clipboard.writeText($(n).text())}))})),$(".stack-copy-code").each(((e,n)=>{$(n).off("click"),$(n).on("click",(e=>{const n=$(e.target).closest(".stack").find("pre");let t=[];n.each(((e,n)=>{t.push($(n).text())})),t=t.join(" |>\n"),navigator.clipboard.writeText(t)}))}))};Shiny.addCustomMessageHandler("blockr-bind-stack",(e=>{const t=`#${e.stack}`;setTimeout((()=>{(e=>{$(e).find(".stack-remove").each(((e,n)=>{"true"!=n.getAttribute("listener")&&$(n).on("click",(e=>{const n=$(e.target).closest(".stack"),t=n.closest(".masonry-item");n.remove(),0!==t.length&&t.remove()}))}))})(t),(e=>{(e=>{const n=$(e).find(".stack-edit-toggle");$(n).hasClass("block-bound")||($(n).addClass("block-bound"),$(n).on("click",(e=>{const n=$(e.target).closest(".stack").find(".block");$(e.currentTarget).toggleClass("etidable");const t=$(e.currentTarget).hasClass("etidable");n.each(((e,i)=>{const o=$(i);return t?(o.removeClass("d-none"),o.find(".block-title").removeClass("d-none"),void(e==n.length-1&&(o.find(".block-output").addClass("show"),o.find(".block-output").removeClass("d-none"),o.find(".block-output").trigger("shown")))):(o.find(".block-title").addClass("d-none"),e==n.length-1?(o.removeClass("d-none"),o.find(".block-output").addClass("show"),o.find(".block-output").removeClass("d-none"),void o.find(".block-output").trigger("shown")):void o.addClass("d-none"))}))})))})(e),(e=>{$(e).each(((e,n)=>{(e=>{const n=$(e).find(".block").last();n.removeClass("d-none");const t=n.find(".block-output");n.find(".block-title").addClass("d-none"),t.removeClass("d-none"),t.trigger("shown")})(n)}))})(e),(e=>{$(e).find(".block-output-toggle").each(((e,n)=>{$(n).hasClass("block-bound")||($(n).addClass("block-bound"),$(n).on("click",(e=>{const n=$(e.target).closest(".block"),t=n.find(".block-output").is(":visible"),i=n.find(".block-input").is(":visible");t||i?(n.find(".block-inputs").addClass("d-none"),n.find(".block-output").addClass("d-none")):(n.find(".block-inputs").removeClass("d-none"),n.find(".block-output").removeClass("d-none"));let o="shown";n.find(".block-output").hasClass("d-none")&&(o="hidden"),n.find(".block-inputs").trigger(o),n.find(".block-output").trigger(o)})))}))})(e)})(t),n()}),750)})),Shiny.addCustomMessageHandler("blockr-add-block",(e=>{e.stack,setTimeout((()=>{n()}),500)}))})()})(); \ No newline at end of file diff --git a/inst/assets/style.min.css b/inst/assets/style.min.css index 0fdd0bd1..8f713c75 100644 --- a/inst/assets/style.min.css +++ b/inst/assets/style.min.css @@ -1 +1 @@ -html .hidden{display:none}html .shown{display:block}html .block-code-output{max-height:10rem;overflow-y:auto}html .block{overflow-y:auto}html .block .block-output{overflow-y:hidden}html .block pre{border-radius:0}html .block .block-output-toggle{color:var(--bs-gray)}html .block .block-output-toggle:hover{color:var(--bs-success)}html .block .block-code-toggle{color:var(--bs-gray)}html .block .block-code-toggle:hover{color:var(--bs-info)}html .block .block-remove{color:var(--bs-gray)}html .block .block-remove:hover{color:var(--bs-danger)}html .block .block-remove,html .block .block-output-toggle,html .block .block-edit-toggle,html .block .block-code-toggle{opacity:0}html .block:hover .block-remove,html .block:hover .block-output-toggle,html .block:hover .block-edit-toggle,html .block:hover .block-code-toggle{opacity:1}html .stack-code-output{max-height:10rem;overflow:auto}html .stack .stack-edit-toggle{color:var(--bs-gray);cursor:pointer}html .stack .stack-edit-toggle:hover{color:var(--bs-primary)}html .stack .stack-copy-code{color:var(--bs-gray);cursor:pointer}html .stack .stack-copy-code:hover{color:var(--bs-info)}html .stack .stack-remove{color:var(--bs-gray)}html .stack .stack-remove:hover{color:var(--bs-danger)}html .stack .stack-remove,html .stack .stack-copy-code,html .stack .stack-edit-toggle{opacity:0}html .stack:hover .stack-remove,html .stack:hover .stack-copy-code,html .stack:hover .stack-edit-toggle{opacity:1} +html .hidden{display:none}html .shown{display:block}html .block-code-output{max-height:10rem;overflow-y:auto}html .block{overflow-y:auto}html .block .block-output{overflow-y:hidden}html .block pre{border-radius:0}html .block .block-output-toggle{color:var(--bs-gray)}html .block .block-output-toggle:hover{color:var(--bs-success)}html .block .block-code-toggle{color:var(--bs-gray)}html .block .block-code-toggle:hover{color:var(--bs-info)}html .block .block-remove{color:var(--bs-gray)}html .block .block-remove:hover{color:var(--bs-danger)}html .block .block-feedback{font-size:.8rem}html .block .block-remove,html .block .block-output-toggle,html .block .block-edit-toggle,html .block .block-code-toggle{opacity:0}html .block:hover .block-remove,html .block:hover .block-output-toggle,html .block:hover .block-edit-toggle,html .block:hover .block-code-toggle{opacity:1}html .stack-code-output{max-height:10rem;overflow:auto}html .stack .stack-edit-toggle{color:var(--bs-gray);cursor:pointer}html .stack .stack-edit-toggle:hover{color:var(--bs-primary)}html .stack .stack-copy-code{color:var(--bs-gray);cursor:pointer}html .stack .stack-copy-code:hover{color:var(--bs-info)}html .stack .stack-remove{color:var(--bs-gray)}html .stack .stack-remove:hover{color:var(--bs-danger)}html .stack .stack-remove,html .stack .stack-copy-code,html .stack .stack-edit-toggle{opacity:0}html .stack:hover .stack-remove,html .stack:hover .stack-copy-code,html .stack:hover .stack-edit-toggle{opacity:1} diff --git a/man/generate_ui.Rd b/man/generate_ui.Rd index 2caccf60..059fbc4d 100644 --- a/man/generate_ui.Rd +++ b/man/generate_ui.Rd @@ -32,10 +32,10 @@ \alias{ui_update.numeric_field} \alias{ui_update.hidden_field} \alias{ui_update.list_field} -\alias{uiOutput} -\alias{uiOutput.block} -\alias{uiOutput.plot_block} -\alias{uiOutput.ggiraph_block} +\alias{uiOutputBlock} +\alias{uiOutputBlock.block} +\alias{uiOutputBlock.plot_block} +\alias{uiOutputBlock.ggiraph_block} \alias{uiCode} \alias{uiCode.block} \title{UI} @@ -102,13 +102,13 @@ ui_update(x, session, id, name) \method{ui_update}{list_field}(x, session, id, name) -uiOutput(x, ns) +uiOutputBlock(x, ns) -\method{uiOutput}{block}(x, ns) +\method{uiOutputBlock}{block}(x, ns) -\method{uiOutput}{plot_block}(x, ns) +\method{uiOutputBlock}{plot_block}(x, ns) -\method{uiOutput}{ggiraph_block}(x, ns) +\method{uiOutputBlock}{ggiraph_block}(x, ns) uiCode(x, ns) diff --git a/man/new_block.Rd b/man/new_block.Rd index dce2e100..a8599b75 100644 --- a/man/new_block.Rd +++ b/man/new_block.Rd @@ -185,7 +185,7 @@ new_cheat_block(data, ...) cheat_block(data, ...) -new_asfactor_block(data, column = character(), ...) +new_asfactor_block(data, column = "VISIT", ...) asfactor_block(data, ...) diff --git a/scss/_block.scss b/scss/_block.scss index 13ebad4e..2907829e 100644 --- a/scss/_block.scss +++ b/scss/_block.scss @@ -37,6 +37,10 @@ html { } } + .block-feedback { + font-size: .8rem; + } + .block-remove, .block-output-toggle, .block-edit-toggle, diff --git a/srcjs/collapse.js b/srcjs/collapse.js index 768e149f..a28dac43 100644 --- a/srcjs/collapse.js +++ b/srcjs/collapse.js @@ -1,16 +1,54 @@ export const collapse = (stack) => { editor(stack); showLastOutputs(stack); + toggleOutputInput(stack); +}; + +const toggleOutputInput = (stack) => { + $(stack).find(".block-output-toggle").each((_index, btn) => { + // already has a listener + if ($(btn).hasClass("block-bound")) { + return; + } + + $(btn).addClass("block-bound"); + + $(btn).on("click", (event) => { + const $block = $(event.target).closest(".block"); + + const outputVisible = $block.find(".block-output").is(":visible"); + const inputVisible = $block.find(".block-input").is(":visible"); + + const toggle = outputVisible || inputVisible; + + if (toggle) { + $block.find(".block-inputs").addClass("d-none"); + $block.find(".block-output").addClass("d-none"); + } else { + $block.find(".block-inputs").removeClass("d-none"); + $block.find(".block-output").removeClass("d-none"); + } + + let ev = "shown"; + if ($block.find(".block-output").hasClass("d-none")) { + ev = "hidden"; + } + + $block.find(".block-inputs").trigger(ev); + $block.find(".block-output").trigger(ev); + }); + }); }; const editor = (stack) => { const editBtn = $(stack).find(".stack-edit-toggle"); // already has a listener - if (editBtn[0].getAttribute("listener")) { + if ($(editBtn).hasClass("block-bound")) { return; } + $(editBtn).addClass("block-bound"); $(editBtn).on("click", (event) => { const $stack = $(event.target).closest(".stack"); const $blocks = $stack.find(".block"); @@ -23,8 +61,7 @@ const editor = (stack) => { if (editable) { $block.removeClass("d-none"); - $block.find(".block-inputs").removeClass("d-none"); - $block.find(".block-inputs").trigger("shown"); + $block.find(".block-title").removeClass("d-none"); if (index == ($blocks.length - 1)) { $block.find(".block-output").addClass("show"); @@ -34,9 +71,7 @@ const editor = (stack) => { return; } - $block.find(".block-inputs").addClass("d-none"); - $block.find(".block-inputs").trigger("hidden"); - + $block.find(".block-title").addClass("d-none"); if (index == ($blocks.length - 1)) { $block.removeClass("d-none"); @@ -55,10 +90,12 @@ export const showLastOutput = (el) => { const $block = $(el).find(".block").last(); $block.removeClass("d-none"); - const lastOutput = $block.find(".block-output"); + const $lastOutput = $block.find(".block-output"); + const $lastTitle = $block.find(".block-title"); - bootstrap.Collapse.getOrCreateInstance(lastOutput, { toggle: false }).show(); - $(lastOutput).trigger("shown"); + $lastTitle.addClass("d-none"); + $lastOutput.removeClass("d-none"); + $lastOutput.trigger("shown"); }; const showLastOutputs = (stack) => { diff --git a/srcjs/shiny.js b/srcjs/shiny.js index ea54c8db..8736ab5d 100644 --- a/srcjs/shiny.js +++ b/srcjs/shiny.js @@ -16,7 +16,6 @@ Shiny.addCustomMessageHandler("blockr-add-block", (msg) => { // TODO remove this // be event based/async instead of timeout setTimeout(() => { - showLastOutput(stack); copyCode(); }, 500); }); diff --git a/test.R b/test.R index a8c75b0c..37e4cc70 100644 --- a/test.R +++ b/test.R @@ -4,7 +4,7 @@ library(shiny) stack <- new_stack( demo_data_block, - demo_select_block + select_block ) ui <- fluidPage( From b37e0bbb339f72f6c4cf59ef502de0877a077426 Mon Sep 17 00:00:00 2001 From: John Coene Date: Fri, 27 Oct 2023 18:46:25 +0200 Subject: [PATCH 3/3] fix: initialise with shown output --- R/ui.R | 2 +- inst/assets/index.js | 2 +- srcjs/collapse.js | 2 +- srcjs/shiny.js | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/R/ui.R b/R/ui.R index f63bd714..224cf43d 100644 --- a/R/ui.R +++ b/R/ui.R @@ -62,7 +62,7 @@ generate_ui.block <- function(x, id, ..., .hidden = TRUE) { uiCode(x, ns) ), div( - class = "d-none block-output", + class = sprintf("%s block-output", inputs_hidden), id = output_id, uiOutputBlock(x, ns) ) diff --git a/inst/assets/index.js b/inst/assets/index.js index 81070acc..0d7983e6 100644 --- a/inst/assets/index.js +++ b/inst/assets/index.js @@ -1 +1 @@ -(()=>{var e={390:e=>{function n(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach((t=>{const i=e[t],o=typeof i;"object"!==o&&"function"!==o||Object.isFrozen(i)||n(i)})),e}class t{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function i(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function o(e,...n){const t=Object.create(null);for(const n in e)t[n]=e[n];return n.forEach((function(e){for(const n in e)t[n]=e[n]})),t}const s=e=>!!e.scope;class r{constructor(e,n){this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!s(e))return;const n=((e,{prefix:n})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const t=e.split(".");return[`${n}${t.shift()}`,...t.map(((e,n)=>`${e}${"_".repeat(n+1)}`))].join(" ")}return`${n}${e}`})(e.scope,{prefix:this.classPrefix});this.span(n)}closeNode(e){s(e)&&(this.buffer+="")}value(){return this.buffer}span(e){this.buffer+=``}}const a=(e={})=>{const n={children:[]};return Object.assign(n,e),n};class c{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const n=a({scope:e});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){return"string"==typeof n?e.addText(n):n.children&&(e.openNode(n),n.children.forEach((n=>this._walk(e,n))),e.closeNode(n)),e}static _collapse(e){"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{c._collapse(e)})))}}class l extends c{constructor(e){super(),this.options=e}addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,n){const t=e.root;n&&(t.scope=`language:${n}`),this.add(t)}toHTML(){return new r(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function u(e){return e?"string"==typeof e?e:e.source:null}function d(e){return f("(?=",e,")")}function g(e){return f("(?:",e,")*")}function h(e){return f("(?:",e,")?")}function f(...e){return e.map((e=>u(e))).join("")}function p(...e){const n=function(e){const n=e[e.length-1];return"object"==typeof n&&n.constructor===Object?(e.splice(e.length-1,1),n):{}}(e);return"("+(n.capture?"":"?:")+e.map((e=>u(e))).join("|")+")"}function b(e){return new RegExp(e.toString()+"|").exec("").length-1}const m=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function E(e,{joinWith:n}){let t=0;return e.map((e=>{t+=1;const n=t;let i=u(e),o="";for(;i.length>0;){const e=m.exec(i);if(!e){o+=i;break}o+=i.substring(0,e.index),i=i.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?o+="\\"+String(Number(e[1])+n):(o+=e[0],"("===e[0]&&t++)}return o})).map((e=>`(${e})`)).join(n)}const x="[a-zA-Z]\\w*",_="[a-zA-Z_]\\w*",w="\\b\\d+(\\.\\d+)?",k="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",y="\\b(0b[01]+)",v={begin:"\\\\[\\s\\S]",relevance:0},A={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[v]},N={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[v]},S=function(e,n,t={}){const i=o({scope:"comment",begin:e,end:n,contains:[]},t);i.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const s=p("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return i.contains.push({begin:f(/[ ]+/,"(",s,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),i},M=S("//","$"),O=S("/\\*","\\*/"),R=S("#","$"),T={scope:"number",begin:w,relevance:0},$={scope:"number",begin:k,relevance:0},I={scope:"number",begin:y,relevance:0},j={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[v,{begin:/\[/,end:/\]/,relevance:0,contains:[v]}]},C={scope:"title",begin:x,relevance:0},L={scope:"title",begin:_,relevance:0},B={begin:"\\.\\s*"+_,relevance:0};var D=Object.freeze({__proto__:null,APOS_STRING_MODE:A,BACKSLASH_ESCAPE:v,BINARY_NUMBER_MODE:I,BINARY_NUMBER_RE:y,COMMENT:S,C_BLOCK_COMMENT_MODE:O,C_LINE_COMMENT_MODE:M,C_NUMBER_MODE:$,C_NUMBER_RE:k,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,n)=>{n.data._beginMatch=e[1]},"on:end":(e,n)=>{n.data._beginMatch!==e[1]&&n.ignoreMatch()}})},HASH_COMMENT_MODE:R,IDENT_RE:x,MATCH_NOTHING_RE:/\b\B/,METHOD_GUARD:B,NUMBER_MODE:T,NUMBER_RE:w,PHRASAL_WORDS_MODE:{begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},QUOTE_STRING_MODE:N,REGEXP_MODE:j,RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{const n=/^#![ ]*\//;return e.binary&&(e.begin=f(n,/.*\b/,e.binary,/\b.*/)),o({scope:"meta",begin:n,end:/$/,relevance:0,"on:begin":(e,n)=>{0!==e.index&&n.ignoreMatch()}},e)},TITLE_MODE:C,UNDERSCORE_IDENT_RE:_,UNDERSCORE_TITLE_MODE:L});function H(e,n){"."===e.input[e.index-1]&&n.ignoreMatch()}function P(e,n){void 0!==e.className&&(e.scope=e.className,delete e.className)}function z(e,n){n&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=H,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,void 0===e.relevance&&(e.relevance=0))}function U(e,n){Array.isArray(e.illegal)&&(e.illegal=p(...e.illegal))}function G(e,n){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function Z(e,n){void 0===e.relevance&&(e.relevance=1)}const F=(e,n)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const t=Object.assign({},e);Object.keys(e).forEach((n=>{delete e[n]})),e.keywords=t.keywords,e.begin=f(t.beforeMatch,d(t.begin)),e.starts={relevance:0,contains:[Object.assign(t,{endsParent:!0})]},e.relevance=0,delete t.beforeMatch},W=["of","and","for","in","not","or","if","then","parent","list","value"],X="keyword";function K(e,n,t=X){const i=Object.create(null);return"string"==typeof e?o(t,e.split(" ")):Array.isArray(e)?o(t,e):Object.keys(e).forEach((function(t){Object.assign(i,K(e[t],n,t))})),i;function o(e,t){n&&(t=t.map((e=>e.toLowerCase()))),t.forEach((function(n){const t=n.split("|");i[t[0]]=[e,q(t[0],t[1])]}))}}function q(e,n){return n?Number(n):function(e){return W.includes(e.toLowerCase())}(e)?0:1}const V={},J=e=>{console.error(e)},Y=(e,...n)=>{console.log(`WARN: ${e}`,...n)},Q=(e,n)=>{V[`${e}/${n}`]||(console.log(`Deprecated as of ${e}. ${n}`),V[`${e}/${n}`]=!0)},ee=new Error;function ne(e,n,{key:t}){let i=0;const o=e[t],s={},r={};for(let e=1;e<=n.length;e++)r[e+i]=o[e],s[e+i]=!0,i+=b(n[e-1]);e[t]=r,e[t]._emit=s,e[t]._multi=!0}function te(e){!function(e){e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,delete e.scope)}(e),"string"==typeof e.beginScope&&(e.beginScope={_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope}),function(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw J("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ee;if("object"!=typeof e.beginScope||null===e.beginScope)throw J("beginScope must be object"),ee;ne(e,e.begin,{key:"beginScope"}),e.begin=E(e.begin,{joinWith:""})}}(e),function(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw J("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ee;if("object"!=typeof e.endScope||null===e.endScope)throw J("endScope must be object"),ee;ne(e,e.end,{key:"endScope"}),e.end=E(e.end,{joinWith:""})}}(e)}function ie(e){function n(n,t){return new RegExp(u(n),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(t?"g":""))}class t{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,n){n.position=this.position++,this.matchIndexes[this.matchAt]=n,this.regexes.push([n,e]),this.matchAt+=b(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);const e=this.regexes.map((e=>e[1]));this.matcherRe=n(E(e,{joinWith:"|"}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;const n=this.matcherRe.exec(e);if(!n)return null;const t=n.findIndex(((e,n)=>n>0&&void 0!==e)),i=this.matchIndexes[t];return n.splice(0,t),Object.assign(n,i)}}class i{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];const n=new t;return this.rules.slice(e).forEach((([e,t])=>n.addRule(e,t))),n.compile(),this.multiRegexes[e]=n,n}resumingScanAtSamePosition(){return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,n){this.rules.push([e,n]),"begin"===n.type&&this.count++}exec(e){const n=this.getMatcher(this.regexIndex);n.lastIndex=this.lastIndex;let t=n.exec(e);if(this.resumingScanAtSamePosition())if(t&&t.index===this.lastIndex);else{const n=this.getMatcher(0);n.lastIndex=this.lastIndex+1,t=n.exec(e)}return t&&(this.regexIndex+=t.position+1,this.regexIndex===this.count&&this.considerAll()),t}}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=o(e.classNameAliases||{}),function t(s,r){const a=s;if(s.isCompiled)return a;[P,G,te,F].forEach((e=>e(s,r))),e.compilerExtensions.forEach((e=>e(s,r))),s.__beforeBegin=null,[z,U,Z].forEach((e=>e(s,r))),s.isCompiled=!0;let c=null;return"object"==typeof s.keywords&&s.keywords.$pattern&&(s.keywords=Object.assign({},s.keywords),c=s.keywords.$pattern,delete s.keywords.$pattern),c=c||/\w+/,s.keywords&&(s.keywords=K(s.keywords,e.case_insensitive)),a.keywordPatternRe=n(c,!0),r&&(s.begin||(s.begin=/\B|\b/),a.beginRe=n(a.begin),s.end||s.endsWithParent||(s.end=/\B|\b/),s.end&&(a.endRe=n(a.end)),a.terminatorEnd=u(a.end)||"",s.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(s.end?"|":"")+r.terminatorEnd)),s.illegal&&(a.illegalRe=n(s.illegal)),s.contains||(s.contains=[]),s.contains=[].concat(...s.contains.map((function(e){return function(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((function(n){return o(e,{variants:null},n)}))),e.cachedVariants?e.cachedVariants:oe(e)?o(e,{starts:e.starts?o(e.starts):null}):Object.isFrozen(e)?o(e):e}("self"===e?s:e)}))),s.contains.forEach((function(e){t(e,a)})),s.starts&&t(s.starts,r),a.matcher=function(e){const n=new i;return e.contains.forEach((e=>n.addRule(e.begin,{rule:e,type:"begin"}))),e.terminatorEnd&&n.addRule(e.terminatorEnd,{type:"end"}),e.illegal&&n.addRule(e.illegal,{type:"illegal"}),n}(a),a}(e)}function oe(e){return!!e&&(e.endsWithParent||oe(e.starts))}class se extends Error{constructor(e,n){super(e),this.name="HTMLInjectionError",this.html=n}}const re=i,ae=o,ce=Symbol("nomatch"),le=function(e){const i=Object.create(null),o=Object.create(null),s=[];let r=!0;const a="Could not find the language '{}', did you forget to load/include a language module?",c={disableAutodetect:!0,name:"Plain text",contains:[]};let u={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:l};function b(e){return u.noHighlightRe.test(e)}function m(e,n,t){let i="",o="";"object"==typeof n?(i=e,t=n.ignoreIllegals,o=n.language):(Q("10.7.0","highlight(lang, code, ...args) has been deprecated."),Q("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),o=e,i=n),void 0===t&&(t=!0);const s={code:i,language:o};N("before:highlight",s);const r=s.result?s.result:E(s.language,s.code,t);return r.code=s.code,N("after:highlight",r),r}function E(e,n,o,s){const c=Object.create(null);function l(){if(!N.keywords)return void M.addText(O);let e=0;N.keywordPatternRe.lastIndex=0;let n=N.keywordPatternRe.exec(O),t="";for(;n;){t+=O.substring(e,n.index);const o=k.case_insensitive?n[0].toLowerCase():n[0],s=(i=o,N.keywords[i]);if(s){const[e,i]=s;if(M.addText(t),t="",c[o]=(c[o]||0)+1,c[o]<=7&&(R+=i),e.startsWith("_"))t+=n[0];else{const t=k.classNameAliases[e]||e;g(n[0],t)}}else t+=n[0];e=N.keywordPatternRe.lastIndex,n=N.keywordPatternRe.exec(O)}var i;t+=O.substring(e),M.addText(t)}function d(){null!=N.subLanguage?function(){if(""===O)return;let e=null;if("string"==typeof N.subLanguage){if(!i[N.subLanguage])return void M.addText(O);e=E(N.subLanguage,O,!0,S[N.subLanguage]),S[N.subLanguage]=e._top}else e=x(O,N.subLanguage.length?N.subLanguage:null);N.relevance>0&&(R+=e.relevance),M.__addSublanguage(e._emitter,e.language)}():l(),O=""}function g(e,n){""!==e&&(M.startScope(n),M.addText(e),M.endScope())}function h(e,n){let t=1;const i=n.length-1;for(;t<=i;){if(!e._emit[t]){t++;continue}const i=k.classNameAliases[e[t]]||e[t],o=n[t];i?g(o,i):(O=o,l(),O=""),t++}}function f(e,n){return e.scope&&"string"==typeof e.scope&&M.openNode(k.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(g(O,k.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),O=""):e.beginScope._multi&&(h(e.beginScope,n),O="")),N=Object.create(e,{parent:{value:N}}),N}function p(e,n,i){let o=function(e,n){const t=e&&e.exec(n);return t&&0===t.index}(e.endRe,i);if(o){if(e["on:end"]){const i=new t(e);e["on:end"](n,i),i.isMatchIgnored&&(o=!1)}if(o){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return p(e.parent,n,i)}function b(e){return 0===N.matcher.regexIndex?(O+=e[0],1):(I=!0,0)}function m(e){const t=e[0],i=n.substring(e.index),o=p(N,e,i);if(!o)return ce;const s=N;N.endScope&&N.endScope._wrap?(d(),g(t,N.endScope._wrap)):N.endScope&&N.endScope._multi?(d(),h(N.endScope,e)):s.skip?O+=t:(s.returnEnd||s.excludeEnd||(O+=t),d(),s.excludeEnd&&(O=t));do{N.scope&&M.closeNode(),N.skip||N.subLanguage||(R+=N.relevance),N=N.parent}while(N!==o.parent);return o.starts&&f(o.starts,e),s.returnEnd?0:t.length}let _={};function w(i,s){const a=s&&s[0];if(O+=i,null==a)return d(),0;if("begin"===_.type&&"end"===s.type&&_.index===s.index&&""===a){if(O+=n.slice(s.index,s.index+1),!r){const n=new Error(`0 width match regex (${e})`);throw n.languageName=e,n.badRule=_.rule,n}return 1}if(_=s,"begin"===s.type)return function(e){const n=e[0],i=e.rule,o=new t(i),s=[i.__beforeBegin,i["on:begin"]];for(const t of s)if(t&&(t(e,o),o.isMatchIgnored))return b(n);return i.skip?O+=n:(i.excludeBegin&&(O+=n),d(),i.returnBegin||i.excludeBegin||(O=n)),f(i,e),i.returnBegin?0:n.length}(s);if("illegal"===s.type&&!o){const e=new Error('Illegal lexeme "'+a+'" for mode "'+(N.scope||"")+'"');throw e.mode=N,e}if("end"===s.type){const e=m(s);if(e!==ce)return e}if("illegal"===s.type&&""===a)return 1;if($>1e5&&$>3*s.index)throw new Error("potential infinite loop, way more iterations than matches");return O+=a,a.length}const k=y(e);if(!k)throw J(a.replace("{}",e)),new Error('Unknown language: "'+e+'"');const v=ie(k);let A="",N=s||v;const S={},M=new u.__emitter(u);!function(){const e=[];for(let n=N;n!==k;n=n.parent)n.scope&&e.unshift(n.scope);e.forEach((e=>M.openNode(e)))}();let O="",R=0,T=0,$=0,I=!1;try{if(k.__emitTokens)k.__emitTokens(n,M);else{for(N.matcher.considerAll();;){$++,I?I=!1:N.matcher.considerAll(),N.matcher.lastIndex=T;const e=N.matcher.exec(n);if(!e)break;const t=w(n.substring(T,e.index),e);T=e.index+t}w(n.substring(T))}return M.finalize(),A=M.toHTML(),{language:e,value:A,relevance:R,illegal:!1,_emitter:M,_top:N}}catch(t){if(t.message&&t.message.includes("Illegal"))return{language:e,value:re(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:T,context:n.slice(T-100,T+100),mode:t.mode,resultSoFar:A},_emitter:M};if(r)return{language:e,value:re(n),illegal:!1,relevance:0,errorRaised:t,_emitter:M,_top:N};throw t}}function x(e,n){n=n||u.languages||Object.keys(i);const t=function(e){const n={value:re(e),illegal:!1,relevance:0,_top:c,_emitter:new u.__emitter(u)};return n._emitter.addText(e),n}(e),o=n.filter(y).filter(A).map((n=>E(n,e,!1)));o.unshift(t);const s=o.sort(((e,n)=>{if(e.relevance!==n.relevance)return n.relevance-e.relevance;if(e.language&&n.language){if(y(e.language).supersetOf===n.language)return 1;if(y(n.language).supersetOf===e.language)return-1}return 0})),[r,a]=s,l=r;return l.secondBest=a,l}function _(e){let n=null;const t=function(e){let n=e.className+" ";n+=e.parentNode?e.parentNode.className:"";const t=u.languageDetectRe.exec(n);if(t){const n=y(t[1]);return n||(Y(a.replace("{}",t[1])),Y("Falling back to no-highlight mode for this block.",e)),n?t[1]:"no-highlight"}return n.split(/\s+/).find((e=>b(e)||y(e)))}(e);if(b(t))return;if(N("before:highlightElement",{el:e,language:t}),e.dataset.highlighted)return void console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);if(e.children.length>0&&(u.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(e)),u.throwUnescapedHTML))throw new se("One of your code blocks includes unescaped HTML.",e.innerHTML);n=e;const i=n.textContent,s=t?m(i,{language:t,ignoreIllegals:!0}):x(i);e.innerHTML=s.value,e.dataset.highlighted="yes",function(e,n,t){const i=n&&o[n]||t;e.classList.add("hljs"),e.classList.add(`language-${i}`)}(e,t,s.language),e.result={language:s.language,re:s.relevance,relevance:s.relevance},s.secondBest&&(e.secondBest={language:s.secondBest.language,relevance:s.secondBest.relevance}),N("after:highlightElement",{el:e,result:s,text:i})}let w=!1;function k(){"loading"!==document.readyState?document.querySelectorAll(u.cssSelector).forEach(_):w=!0}function y(e){return e=(e||"").toLowerCase(),i[e]||i[o[e]]}function v(e,{languageName:n}){"string"==typeof e&&(e=[e]),e.forEach((e=>{o[e.toLowerCase()]=n}))}function A(e){const n=y(e);return n&&!n.disableAutodetect}function N(e,n){const t=e;s.forEach((function(e){e[t]&&e[t](n)}))}"undefined"!=typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",(function(){w&&k()}),!1),Object.assign(e,{highlight:m,highlightAuto:x,highlightAll:k,highlightElement:_,highlightBlock:function(e){return Q("10.7.0","highlightBlock will be removed entirely in v12.0"),Q("10.7.0","Please use highlightElement now."),_(e)},configure:function(e){u=ae(u,e)},initHighlighting:()=>{k(),Q("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")},initHighlightingOnLoad:function(){k(),Q("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")},registerLanguage:function(n,t){let o=null;try{o=t(e)}catch(e){if(J("Language definition for '{}' could not be registered.".replace("{}",n)),!r)throw e;J(e),o=c}o.name||(o.name=n),i[n]=o,o.rawDefinition=t.bind(null,e),o.aliases&&v(o.aliases,{languageName:n})},unregisterLanguage:function(e){delete i[e];for(const n of Object.keys(o))o[n]===e&&delete o[n]},listLanguages:function(){return Object.keys(i)},getLanguage:y,registerAliases:v,autoDetection:A,inherit:ae,addPlugin:function(e){!function(e){e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=n=>{e["before:highlightBlock"](Object.assign({block:n.el},n))}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=n=>{e["after:highlightBlock"](Object.assign({block:n.el},n))})}(e),s.push(e)},removePlugin:function(e){const n=s.indexOf(e);-1!==n&&s.splice(n,1)}}),e.debugMode=function(){r=!1},e.safeMode=function(){r=!0},e.versionString="11.9.0",e.regex={concat:f,lookahead:d,either:p,optional:h,anyNumberOfTimes:g};for(const e in D)"object"==typeof D[e]&&n(D[e]);return Object.assign(e,D),e},ue=le({});ue.newInstance=()=>le({}),e.exports=ue,ue.HighlightJS=ue,ue.default=ue}},n={};function t(i){var o=n[i];if(void 0!==o)return o.exports;var s=n[i]={exports:{}};return e[i](s,s.exports,t),s.exports}(()=>{"use strict";Shiny;const e=t(390);e.registerLanguage("r",(function(e){const n=e.regex,t=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,i=n.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),o=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,s=n.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:t,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:n.lookahead(n.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:t},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[o,i]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,i]},{scope:{1:"punctuation",2:"number"},match:[s,i]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,i]}]},{scope:{3:"operator"},match:[t,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:o},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:s},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}})),$((()=>{$(document).on("shiny:value",(n=>{n.name.match(/-code$/)&&($(`#${n.name}`).addClass("language-r"),setTimeout((()=>{e.highlightElement(document.getElementById(n.name))}),250))}))}));const n=()=>{$(".block-copy-code").each(((e,n)=>{$(n).off("click"),$(n).on("click",(e=>{var n;n=$(e.target).closest("div").find("pre"),navigator.clipboard.writeText($(n).text())}))})),$(".stack-copy-code").each(((e,n)=>{$(n).off("click"),$(n).on("click",(e=>{const n=$(e.target).closest(".stack").find("pre");let t=[];n.each(((e,n)=>{t.push($(n).text())})),t=t.join(" |>\n"),navigator.clipboard.writeText(t)}))}))};Shiny.addCustomMessageHandler("blockr-bind-stack",(e=>{const t=`#${e.stack}`;setTimeout((()=>{(e=>{$(e).find(".stack-remove").each(((e,n)=>{"true"!=n.getAttribute("listener")&&$(n).on("click",(e=>{const n=$(e.target).closest(".stack"),t=n.closest(".masonry-item");n.remove(),0!==t.length&&t.remove()}))}))})(t),(e=>{(e=>{const n=$(e).find(".stack-edit-toggle");$(n).hasClass("block-bound")||($(n).addClass("block-bound"),$(n).on("click",(e=>{const n=$(e.target).closest(".stack").find(".block");$(e.currentTarget).toggleClass("etidable");const t=$(e.currentTarget).hasClass("etidable");n.each(((e,i)=>{const o=$(i);return t?(o.removeClass("d-none"),o.find(".block-title").removeClass("d-none"),void(e==n.length-1&&(o.find(".block-output").addClass("show"),o.find(".block-output").removeClass("d-none"),o.find(".block-output").trigger("shown")))):(o.find(".block-title").addClass("d-none"),e==n.length-1?(o.removeClass("d-none"),o.find(".block-output").addClass("show"),o.find(".block-output").removeClass("d-none"),void o.find(".block-output").trigger("shown")):void o.addClass("d-none"))}))})))})(e),(e=>{$(e).each(((e,n)=>{(e=>{const n=$(e).find(".block").last();n.removeClass("d-none");const t=n.find(".block-output");n.find(".block-title").addClass("d-none"),t.removeClass("d-none"),t.trigger("shown")})(n)}))})(e),(e=>{$(e).find(".block-output-toggle").each(((e,n)=>{$(n).hasClass("block-bound")||($(n).addClass("block-bound"),$(n).on("click",(e=>{const n=$(e.target).closest(".block"),t=n.find(".block-output").is(":visible"),i=n.find(".block-input").is(":visible");t||i?(n.find(".block-inputs").addClass("d-none"),n.find(".block-output").addClass("d-none")):(n.find(".block-inputs").removeClass("d-none"),n.find(".block-output").removeClass("d-none"));let o="shown";n.find(".block-output").hasClass("d-none")&&(o="hidden"),n.find(".block-inputs").trigger(o),n.find(".block-output").trigger(o)})))}))})(e)})(t),n()}),750)})),Shiny.addCustomMessageHandler("blockr-add-block",(e=>{e.stack,setTimeout((()=>{n()}),500)}))})()})(); \ No newline at end of file +(()=>{var e={390:e=>{function n(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach((t=>{const i=e[t],o=typeof i;"object"!==o&&"function"!==o||Object.isFrozen(i)||n(i)})),e}class t{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function i(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function o(e,...n){const t=Object.create(null);for(const n in e)t[n]=e[n];return n.forEach((function(e){for(const n in e)t[n]=e[n]})),t}const s=e=>!!e.scope;class r{constructor(e,n){this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!s(e))return;const n=((e,{prefix:n})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const t=e.split(".");return[`${n}${t.shift()}`,...t.map(((e,n)=>`${e}${"_".repeat(n+1)}`))].join(" ")}return`${n}${e}`})(e.scope,{prefix:this.classPrefix});this.span(n)}closeNode(e){s(e)&&(this.buffer+="")}value(){return this.buffer}span(e){this.buffer+=``}}const a=(e={})=>{const n={children:[]};return Object.assign(n,e),n};class c{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const n=a({scope:e});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){return"string"==typeof n?e.addText(n):n.children&&(e.openNode(n),n.children.forEach((n=>this._walk(e,n))),e.closeNode(n)),e}static _collapse(e){"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{c._collapse(e)})))}}class l extends c{constructor(e){super(),this.options=e}addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,n){const t=e.root;n&&(t.scope=`language:${n}`),this.add(t)}toHTML(){return new r(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function u(e){return e?"string"==typeof e?e:e.source:null}function d(e){return f("(?=",e,")")}function g(e){return f("(?:",e,")*")}function h(e){return f("(?:",e,")?")}function f(...e){return e.map((e=>u(e))).join("")}function p(...e){const n=function(e){const n=e[e.length-1];return"object"==typeof n&&n.constructor===Object?(e.splice(e.length-1,1),n):{}}(e);return"("+(n.capture?"":"?:")+e.map((e=>u(e))).join("|")+")"}function b(e){return new RegExp(e.toString()+"|").exec("").length-1}const m=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function E(e,{joinWith:n}){let t=0;return e.map((e=>{t+=1;const n=t;let i=u(e),o="";for(;i.length>0;){const e=m.exec(i);if(!e){o+=i;break}o+=i.substring(0,e.index),i=i.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?o+="\\"+String(Number(e[1])+n):(o+=e[0],"("===e[0]&&t++)}return o})).map((e=>`(${e})`)).join(n)}const x="[a-zA-Z]\\w*",_="[a-zA-Z_]\\w*",w="\\b\\d+(\\.\\d+)?",k="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",y="\\b(0b[01]+)",v={begin:"\\\\[\\s\\S]",relevance:0},A={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[v]},N={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[v]},S=function(e,n,t={}){const i=o({scope:"comment",begin:e,end:n,contains:[]},t);i.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const s=p("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return i.contains.push({begin:f(/[ ]+/,"(",s,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),i},M=S("//","$"),O=S("/\\*","\\*/"),R=S("#","$"),T={scope:"number",begin:w,relevance:0},$={scope:"number",begin:k,relevance:0},I={scope:"number",begin:y,relevance:0},j={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[v,{begin:/\[/,end:/\]/,relevance:0,contains:[v]}]},C={scope:"title",begin:x,relevance:0},L={scope:"title",begin:_,relevance:0},B={begin:"\\.\\s*"+_,relevance:0};var D=Object.freeze({__proto__:null,APOS_STRING_MODE:A,BACKSLASH_ESCAPE:v,BINARY_NUMBER_MODE:I,BINARY_NUMBER_RE:y,COMMENT:S,C_BLOCK_COMMENT_MODE:O,C_LINE_COMMENT_MODE:M,C_NUMBER_MODE:$,C_NUMBER_RE:k,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,n)=>{n.data._beginMatch=e[1]},"on:end":(e,n)=>{n.data._beginMatch!==e[1]&&n.ignoreMatch()}})},HASH_COMMENT_MODE:R,IDENT_RE:x,MATCH_NOTHING_RE:/\b\B/,METHOD_GUARD:B,NUMBER_MODE:T,NUMBER_RE:w,PHRASAL_WORDS_MODE:{begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},QUOTE_STRING_MODE:N,REGEXP_MODE:j,RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{const n=/^#![ ]*\//;return e.binary&&(e.begin=f(n,/.*\b/,e.binary,/\b.*/)),o({scope:"meta",begin:n,end:/$/,relevance:0,"on:begin":(e,n)=>{0!==e.index&&n.ignoreMatch()}},e)},TITLE_MODE:C,UNDERSCORE_IDENT_RE:_,UNDERSCORE_TITLE_MODE:L});function H(e,n){"."===e.input[e.index-1]&&n.ignoreMatch()}function P(e,n){void 0!==e.className&&(e.scope=e.className,delete e.className)}function z(e,n){n&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=H,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,void 0===e.relevance&&(e.relevance=0))}function U(e,n){Array.isArray(e.illegal)&&(e.illegal=p(...e.illegal))}function G(e,n){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function Z(e,n){void 0===e.relevance&&(e.relevance=1)}const F=(e,n)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const t=Object.assign({},e);Object.keys(e).forEach((n=>{delete e[n]})),e.keywords=t.keywords,e.begin=f(t.beforeMatch,d(t.begin)),e.starts={relevance:0,contains:[Object.assign(t,{endsParent:!0})]},e.relevance=0,delete t.beforeMatch},W=["of","and","for","in","not","or","if","then","parent","list","value"],X="keyword";function K(e,n,t=X){const i=Object.create(null);return"string"==typeof e?o(t,e.split(" ")):Array.isArray(e)?o(t,e):Object.keys(e).forEach((function(t){Object.assign(i,K(e[t],n,t))})),i;function o(e,t){n&&(t=t.map((e=>e.toLowerCase()))),t.forEach((function(n){const t=n.split("|");i[t[0]]=[e,q(t[0],t[1])]}))}}function q(e,n){return n?Number(n):function(e){return W.includes(e.toLowerCase())}(e)?0:1}const V={},J=e=>{console.error(e)},Y=(e,...n)=>{console.log(`WARN: ${e}`,...n)},Q=(e,n)=>{V[`${e}/${n}`]||(console.log(`Deprecated as of ${e}. ${n}`),V[`${e}/${n}`]=!0)},ee=new Error;function ne(e,n,{key:t}){let i=0;const o=e[t],s={},r={};for(let e=1;e<=n.length;e++)r[e+i]=o[e],s[e+i]=!0,i+=b(n[e-1]);e[t]=r,e[t]._emit=s,e[t]._multi=!0}function te(e){!function(e){e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,delete e.scope)}(e),"string"==typeof e.beginScope&&(e.beginScope={_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope}),function(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw J("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ee;if("object"!=typeof e.beginScope||null===e.beginScope)throw J("beginScope must be object"),ee;ne(e,e.begin,{key:"beginScope"}),e.begin=E(e.begin,{joinWith:""})}}(e),function(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw J("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ee;if("object"!=typeof e.endScope||null===e.endScope)throw J("endScope must be object"),ee;ne(e,e.end,{key:"endScope"}),e.end=E(e.end,{joinWith:""})}}(e)}function ie(e){function n(n,t){return new RegExp(u(n),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(t?"g":""))}class t{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,n){n.position=this.position++,this.matchIndexes[this.matchAt]=n,this.regexes.push([n,e]),this.matchAt+=b(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);const e=this.regexes.map((e=>e[1]));this.matcherRe=n(E(e,{joinWith:"|"}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;const n=this.matcherRe.exec(e);if(!n)return null;const t=n.findIndex(((e,n)=>n>0&&void 0!==e)),i=this.matchIndexes[t];return n.splice(0,t),Object.assign(n,i)}}class i{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];const n=new t;return this.rules.slice(e).forEach((([e,t])=>n.addRule(e,t))),n.compile(),this.multiRegexes[e]=n,n}resumingScanAtSamePosition(){return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,n){this.rules.push([e,n]),"begin"===n.type&&this.count++}exec(e){const n=this.getMatcher(this.regexIndex);n.lastIndex=this.lastIndex;let t=n.exec(e);if(this.resumingScanAtSamePosition())if(t&&t.index===this.lastIndex);else{const n=this.getMatcher(0);n.lastIndex=this.lastIndex+1,t=n.exec(e)}return t&&(this.regexIndex+=t.position+1,this.regexIndex===this.count&&this.considerAll()),t}}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=o(e.classNameAliases||{}),function t(s,r){const a=s;if(s.isCompiled)return a;[P,G,te,F].forEach((e=>e(s,r))),e.compilerExtensions.forEach((e=>e(s,r))),s.__beforeBegin=null,[z,U,Z].forEach((e=>e(s,r))),s.isCompiled=!0;let c=null;return"object"==typeof s.keywords&&s.keywords.$pattern&&(s.keywords=Object.assign({},s.keywords),c=s.keywords.$pattern,delete s.keywords.$pattern),c=c||/\w+/,s.keywords&&(s.keywords=K(s.keywords,e.case_insensitive)),a.keywordPatternRe=n(c,!0),r&&(s.begin||(s.begin=/\B|\b/),a.beginRe=n(a.begin),s.end||s.endsWithParent||(s.end=/\B|\b/),s.end&&(a.endRe=n(a.end)),a.terminatorEnd=u(a.end)||"",s.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(s.end?"|":"")+r.terminatorEnd)),s.illegal&&(a.illegalRe=n(s.illegal)),s.contains||(s.contains=[]),s.contains=[].concat(...s.contains.map((function(e){return function(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((function(n){return o(e,{variants:null},n)}))),e.cachedVariants?e.cachedVariants:oe(e)?o(e,{starts:e.starts?o(e.starts):null}):Object.isFrozen(e)?o(e):e}("self"===e?s:e)}))),s.contains.forEach((function(e){t(e,a)})),s.starts&&t(s.starts,r),a.matcher=function(e){const n=new i;return e.contains.forEach((e=>n.addRule(e.begin,{rule:e,type:"begin"}))),e.terminatorEnd&&n.addRule(e.terminatorEnd,{type:"end"}),e.illegal&&n.addRule(e.illegal,{type:"illegal"}),n}(a),a}(e)}function oe(e){return!!e&&(e.endsWithParent||oe(e.starts))}class se extends Error{constructor(e,n){super(e),this.name="HTMLInjectionError",this.html=n}}const re=i,ae=o,ce=Symbol("nomatch"),le=function(e){const i=Object.create(null),o=Object.create(null),s=[];let r=!0;const a="Could not find the language '{}', did you forget to load/include a language module?",c={disableAutodetect:!0,name:"Plain text",contains:[]};let u={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:l};function b(e){return u.noHighlightRe.test(e)}function m(e,n,t){let i="",o="";"object"==typeof n?(i=e,t=n.ignoreIllegals,o=n.language):(Q("10.7.0","highlight(lang, code, ...args) has been deprecated."),Q("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),o=e,i=n),void 0===t&&(t=!0);const s={code:i,language:o};N("before:highlight",s);const r=s.result?s.result:E(s.language,s.code,t);return r.code=s.code,N("after:highlight",r),r}function E(e,n,o,s){const c=Object.create(null);function l(){if(!N.keywords)return void M.addText(O);let e=0;N.keywordPatternRe.lastIndex=0;let n=N.keywordPatternRe.exec(O),t="";for(;n;){t+=O.substring(e,n.index);const o=k.case_insensitive?n[0].toLowerCase():n[0],s=(i=o,N.keywords[i]);if(s){const[e,i]=s;if(M.addText(t),t="",c[o]=(c[o]||0)+1,c[o]<=7&&(R+=i),e.startsWith("_"))t+=n[0];else{const t=k.classNameAliases[e]||e;g(n[0],t)}}else t+=n[0];e=N.keywordPatternRe.lastIndex,n=N.keywordPatternRe.exec(O)}var i;t+=O.substring(e),M.addText(t)}function d(){null!=N.subLanguage?function(){if(""===O)return;let e=null;if("string"==typeof N.subLanguage){if(!i[N.subLanguage])return void M.addText(O);e=E(N.subLanguage,O,!0,S[N.subLanguage]),S[N.subLanguage]=e._top}else e=x(O,N.subLanguage.length?N.subLanguage:null);N.relevance>0&&(R+=e.relevance),M.__addSublanguage(e._emitter,e.language)}():l(),O=""}function g(e,n){""!==e&&(M.startScope(n),M.addText(e),M.endScope())}function h(e,n){let t=1;const i=n.length-1;for(;t<=i;){if(!e._emit[t]){t++;continue}const i=k.classNameAliases[e[t]]||e[t],o=n[t];i?g(o,i):(O=o,l(),O=""),t++}}function f(e,n){return e.scope&&"string"==typeof e.scope&&M.openNode(k.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(g(O,k.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),O=""):e.beginScope._multi&&(h(e.beginScope,n),O="")),N=Object.create(e,{parent:{value:N}}),N}function p(e,n,i){let o=function(e,n){const t=e&&e.exec(n);return t&&0===t.index}(e.endRe,i);if(o){if(e["on:end"]){const i=new t(e);e["on:end"](n,i),i.isMatchIgnored&&(o=!1)}if(o){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return p(e.parent,n,i)}function b(e){return 0===N.matcher.regexIndex?(O+=e[0],1):(I=!0,0)}function m(e){const t=e[0],i=n.substring(e.index),o=p(N,e,i);if(!o)return ce;const s=N;N.endScope&&N.endScope._wrap?(d(),g(t,N.endScope._wrap)):N.endScope&&N.endScope._multi?(d(),h(N.endScope,e)):s.skip?O+=t:(s.returnEnd||s.excludeEnd||(O+=t),d(),s.excludeEnd&&(O=t));do{N.scope&&M.closeNode(),N.skip||N.subLanguage||(R+=N.relevance),N=N.parent}while(N!==o.parent);return o.starts&&f(o.starts,e),s.returnEnd?0:t.length}let _={};function w(i,s){const a=s&&s[0];if(O+=i,null==a)return d(),0;if("begin"===_.type&&"end"===s.type&&_.index===s.index&&""===a){if(O+=n.slice(s.index,s.index+1),!r){const n=new Error(`0 width match regex (${e})`);throw n.languageName=e,n.badRule=_.rule,n}return 1}if(_=s,"begin"===s.type)return function(e){const n=e[0],i=e.rule,o=new t(i),s=[i.__beforeBegin,i["on:begin"]];for(const t of s)if(t&&(t(e,o),o.isMatchIgnored))return b(n);return i.skip?O+=n:(i.excludeBegin&&(O+=n),d(),i.returnBegin||i.excludeBegin||(O=n)),f(i,e),i.returnBegin?0:n.length}(s);if("illegal"===s.type&&!o){const e=new Error('Illegal lexeme "'+a+'" for mode "'+(N.scope||"")+'"');throw e.mode=N,e}if("end"===s.type){const e=m(s);if(e!==ce)return e}if("illegal"===s.type&&""===a)return 1;if($>1e5&&$>3*s.index)throw new Error("potential infinite loop, way more iterations than matches");return O+=a,a.length}const k=y(e);if(!k)throw J(a.replace("{}",e)),new Error('Unknown language: "'+e+'"');const v=ie(k);let A="",N=s||v;const S={},M=new u.__emitter(u);!function(){const e=[];for(let n=N;n!==k;n=n.parent)n.scope&&e.unshift(n.scope);e.forEach((e=>M.openNode(e)))}();let O="",R=0,T=0,$=0,I=!1;try{if(k.__emitTokens)k.__emitTokens(n,M);else{for(N.matcher.considerAll();;){$++,I?I=!1:N.matcher.considerAll(),N.matcher.lastIndex=T;const e=N.matcher.exec(n);if(!e)break;const t=w(n.substring(T,e.index),e);T=e.index+t}w(n.substring(T))}return M.finalize(),A=M.toHTML(),{language:e,value:A,relevance:R,illegal:!1,_emitter:M,_top:N}}catch(t){if(t.message&&t.message.includes("Illegal"))return{language:e,value:re(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:T,context:n.slice(T-100,T+100),mode:t.mode,resultSoFar:A},_emitter:M};if(r)return{language:e,value:re(n),illegal:!1,relevance:0,errorRaised:t,_emitter:M,_top:N};throw t}}function x(e,n){n=n||u.languages||Object.keys(i);const t=function(e){const n={value:re(e),illegal:!1,relevance:0,_top:c,_emitter:new u.__emitter(u)};return n._emitter.addText(e),n}(e),o=n.filter(y).filter(A).map((n=>E(n,e,!1)));o.unshift(t);const s=o.sort(((e,n)=>{if(e.relevance!==n.relevance)return n.relevance-e.relevance;if(e.language&&n.language){if(y(e.language).supersetOf===n.language)return 1;if(y(n.language).supersetOf===e.language)return-1}return 0})),[r,a]=s,l=r;return l.secondBest=a,l}function _(e){let n=null;const t=function(e){let n=e.className+" ";n+=e.parentNode?e.parentNode.className:"";const t=u.languageDetectRe.exec(n);if(t){const n=y(t[1]);return n||(Y(a.replace("{}",t[1])),Y("Falling back to no-highlight mode for this block.",e)),n?t[1]:"no-highlight"}return n.split(/\s+/).find((e=>b(e)||y(e)))}(e);if(b(t))return;if(N("before:highlightElement",{el:e,language:t}),e.dataset.highlighted)return void console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);if(e.children.length>0&&(u.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(e)),u.throwUnescapedHTML))throw new se("One of your code blocks includes unescaped HTML.",e.innerHTML);n=e;const i=n.textContent,s=t?m(i,{language:t,ignoreIllegals:!0}):x(i);e.innerHTML=s.value,e.dataset.highlighted="yes",function(e,n,t){const i=n&&o[n]||t;e.classList.add("hljs"),e.classList.add(`language-${i}`)}(e,t,s.language),e.result={language:s.language,re:s.relevance,relevance:s.relevance},s.secondBest&&(e.secondBest={language:s.secondBest.language,relevance:s.secondBest.relevance}),N("after:highlightElement",{el:e,result:s,text:i})}let w=!1;function k(){"loading"!==document.readyState?document.querySelectorAll(u.cssSelector).forEach(_):w=!0}function y(e){return e=(e||"").toLowerCase(),i[e]||i[o[e]]}function v(e,{languageName:n}){"string"==typeof e&&(e=[e]),e.forEach((e=>{o[e.toLowerCase()]=n}))}function A(e){const n=y(e);return n&&!n.disableAutodetect}function N(e,n){const t=e;s.forEach((function(e){e[t]&&e[t](n)}))}"undefined"!=typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",(function(){w&&k()}),!1),Object.assign(e,{highlight:m,highlightAuto:x,highlightAll:k,highlightElement:_,highlightBlock:function(e){return Q("10.7.0","highlightBlock will be removed entirely in v12.0"),Q("10.7.0","Please use highlightElement now."),_(e)},configure:function(e){u=ae(u,e)},initHighlighting:()=>{k(),Q("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")},initHighlightingOnLoad:function(){k(),Q("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")},registerLanguage:function(n,t){let o=null;try{o=t(e)}catch(e){if(J("Language definition for '{}' could not be registered.".replace("{}",n)),!r)throw e;J(e),o=c}o.name||(o.name=n),i[n]=o,o.rawDefinition=t.bind(null,e),o.aliases&&v(o.aliases,{languageName:n})},unregisterLanguage:function(e){delete i[e];for(const n of Object.keys(o))o[n]===e&&delete o[n]},listLanguages:function(){return Object.keys(i)},getLanguage:y,registerAliases:v,autoDetection:A,inherit:ae,addPlugin:function(e){!function(e){e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=n=>{e["before:highlightBlock"](Object.assign({block:n.el},n))}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=n=>{e["after:highlightBlock"](Object.assign({block:n.el},n))})}(e),s.push(e)},removePlugin:function(e){const n=s.indexOf(e);-1!==n&&s.splice(n,1)}}),e.debugMode=function(){r=!1},e.safeMode=function(){r=!0},e.versionString="11.9.0",e.regex={concat:f,lookahead:d,either:p,optional:h,anyNumberOfTimes:g};for(const e in D)"object"==typeof D[e]&&n(D[e]);return Object.assign(e,D),e},ue=le({});ue.newInstance=()=>le({}),e.exports=ue,ue.HighlightJS=ue,ue.default=ue}},n={};function t(i){var o=n[i];if(void 0!==o)return o.exports;var s=n[i]={exports:{}};return e[i](s,s.exports,t),s.exports}(()=>{"use strict";Shiny;const e=t(390);e.registerLanguage("r",(function(e){const n=e.regex,t=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,i=n.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),o=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,s=n.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:t,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:n.lookahead(n.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:t},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[o,i]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,i]},{scope:{1:"punctuation",2:"number"},match:[s,i]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,i]}]},{scope:{3:"operator"},match:[t,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:o},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:s},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}})),$((()=>{$(document).on("shiny:value",(n=>{n.name.match(/-code$/)&&($(`#${n.name}`).addClass("language-r"),setTimeout((()=>{e.highlightElement(document.getElementById(n.name))}),250))}))}));const n=e=>{$(e).find(".block-output-toggle").each(((e,n)=>{$(n).hasClass("block-bound")||($(n).addClass("block-bound"),$(n).on("click",(e=>{const n=$(e.target).closest(".block"),t=n.find(".block-output").is(":visible"),i=n.find(".block-input").is(":visible");t||i?(n.find(".block-inputs").addClass("d-none"),n.find(".block-output").addClass("d-none")):(n.find(".block-inputs").removeClass("d-none"),n.find(".block-output").removeClass("d-none"));let o="shown";n.find(".block-output").hasClass("d-none")&&(o="hidden"),n.find(".block-inputs").trigger(o),n.find(".block-output").trigger(o)})))}))},i=()=>{$(".block-copy-code").each(((e,n)=>{$(n).off("click"),$(n).on("click",(e=>{var n;n=$(e.target).closest("div").find("pre"),navigator.clipboard.writeText($(n).text())}))})),$(".stack-copy-code").each(((e,n)=>{$(n).off("click"),$(n).on("click",(e=>{const n=$(e.target).closest(".stack").find("pre");let t=[];n.each(((e,n)=>{t.push($(n).text())})),t=t.join(" |>\n"),navigator.clipboard.writeText(t)}))}))};Shiny.addCustomMessageHandler("blockr-bind-stack",(e=>{const t=`#${e.stack}`;setTimeout((()=>{(e=>{$(e).find(".stack-remove").each(((e,n)=>{"true"!=n.getAttribute("listener")&&$(n).on("click",(e=>{const n=$(e.target).closest(".stack"),t=n.closest(".masonry-item");n.remove(),0!==t.length&&t.remove()}))}))})(t),(e=>{(e=>{const n=$(e).find(".stack-edit-toggle");$(n).hasClass("block-bound")||($(n).addClass("block-bound"),$(n).on("click",(e=>{const n=$(e.target).closest(".stack").find(".block");$(e.currentTarget).toggleClass("etidable");const t=$(e.currentTarget).hasClass("etidable");n.each(((e,i)=>{const o=$(i);return t?(o.removeClass("d-none"),o.find(".block-title").removeClass("d-none"),void(e==n.length-1&&(o.find(".block-output").addClass("show"),o.find(".block-output").removeClass("d-none"),o.find(".block-output").trigger("shown")))):(o.find(".block-title").addClass("d-none"),e==n.length-1?(o.removeClass("d-none"),o.find(".block-output").addClass("show"),o.find(".block-output").removeClass("d-none"),void o.find(".block-output").trigger("shown")):void o.addClass("d-none"))}))})))})(e),(e=>{$(e).each(((e,n)=>{(e=>{const n=$(e).find(".block").last();n.removeClass("d-none");const t=n.find(".block-output");n.find(".block-title").addClass("d-none"),t.removeClass("d-none"),t.trigger("shown")})(n)}))})(e),n(e)})(t),i()}),750)})),Shiny.addCustomMessageHandler("blockr-add-block",(e=>{const t=`#${e.stack}`;setTimeout((()=>{i(),n(t)}),500)}))})()})(); \ No newline at end of file diff --git a/srcjs/collapse.js b/srcjs/collapse.js index a28dac43..d0a48fb1 100644 --- a/srcjs/collapse.js +++ b/srcjs/collapse.js @@ -4,7 +4,7 @@ export const collapse = (stack) => { toggleOutputInput(stack); }; -const toggleOutputInput = (stack) => { +export const toggleOutputInput = (stack) => { $(stack).find(".block-output-toggle").each((_index, btn) => { // already has a listener if ($(btn).hasClass("block-bound")) { diff --git a/srcjs/shiny.js b/srcjs/shiny.js index 8736ab5d..7a87f006 100644 --- a/srcjs/shiny.js +++ b/srcjs/shiny.js @@ -1,4 +1,4 @@ -import { collapse, showLastOutput } from "./collapse.js"; +import { collapse, toggleOutputInput } from "./collapse.js"; import { remove } from "./remove-stack.js"; import { copyCode } from "./copy.js"; @@ -17,5 +17,6 @@ Shiny.addCustomMessageHandler("blockr-add-block", (msg) => { // be event based/async instead of timeout setTimeout(() => { copyCode(); + toggleOutputInput(stack); }, 500); });