@@ -311,10 +311,32 @@ func (r *PdfRenderer) processLink(node ast.Link, entering bool) {
311311 if r .InputBaseURL != "" && ! strings .HasPrefix (destination , "http" ) {
312312 destination = r .InputBaseURL + "/" + strings .Replace (destination , "./" , "" , 1 )
313313 }
314+
315+ // Get the current style from parent (might be heading)
316+ parentStyle := r .cs .peek ().textStyle
317+
318+ // Determine if parent is a heading by checking font size
319+ linkStyle := r .Link
320+ isInsideHeading := parentStyle .Size > r .Normal .Size
321+
322+ if isInsideHeading {
323+ // Preserve heading size/font, but use link color
324+ linkStyle = Styler {
325+ Font : parentStyle .Font ,
326+ Style : parentStyle .Style ,
327+ Size : parentStyle .Size ,
328+ Spacing : parentStyle .Spacing ,
329+ TextColor : r .Link .TextColor , // Link blue color
330+ FillColor : parentStyle .FillColor ,
331+ }
332+ }
333+
314334 x := & containerState {
315- textStyle : r .Link , listkind : notlist ,
335+ textStyle : linkStyle ,
336+ listkind : notlist ,
316337 leftMargin : r .cs .peek ().leftMargin ,
317- destination : destination }
338+ destination : destination ,
339+ }
318340 r .cs .push (x )
319341 r .tracer ("Link (entering)" ,
320342 fmt .Sprintf ("Destination[%v] Title[%v]" ,
0 commit comments