File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -88,18 +88,19 @@ export function parseCodeBlock(
8888
8989/**
9090 * Loop through all the lines and extract lines at the beginning which start
91- * with Quarto parameter comments and have the format "#| " as `quartoArgs`,
92- * and strip those lines from the result. Also remove up to one empty line
93- * after any args.
91+ * with Quarto parameter comments and have the format "#| ", "# | " or "##| "
92+ * as `quartoArgs`, and strip those lines from the result. Also remove up to
93+ * one empty line after any args.
9494 */
9595export function processQuartoArgs ( lines : string [ ] ) : {
9696 lines : string [ ] ;
9797 quartoArgs : QuartoArgs ;
9898} {
9999 let i = 0 ;
100+ const rgxQuartoComment = / ^ ( # ? | # # ) \| / ;
100101 while ( i < lines . length ) {
101102 const line = lines [ i ] ;
102- if ( ! line . match ( / ^ # \| / ) ) {
103+ if ( ! line . match ( rgxQuartoComment ) ) {
103104 // Remove up to one blank line after finding any args.
104105 if ( line === "" ) {
105106 i ++ ;
@@ -114,7 +115,7 @@ export function processQuartoArgs(lines: string[]): {
114115 // Extract the lines that start with "#| " and remove that comment prefix.
115116 const argCommentLines = lines
116117 . slice ( 0 , i )
117- . map ( ( line ) => line . replace ( / ^ # \| / , "" ) ) ;
118+ . map ( ( line ) => line . replace ( rgxQuartoComment , "" ) ) ;
118119
119120 // Parse the args as YAML.
120121 const quartoArgs : QuartoArgs = yamlLoad (
You can’t perform that action at this time.
0 commit comments