@@ -349,16 +349,20 @@ async function mergeExecutedFiles(
349349 if ( file ) {
350350 const partitioned = partitionMarkdown ( file . executeResult . markdown ) ;
351351
352+ // Will always provide the title markdown whether the title was provided by
353+ // front matter or by the first heading. Note that this will
354+ // prefer to use the title that appears in the front matter, and if
355+ // there is no front matter title it will promote the first heading to
356+ // level 1 heading
352357 const resolveTitleMarkdown = ( partitioned : PartitionedMarkdown ) => {
358+ // Creates a markdown title, dealing with attributes, if present
353359 const createMarkdownTitle = ( text : string , attr ?: PandocAttr ) => {
354360 let attrStr = "" ;
355361 if ( attr ) {
356362 const idStr = attr . id !== "" ? `#${ attr . id } ` : "" ;
357363 const clzStr = attr . classes . map ( ( clz ) => {
358364 return `.${ clz } ` ;
359365 } ) ;
360- // TODO: replace tempalte with local path to orcid image
361- // TODO: add nbsp when title block renders something
362366 const keyValueStr = attr . keyvalue . map ( ( kv ) => {
363367 const escapedValue = kv [ 1 ] . replaceAll ( / " / gm, '\\"' ) ;
364368 return `${ kv [ 0 ] } ="${ escapedValue } " ` ;
@@ -391,6 +395,10 @@ async function mergeExecutedFiles(
391395 return createMarkdownTitle ( titleText , titleAttr ) ;
392396 } ;
393397
398+ // If there is front matter for this chapter, this will generate a code
399+ // cell that will be rendered a LUA filter (the code cell will provide the
400+ // path to the template that should be used as well as the front matter
401+ // to use when rendering)
394402 const resolveTitleBlockMarkdown = ( yaml ?: Metadata ) => {
395403 if ( yaml ) {
396404 const titleBlockPath = resourcePath (
@@ -413,6 +421,7 @@ async function mergeExecutedFiles(
413421 }
414422 } ;
415423
424+ // Compose the markdown for this chapter
416425 const titleMarkdown = resolveTitleMarkdown ( partitioned ) ;
417426 const titleBlockMarkdown = resolveTitleBlockMarkdown (
418427 partitioned . yaml ,
0 commit comments