@@ -69,12 +69,10 @@ function renderNode(
6969 language : string ,
7070 onNavigate ?: ( target : string ) => void
7171) : ReactNode {
72- // Handle text nodes
7372 if ( node . type === "text" ) {
7473 return node . value ;
7574 }
7675
77- // Render children recursively
7876 const children =
7977 "children" in node && node . children
8078 ? node . children . map ( ( child , i ) =>
@@ -83,7 +81,6 @@ function renderNode(
8381 : null ;
8482
8583 switch ( node . type ) {
86- // Structure elements
8784 case "Label" :
8885 return (
8986 < span className = "label font-semibold" key = { key } >
@@ -150,7 +147,6 @@ function renderNode(
150147 </ div >
151148 ) ;
152149
153- // Terms and references
154150 case "DefinedTermEn" :
155151 case "DefinedTermFr" :
156152 return (
@@ -165,9 +161,6 @@ function renderNode(
165161 </ span >
166162 ) ;
167163 case "XRefExternal" : {
168- // Only create links for acts/regulations that have a valid link attribute
169- // External references like "Designated Airspace Handbook" (reference-type="other")
170- // don't have links and should render as styled text, not broken anchors
171164 if ( node . link ) {
172165 const href = buildJusticeCanadaUrl (
173166 node . link ,
@@ -187,17 +180,14 @@ function renderNode(
187180 </ a >
188181 ) ;
189182 }
190- // No link available - render as emphasized text (external publications, standards)
191183 return (
192184 < em className = "text-foreground" key = { key } >
193185 { children }
194186 </ em >
195187 ) ;
196188 }
197189 case "XRefInternal" : {
198- // Target can be explicit attribute or extracted from children text
199190 const target = node . target || extractTextFromChildren ( node . children ) ;
200- // If we have a navigation handler and target, make it clickable
201191 if ( onNavigate && target ) {
202192 return (
203193 < button
@@ -210,15 +200,13 @@ function renderNode(
210200 </ button >
211201 ) ;
212202 }
213- // Fallback to plain text if no handler
214203 return (
215204 < span className = "text-primary" key = { key } >
216205 { children }
217206 </ span >
218207 ) ;
219208 }
220209
221- // Text formatting
222210 case "Emphasis" :
223211 if ( node . style === "italic" ) {
224212 return (
@@ -254,7 +242,6 @@ function renderNode(
254242 </ span >
255243 ) ;
256244 case "FootnoteRef" :
257- // Render as superscript letter (children contains "a", "b", "c" etc.)
258245 return (
259246 < sup className = "text-primary" key = { key } >
260247 { children }
@@ -265,7 +252,6 @@ function renderNode(
265252 case "PageBreak" :
266253 return < hr className = "my-4 border-dashed" key = { key } /> ;
267254 case "FormBlank" :
268- // FormBlank can have children (e.g., "A Justice of the Peace in and for <Leader/>")
269255 if ( children && node . children && node . children . length > 0 ) {
270256 return (
271257 < span className = "form-blank-with-content block text-center" key = { key } >
@@ -275,7 +261,6 @@ function renderNode(
275261 </ span >
276262 ) ;
277263 }
278- // Simple blank line (no content)
279264 return (
280265 < span
281266 className = "inline-block border-current border-b"
@@ -286,7 +271,6 @@ function renderNode(
286271 </ span >
287272 ) ;
288273 case "Fraction" : {
289- // Look for Numerator and Denominator children for proper rendering
290274 const numerator = node . children ?. find (
291275 ( c ) => "type" in c && c . type === "Numerator"
292276 ) ;
@@ -307,7 +291,6 @@ function renderNode(
307291 </ span >
308292 ) ;
309293 }
310- // Fallback for simple fractions without Numerator/Denominator tags
311294 return (
312295 < span className = "inline-fraction" key = { key } >
313296 { children }
@@ -318,9 +301,7 @@ function renderNode(
318301 case "Denominator" :
319302 return < span key = { key } > { children } </ span > ;
320303 case "Leader" : {
321- // Use explicit length if provided, otherwise default to 4em
322304 const width = node . length || "4em" ;
323- // Style "none" means no visible line (just space)
324305 const borderStyle =
325306 node . style === "none"
326307 ? "none"
@@ -372,16 +353,13 @@ function renderNode(
372353 </ li >
373354 ) ;
374355
375- // Tables (CALS)
376356 case "TableGroup" :
377357 return (
378358 < div className = "table-group my-4 overflow-x-auto" key = { key } >
379359 { children }
380360 </ div >
381361 ) ;
382362 case "Table" : {
383- // Separate text/unknown children (for caption) from valid table children
384- // Valid table children: TGroup, THead, TBody, TFoot, ColSpec
385363 const tableChildren =
386364 "children" in node && node . children
387365 ? node . children . filter (
@@ -456,9 +434,8 @@ function renderNode(
456434 ) ;
457435 }
458436 case "ColSpec" :
459- return null ; // Handled by table rendering logic
437+ return null ;
460438
461- // Formulas and math
462439 case "FormulaGroup" :
463440 return (
464441 < div className = "formula-group my-4" key = { key } >
@@ -501,27 +478,22 @@ function renderNode(
501478 </ React . Fragment >
502479 ) ;
503480 case "FormulaParagraph" :
504- // Use div instead of p because FormulaParagraph can contain nested formulas (divs)
505481 return (
506482 < div className = "formula-paragraph my-1" key = { key } >
507483 { children }
508484 </ div >
509485 ) ;
510486
511- // MathML - inject raw XML for browser math rendering
512487 case "MathML" :
513488 return < MathMLRenderer display = { node . display } key = { key } raw = { node . raw } /> ;
514489
515- // Images
516490 case "ImageGroup" :
517491 return (
518492 < figure className = "image-group my-4" key = { key } >
519493 { children }
520494 </ figure >
521495 ) ;
522496 case "Image" :
523- // Use native img for legislation images - they need to display at natural size
524- // Next.js Image requires fixed dimensions which don't work well for formula images
525497 return node . source ? (
526498 // biome-ignore lint/nursery/useImageSize: legislation images need natural sizing
527499 // biome-ignore lint/performance/noImgElement: Next.js Image doesn't support variable sizes
@@ -539,7 +511,6 @@ function renderNode(
539511 </ figcaption >
540512 ) ;
541513
542- // Bilingual content
543514 case "BilingualGroup" :
544515 return (
545516 < div className = "bilingual-group my-2 flex gap-4" key = { key } >
@@ -559,7 +530,6 @@ function renderNode(
559530 </ span >
560531 ) ;
561532
562- // Special content
563533 case "QuotedText" :
564534 return (
565535 < blockquote
@@ -600,7 +570,6 @@ function renderNode(
600570 </ div >
601571 ) ;
602572 case "Heading" : {
603- // Render heading with appropriate HTML tag based on level
604573 const level = "level" in node ? ( node . level as number ) : 3 ;
605574 const HeadingTag = `h${ Math . min ( Math . max ( level + 1 , 2 ) , 6 ) } ` as
606575 | "h2"
@@ -621,7 +590,6 @@ function renderNode(
621590 </ span >
622591 ) ;
623592
624- // Metadata elements (marginal notes, historical notes, footnotes)
625593 case "MarginalNote" :
626594 return (
627595 < aside
@@ -661,7 +629,6 @@ function renderNode(
661629 </ aside >
662630 ) ;
663631
664- // Amending and container elements
665632 case "SectionPiece" :
666633 case "AmendedText" :
667634 case "AmendedContent" :
@@ -675,21 +642,15 @@ function renderNode(
675642 </ div >
676643 ) ;
677644
678- // Fallback for unhandled elements (including "Unknown" type)
679- // Using Fragment avoids invalid HTML nesting (e.g., <span> inside <table>)
680645 default :
681- // Handle Unknown type with specific tags
682646 if ( node . type === "Unknown" && "tag" in node ) {
683- // AlternateText: accessibility text for images - hide visually
684647 if ( node . tag === "AlternateText" ) {
685648 return (
686649 < span className = "sr-only" key = { key } >
687650 { children }
688651 </ span >
689652 ) ;
690653 }
691- // Provisions: render as div with proper layout
692- // Check if this provision has a Label child (indicates it's a list item like (a), (b))
693654 if ( node . tag === "Provision" ) {
694655 const hasLabel =
695656 node . children ?. some (
@@ -699,8 +660,6 @@ function renderNode(
699660 "tag" in child &&
700661 child . tag === "Label" )
701662 ) ?? false ;
702- // Provisions with labels are indented list items
703- // Provisions without labels are block paragraphs
704663 return (
705664 < div
706665 className = {
0 commit comments