Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Created July 22, 2012 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramnathv/3160927 to your computer and use it in GitHub Desktop.
Save ramnathv/3160927 to your computer and use it in GitHub Desktop.
Diagnose Slidify Error
library(markdown)
re.capture <- function(pattern, string, ...) {
rex = list(src = string, names = list(),
result = regexpr(pattern, string, perl = TRUE, ...))
for (.name in attr(rex$result, 'capture.name')) {
rex$names[[.name]] = substr(rex$src,
attr(rex$result, 'capture.start')[,.name],
attr(rex$result, 'capture.start')[,.name]
+ attr(rex$result, 'capture.length')[,.name]
- 1)
}
return(rex)
}
raw_md <- "\n### Slide 1 ###\n\nThis is an unordered list \n\n- Point 1\n- Point 2\n- Point 3\n- Point 4"
content <- renderMarkdown(text = raw_md, renderer.options = markdownExtensions())
hpat <- '(?<header><h(?<level>[0-9])>(?<title>.*)</h[0-9]>)\n+'
vars <- re.capture(hpat, content)$name
print(vars)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment