Skip to content

Commit

Permalink
Ends code chunk in .R file when a
Browse files Browse the repository at this point in the history
section header is used, e.g. `# Header ----`
  • Loading branch information
kylebutts committed Nov 24, 2023
1 parent f66ceef commit bda928c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/rmarkdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ function isChunkStartLine(text: string, isRDoc: boolean) {

function isChunkEndLine(text: string, isRDoc: boolean) {
if (isRDoc) {
return (isRChunkLine(text));
const isSectionHeader = text.match(/^#+\s*.*[-#+=*]{4,}/g);
return (isRChunkLine(text) || isSectionHeader);
} else {
return (!!text.match(/^\s*```+\s*$/g));
}
Expand Down

0 comments on commit bda928c

Please sign in to comment.