Skip to content

Commit

Permalink
this is the correct way of allowing // to "comment out" code chunks
Browse files Browse the repository at this point in the history
pattern$chunk.code = '^/+' will tell the parser to strip // or more slashes from the code chunk; hook.chunk() in knit_hooks is irrelevant here because it is used to render output
  • Loading branch information
yihui committed Apr 14, 2013
1 parent 6b29ede commit d67729b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion R/hooks-asciidoc.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ render_asciidoc = function() {
sprintf('+%s+', x)
}
hook.chunk = function(x, options) {
x = gsub("/{2,}", "", x)
if (is.null(s = options$indent)) return(x)
line_prompt(x, prompt = s, continue = s)
}
Expand Down
2 changes: 1 addition & 1 deletion R/pattern.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ all_patterns = list(
inline.code = ":r:`([^`]+)`"),

`asciidoc` = list(chunk.begin = '^/{2}\\s*begin\\.rcode$',
chunk.end = '^/{2}\\s*end\\.rcode$',
chunk.end = '^/{2}\\s*end\\.rcode$', chunk.code = '^/+',
ref.chunk = '^\\s*<<(.+)>>\\s*$',
inline.code = '`r +([^`\n]+)\\s*`',
inline.comment = '^//.*',
Expand Down

0 comments on commit d67729b

Please sign in to comment.