Skip to content

Commit 37ee442

Browse files
committed
Merge branch 'topic/update_md' into 'master'
Update after Markdown API changes See merge request eng/ide/gnatdoc!169
2 parents 93ea389 + 1203d10 commit 37ee442

File tree

4 files changed

+103
-154
lines changed

4 files changed

+103
-154
lines changed

source/backend/gnatdoc-backend-html_markup.adb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ with VSS.IRIs;
1919
with VSS.XML.Events;
2020
with VSS.XML.Namespaces;
2121

22-
with Markdown.Annotations.Visitors;
22+
with Markdown.Inlines.Visitors;
2323
with Markdown.Block_Containers;
2424
with Markdown.Blocks.Indented_Code;
2525
with Markdown.Blocks.Lists;
@@ -30,7 +30,7 @@ with Markdown.Parsers.GNATdoc_Enable;
3030
package body GNATdoc.Backend.HTML_Markup is
3131

3232
type Annotated_Text_Builder is
33-
limited new Markdown.Annotations.Visitors.Annotated_Text_Visitor with
33+
limited new Markdown.Inlines.Visitors.Annotated_Text_Visitor with
3434
record
3535
Image : Boolean := False;
3636
Text : VSS.Strings.Virtual_String;
@@ -71,7 +71,7 @@ package body GNATdoc.Backend.HTML_Markup is
7171

7272
procedure Build_Annotated_Text
7373
(Result : in out VSS.XML.Event_Vectors.Vector;
74-
Item : Markdown.Annotations.Annotated_Text'Class);
74+
Item : Markdown.Inlines.Inline_Vector'Class);
7575

7676
procedure Build_Block
7777
(Result : in out VSS.XML.Event_Vectors.Vector;
@@ -126,10 +126,10 @@ package body GNATdoc.Backend.HTML_Markup is
126126

127127
procedure Build_Annotated_Text
128128
(Result : in out VSS.XML.Event_Vectors.Vector;
129-
Item : Markdown.Annotations.Annotated_Text'Class)
129+
Item : Markdown.Inlines.Inline_Vector'Class)
130130
is
131131
Visitor : Annotated_Text_Builder;
132-
Iterator : Markdown.Annotations.Visitors.Annotated_Text_Iterator;
132+
Iterator : Markdown.Inlines.Visitors.Annotated_Text_Iterator;
133133

134134
begin
135135
Iterator.Iterate (Item, Visitor);
@@ -229,6 +229,7 @@ package body GNATdoc.Backend.HTML_Markup is
229229

230230
begin
231231
Markdown.Parsers.GNATdoc_Enable (Parser);
232+
Parser.Set_Extensions ((Link_Attributes => True));
232233

233234
for Line of Text loop
234235
Parser.Parse_Line (Line);

source/backend/markdown-annotations-visitors.adb

Lines changed: 0 additions & 146 deletions
This file was deleted.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
--
2+
-- Copyright (C) 2025, AdaCore
3+
--
4+
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
--
6+
7+
package body Markdown.Inlines.Visitors is
8+
9+
-------------
10+
-- Iterate --
11+
-------------
12+
13+
procedure Iterate
14+
(Self : in out Annotated_Text_Iterator'Class;
15+
Text : Markdown.Inlines.Inline_Vector'Class;
16+
Visitor : in out Annotated_Text_Visitor'Class)
17+
is
18+
pragma Unreferenced (Self);
19+
20+
type Iteration_State is record
21+
Destination : VSS.Strings.Virtual_String;
22+
-- Link/image url
23+
Title : VSS.Strings.Virtual_String;
24+
-- Link/image title
25+
Attributes : Markdown.Attribute_Lists.Attribute_List;
26+
-- Link/image attributes if Link_Attributes extension is on
27+
end record;
28+
-- Suppose we don't have nested images for now.
29+
30+
procedure Iterate
31+
(State : in out Iteration_State;
32+
Item : Markdown.Inlines.Inline);
33+
34+
-------------
35+
-- Iterate --
36+
-------------
37+
38+
procedure Iterate
39+
(State : in out Iteration_State;
40+
Item : Markdown.Inlines.Inline)
41+
is
42+
43+
Ignore : Boolean;
44+
45+
begin
46+
case Item.Kind is
47+
when Markdown.Inlines.Text =>
48+
Visitor.Visit_Text (Item.Text);
49+
50+
when Markdown.Inlines.Start_Emphasis =>
51+
Visitor.Enter_Emphasis;
52+
53+
when Markdown.Inlines.End_Emphasis =>
54+
Visitor.Leave_Emphasis;
55+
56+
when Markdown.Inlines.Start_Strong =>
57+
Visitor.Enter_Strong;
58+
59+
when Markdown.Inlines.End_Strong =>
60+
Visitor.Leave_Strong;
61+
62+
when Markdown.Inlines.Code_Span =>
63+
Visitor.Enter_Code_Span;
64+
Visitor.Visit_Text (Item.Code_Span);
65+
Visitor.Leave_Code_Span;
66+
67+
when Markdown.Inlines.Start_Image =>
68+
State :=
69+
(Destination => Item.Destination,
70+
Title => Item.Title.Join_Lines (VSS.Strings.LF),
71+
Attributes => Item.Attributes);
72+
73+
Visitor.Enter_Image
74+
(Destination => State.Destination,
75+
Title => State.Title);
76+
77+
when Markdown.Inlines.End_Image =>
78+
Visitor.Leave_Image
79+
(Destination => State.Destination,
80+
Title => State.Title);
81+
82+
when others =>
83+
null;
84+
end case;
85+
end Iterate;
86+
87+
State : Iteration_State;
88+
begin
89+
for Item of Text loop
90+
Iterate (State, Item);
91+
end loop;
92+
end Iterate;
93+
94+
end Markdown.Inlines.Visitors;

source/backend/markdown-annotations-visitors.ads renamed to source/backend/markdown-inlines-visitors.ads

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55
--
66

7-
package Markdown.Annotations.Visitors
7+
package Markdown.Inlines.Visitors
88
with Preelaborate
99
is
1010

@@ -46,7 +46,7 @@ is
4646

4747
procedure Iterate
4848
(Self : in out Annotated_Text_Iterator'Class;
49-
Text : Markdown.Annotations.Annotated_Text'Class;
49+
Text : Markdown.Inlines.Inline_Vector'Class;
5050
Visitor : in out Annotated_Text_Visitor'Class);
5151

5252
private
@@ -55,4 +55,4 @@ private
5555
null;
5656
end record;
5757

58-
end Markdown.Annotations.Visitors;
58+
end Markdown.Inlines.Visitors;

0 commit comments

Comments
 (0)