@@ -56,7 +56,16 @@ const INLINE_TYPE_MAP: Readonly<Record<string, InlineType>> = {
5656 */
5757interface StackFrame {
5858 /** What kind of frame this is */
59- kind : "level" | "content" | "inline" | "note" | "sourceCredit" | "notesContainer" | "quotedContent" | "meta" | "ignore" ;
59+ kind :
60+ | "level"
61+ | "content"
62+ | "inline"
63+ | "note"
64+ | "sourceCredit"
65+ | "notesContainer"
66+ | "quotedContent"
67+ | "meta"
68+ | "ignore" ;
6069 /** The AST node being constructed (null for meta/ignore frames) */
6170 node : ASTNode | null ;
6271 /** The XML element name that opened this frame */
@@ -151,8 +160,14 @@ export class ASTBuilder {
151160
152161 if ( name === "xhtml:table" ) {
153162 this . tableCollector = {
154- headers : [ ] , rows : [ ] , currentRow : [ ] , cellText : "" ,
155- inHead : false , inCell : false , isComplex : false , cellDepth : 0 ,
163+ headers : [ ] ,
164+ rows : [ ] ,
165+ currentRow : [ ] ,
166+ cellText : "" ,
167+ inHead : false ,
168+ inCell : false ,
169+ isComplex : false ,
170+ cellDepth : 0 ,
156171 } ;
157172 return ;
158173 }
@@ -163,8 +178,14 @@ export class ASTBuilder {
163178
164179 if ( name === "layout" ) {
165180 this . layoutCollector = {
166- headers : [ ] , rows : [ ] , currentRow : [ ] , cellText : "" ,
167- inHead : false , inCell : false , isComplex : false , cellDepth : 0 ,
181+ headers : [ ] ,
182+ rows : [ ] ,
183+ currentRow : [ ] ,
184+ cellText : "" ,
185+ inHead : false ,
186+ inCell : false ,
187+ isComplex : false ,
188+ cellDepth : 0 ,
168189 } ;
169190 return ;
170191 }
@@ -207,7 +228,12 @@ export class ASTBuilder {
207228 return ;
208229 }
209230
210- if ( name === "note" || name === "statutoryNote" || name === "editorialNote" || name === "changeNote" ) {
231+ if (
232+ name === "note" ||
233+ name === "statutoryNote" ||
234+ name === "editorialNote" ||
235+ name === "changeNote"
236+ ) {
211237 this . openNote ( name , attrs ) ;
212238 return ;
213239 }
@@ -349,7 +375,12 @@ export class ASTBuilder {
349375 }
350376
351377 // Handle note close
352- if ( name === "note" || name === "statutoryNote" || name === "editorialNote" || name === "changeNote" ) {
378+ if (
379+ name === "note" ||
380+ name === "statutoryNote" ||
381+ name === "editorialNote" ||
382+ name === "changeNote"
383+ ) {
353384 this . closeNote ( ) ;
354385 return ;
355386 }
@@ -455,7 +486,11 @@ export class ASTBuilder {
455486 const trimmed = text . trim ( ) ;
456487 if ( trimmed ) {
457488 const textNode : InlineNode = { type : "inline" , inlineType : "text" , text } ;
458- const contentNode : ContentNode = { type : "content" , variant : "content" , children : [ textNode ] } ;
489+ const contentNode : ContentNode = {
490+ type : "content" ,
491+ variant : "content" ,
492+ children : [ textNode ] ,
493+ } ;
459494 const parent = frame . node ;
460495 if ( parent && "children" in parent && Array . isArray ( parent . children ) ) {
461496 ( parent . children as ASTNode [ ] ) . push ( contentNode ) ;
@@ -469,7 +504,11 @@ export class ASTBuilder {
469504 const trimmed = text . trim ( ) ;
470505 if ( trimmed ) {
471506 const textNode : InlineNode = { type : "inline" , inlineType : "text" , text } ;
472- const contentNode : ContentNode = { type : "content" , variant : "content" , children : [ textNode ] } ;
507+ const contentNode : ContentNode = {
508+ type : "content" ,
509+ variant : "content" ,
510+ children : [ textNode ] ,
511+ } ;
473512 ( frame . node as LevelNode ) . children . push ( contentNode ) ;
474513 }
475514 return ;
@@ -741,7 +780,12 @@ export class ASTBuilder {
741780 // Add as inline "quoted" node if parent is content/inline,
742781 // or as block node if parent is note/level
743782 const parentFrame = this . peekFrame ( ) ;
744- if ( parentFrame && ( parentFrame . kind === "content" || parentFrame . kind === "inline" || parentFrame . kind === "sourceCredit" ) ) {
783+ if (
784+ parentFrame &&
785+ ( parentFrame . kind === "content" ||
786+ parentFrame . kind === "inline" ||
787+ parentFrame . kind === "sourceCredit" )
788+ ) {
745789 // Flatten to inline quoted text
746790 const qNode : InlineNode = {
747791 type : "inline" ,
@@ -766,7 +810,11 @@ export class ASTBuilder {
766810 const levelFrame = this . findParentFrame ( "level" ) ;
767811
768812 // Heading inside a note takes priority
769- if ( name === "heading" && noteFrame && ( ! levelFrame || this . stack . indexOf ( noteFrame ) > this . stack . indexOf ( levelFrame ) ) ) {
813+ if (
814+ name === "heading" &&
815+ noteFrame &&
816+ ( ! levelFrame || this . stack . indexOf ( noteFrame ) > this . stack . indexOf ( levelFrame ) )
817+ ) {
770818 ( noteFrame . node as NoteNode ) . heading = text ;
771819 return ;
772820 }
@@ -783,7 +831,9 @@ export class ASTBuilder {
783831 }
784832
785833 // Update ancestor entry if this is a big level
786- const ancestor = this . ancestors . find ( ( a ) => a . levelType === levelNode . levelType && a . identifier === levelNode . identifier ) ;
834+ const ancestor = this . ancestors . find (
835+ ( a ) => a . levelType === levelNode . levelType && a . identifier === levelNode . identifier ,
836+ ) ;
787837 if ( ancestor ) {
788838 if ( name === "num" ) {
789839 ancestor . numValue = levelNode . numValue ;
@@ -812,10 +862,18 @@ export class ASTBuilder {
812862 }
813863 children . push ( textNode ) ;
814864 }
815- } else if ( parentFrame . kind === "note" || parentFrame . kind === "level" || parentFrame . kind === "quotedContent" ) {
865+ } else if (
866+ parentFrame . kind === "note" ||
867+ parentFrame . kind === "level" ||
868+ parentFrame . kind === "quotedContent"
869+ ) {
816870 // Wrap in a ContentNode
817871 const textNode : InlineNode = { type : "inline" , inlineType : "text" , text } ;
818- const contentNode : ContentNode = { type : "content" , variant : "content" , children : [ textNode ] } ;
872+ const contentNode : ContentNode = {
873+ type : "content" ,
874+ variant : "content" ,
875+ children : [ textNode ] ,
876+ } ;
819877 const parent = parentFrame . node ;
820878 if ( parent && "children" in parent && Array . isArray ( parent . children ) ) {
821879 ( parent . children as ASTNode [ ] ) . push ( contentNode ) ;
0 commit comments