Skip to content

Commit

Permalink
Fix the <ref> processing again
Browse files Browse the repository at this point in the history
The string/rope semantics continue to bite us. The original fix in bd1cd44 was not correct, for unclear reasons. This version uses ExtractAll() to ensure we get a fresh CutRope that we can AppendDestructively() to Scratch, which is more in line with what other parts of the file do.
  • Loading branch information
domenic committed Aug 8, 2023
1 parent 0ad4342 commit 27ab106
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/wattsi.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1585,19 +1585,25 @@ TCrossReferences = record
ListNode^.Next := References[ReferenceName];
References[ReferenceName] := ListNode;
MissingReferences[ReferenceName] := ListNode;

NewLink := ConstructHTMLElement(eA);
Scratch := Default(Rope);
ExtractedData := Element.TextContent.ExtractAll();
Scratch.Append('#refs');
Scratch.Append(@ReferenceName);
Scratch.AppendDestructively(ExtractedData);
NewLink.SetAttributeDestructively('href', Scratch);

Scratch := Default(Rope);
ExtractedData := Element.TextContent.ExtractAll();
Scratch.Append('[');
Scratch.Append(@ReferenceName);
Scratch.AppendDestructively(ExtractedData);
Scratch.Append(']');
NewLink.AppendChild(TText.CreateDestructively(Scratch));

(Node.ParentNode as TElement).ReplaceChild(NewLink, Node);
Node.Free();
Node := NewLink;

Result := ProcessNode(Node);
end
else
Expand Down

0 comments on commit 27ab106

Please sign in to comment.