diff --git a/R/hooks-asciidoc.R b/R/hooks-asciidoc.R index 0ee19567ef..0dd8670d39 100644 --- a/R/hooks-asciidoc.R +++ b/R/hooks-asciidoc.R @@ -36,7 +36,9 @@ hooks_asciidoc = function() { hook.error = function(x, options) { sprintf('\n[CAUTION]\n====\n.Error\n%s\n====\n', gsub('^.*Error: ', '', x)) } - hook.output = function(x, options) sprintf('\n----\n%s----\n', x) + hook.output = function(x, options) { + if (output_asis(x, options)) x else sprintf('\n----\n%s----\n', x) + } list( source = hook.source, output = hook.output, message = hook.message, warning = hook.warning, error = hook.error, plot = hook_plot_asciidoc diff --git a/R/hooks-html.R b/R/hooks-html.R index 49d3e1fef2..54b28f408d 100644 --- a/R/hooks-html.R +++ b/R/hooks-html.R @@ -252,6 +252,7 @@ hooks_html = function() { hook = function(name) { force(name) function(x, options) { + if (name == 'output' && output_asis(x, options)) return(x) x = if (name == 'source') { c(hilight_source(x, 'html', options), '') } else escape_html(x) diff --git a/R/hooks-md.R b/R/hooks-md.R index f2443f9aee..1188fbd5d8 100644 --- a/R/hooks-md.R +++ b/R/hooks-md.R @@ -175,6 +175,7 @@ hooks_markdown = function(strict = FALSE, fence_char = '`') { hook.o = function(class) { force(class) function(x, options) { + if (class == 'output' && output_asis(x, options)) return(x) hook.t(x, options[[paste0('attr.', class)]], options[[paste0('class.', class)]]) } } @@ -290,6 +291,9 @@ hooks_jekyll = function(highlight = c('pygments', 'prettify', 'none'), extra = ' hook.r(x, options) } merge_list(hook.m, list( - source = source, output = hook.t, warning = hook.t, message = hook.t, error = hook.t + source = source, warning = hook.t, message = hook.t, error = hook.t, + output = function(x, options) { + if (output_asis(x, options)) x else hook.t(x, options) + } )) } diff --git a/R/hooks-rst.R b/R/hooks-rst.R index 4d64bcb711..6986e8259c 100644 --- a/R/hooks-rst.R +++ b/R/hooks-rst.R @@ -42,7 +42,9 @@ hooks_rst = function(strict = FALSE) { (if (strict) hook.s else hook.t)(x, options) }, warning = hook.s, error = hook.s, message = hook.s, - output = hook.s, inline = hook.i, plot = hook_plot_rst + inline = hook.i, plot = hook_plot_rst, output = function(x, options) { + if (output_asis(x, options)) x else hook.s(x, options) + } ) } diff --git a/R/hooks-textile.R b/R/hooks-textile.R index 534d5ff467..34e7a5faf9 100644 --- a/R/hooks-textile.R +++ b/R/hooks-textile.R @@ -33,6 +33,7 @@ hooks_textile = function() { function(x, options) { if (name == 'source') x = c(hilight_source(x, 'textile', options), '') x = one_string(x) + if (name == 'output' && output_asis(x, options)) return(x) sprintf('bc(knitr %s %s#%s).. %s\np(knitr_end). \n\n', tolower(options$engine), name, options$label, x) } diff --git a/R/output.R b/R/output.R index 1cf447e32b..6005c78365 100644 --- a/R/output.R +++ b/R/output.R @@ -512,8 +512,7 @@ sew.knit_asis = function(x, options, inline = FALSE, ...) { } } x = wrap_asis(x, options) - if (!out_format('latex') || inline) return(x) - # latex output need the \end{kframe} trick + if (inline) return(x) options$results = 'asis' knit_hooks$get('output')(x, options) }