Created
July 22, 2012 20:14
-
-
Save ramnathv/3160927 to your computer and use it in GitHub Desktop.
Diagnose Slidify Error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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