Compare commits

..

No commits in common. "feature-callback-based" and "main" have entirely different histories.

5 changed files with 111 additions and 203 deletions

View File

@ -188,15 +188,6 @@ procedure Aqs2mdx is
end if;
when Inline_Link =>
List.Append (Traverse_Link (Block));
when Block_DefinitionList =>
declare
Arr : League.JSON.Arrays.JSON_Array :=
Pandoc.Definition_List (Block);
begin
for I in 1 .. Arr.Length loop
List.Append (Arr(I));
end loop;
end;
when others =>
if Block (Pandoc.Content_String).To_Array.Length > 0 then
declare

View File

@ -1,59 +0,0 @@
package body Pandoc.Blocks is
function Create_Block
(T : Object_Type;
Content : League.JSON.Values.JSON_Value)
return League.JSON.Values.JSON_Value
is
begin
return Create_Block (T, Empty_Attribute, Content);
end Create_Block;
function Create_Block
(T : Object_Type;
Attr : League.JSON.Values.JSON_Value;
Content : League.JSON.Values.JSON_Value)
return League.JSON.Values.JSON_Value
is
Block : League.JSON.Objects.JSON_Object;
New_Content : League.JSON.Arrays.JSON_Array;
begin
New_Content.Append (Attr);
New_Content.Append (Content);
Block.Insert
(Type_String, League.JSON.Values.To_JSON_Value( Type_To_String (T)));
Block.Insert (Content_String, New_Content);
return Block.To_JSON_Value;
end Create_Block;
function Raw_Block
(T : League.Strings.Universal_String;
Content : League.Strings.Universal_String)
return League.JSON.Values.JSON_Value
is
begin
return Raw_Block (Empty_Attribute, T, Content);
end Raw_Block;
function Raw_Block
(Attr : League.JSON.Values.JSON_Value;
T : League.Strings.Universal_String;
Content : League.Strings.Universal_String
return League.JSON.Values.JSON_Value
is
Formatted_Content : League.JSON.Arrays.JSON_Array;
begin
Formatted_Content.Append (
League.JSON.Values.To_JSON_Value (T));
Formatted_Content.Append (
League.JSON.Values.To_JSON_Value (Content));
return Create_Block (Block_RawBlock, Attr, Formatted_Content);
end Raw_Block;
end Pandoc.Blocks;

View File

@ -1,28 +0,0 @@
with League.JSON.Values;
with League.JSON.Arrays.JSON_Array;
package Pandoc.Blocks is
function Create_Block
(T : Object_Type;
Content : League.JSON.Values.JSON_Value)
return League.JSON.Values.JSON_Value;
function Create_Block
(T : Object_Type;
Attr : League.JSON.Values.JSON_Value;
Content : League.JSON.Values.JSON_Value)
return League.JSON.Values.JSON_Value;
function Raw_Block
(T : League.Strings.Universal_String;
Content : League.Strings.Universal_String)
return League.JSON.Values.JSON_Value;
function Raw_Block
(Attr : League.JSON.Values.JSON_Value;
T : League.Strings.Universal_String;
Content : League.Strings.Universal_String)
return League.JSON.Values.JSON_Value;
end Pandoc.Blocks;

View File

@ -1,85 +1,102 @@
pragma Ada_2022;
with League.JSON.Arrays;
package body Pandoc is
function Get_Type (B : League.JSON.Objects.JSON_Object)
return Object_Type is (Type_Mapping (B (Type_String).To_String));
function Type_To_String (T : Object_Type)
return League.Strings.Universal_String
is
begin
return Obj_String_Representation (T);
end Type_To_String;
function Attr
(Id : League.Strings.Universal_String;
Key : League.Strings.Universal_String;
Value : League.Strings.Universal_String)
return League.JSON.Values.JSON_Value
is
Key_Value_Pair : League.JSON.Arrays.JSON_Array;
Attr_Map : League.JSON.Arrays.JSON_Array;
Attr : League.JSON.Arrays.JSON_Array;
begin
Key_Value_Pair.Append (
League.JSON.Values.To_JSON_Value (Key));
Key_Value_Pair.Append (
League.JSON.Values.To_JSON_Value (Value));
Attr_Map.Append (Key_Value_Pair.To_JSON_Value);
Attr.Append (
League.JSON.Values.To_JSON_Value (Id));
Attr.Append (Attr_Map.To_JSON_Value);
return Attr.To_JSON_Value;
end Attr;
function Attr
(Id : League.Strings.Universal_String;
Key_Value : Key_Value_Pairs)
return League.JSON.Values.JSON_Value
is
Attr_Map : League.JSON.Arrays.JSON_Array;
Attr : League.JSON.Arrays.JSON_Array;
begin
for J in Key_Value'Range loop
declare
Pair : League.JSON.Arrays.JSON_Array;
begin
Pair.Append (
League.JSON.Values.To_JSON_Value (Key_Value (J).Key));
Pair.Append (
League.JSON.Values.To_JSON_Value (Key_Value (J).Value));
Attr_Map.Append (Pair.To_JSON_Value);
end;
end loop;
Attr.Append (
League.JSON.Values.To_JSON_Value (Id));
Attr.Append (Attr_Map.To_JSON_Value);
return Attr.To_JSON_Value;
end Attr;
function Attr
(Key : League.Strings.Universal_String;
Value : League.Strings.Universal_String)
return League.JSON.Values.JSON_Value
Value : League.Strings.Universal_String;
Id : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String)
return League.JSON.Values.JSON_Value is
(Attr (Id, [Key], [Value]));
function Attr
(Id : League.Strings.Universal_String;
Key : String_Array;
Value : String_Array) return League.JSON.Values.JSON_Value
is
Outer : League.JSON.Arrays.JSON_Array;
Other : League.JSON.Arrays.JSON_Array;
Inner : League.JSON.Arrays.JSON_Array;
begin
return Attr (+"", Key, Value);
Outer.Append (League.JSON.Values.To_JSON_Value (Id));
Outer.Append (Other.To_JSON_Value);
for K in Key'Range loop
declare
Pair : League.JSON.Arrays.JSON_Array;
begin
Pair.Append (League.JSON.Values.To_JSON_Value (Key (K)));
Pair.Append (League.JSON.Values.To_JSON_Value (Value (K)));
Inner.Append (Pair.To_JSON_Value);
end;
end loop;
Outer.Append (Inner.To_JSON_Value);
return Outer.To_JSON_Value;
end Attr;
function Attr (Key_Value : Key_Value_Pairs)
function Div (
Attr : League.JSON.Values.JSON_Value;
Content : Content_Arr) return League.JSON.Values.JSON_Value
is
Block : League.JSON.Objects.JSON_Object;
Out_Content : League.JSON.Arrays.JSON_Array;
Content_Block : League.JSON.Arrays.JSON_Array;
begin
Block.Insert (
Type_String,
League.JSON.Values.To_JSON_Value (
Obj_String_Representation (Block_Div)
)
);
for C in Content'Range loop
Content_Block.Append (Content (C));
end loop;
Out_Content.Append (Attr);
Out_Content.Append (Content_Block.To_JSON_Value);
Block.Insert (
Content_String,
Out_Content.To_JSON_Value
);
return Block.To_JSON_Value;
end Div;
function Div
(Attr : League.JSON.Values.JSON_Value;
Content : League.JSON.Values.JSON_Value)
return League.JSON.Values.JSON_Value
is
Block : League.JSON.Objects.JSON_Object;
Out_Content : League.JSON.Arrays.JSON_Array;
begin
return Attr (+"", Key_Value);
end Attr;
Block.Insert (
Type_String,
League.JSON.Values.To_JSON_Value (
Obj_String_Representation (Block_Div)
)
);
Out_Content.Append (Attr);
Out_Content.Append (Content);
Block.Insert (
Content_String,
Out_Content.To_JSON_Value
);
return Block.To_JSON_Value;
end Div;
function Get_Type (B : League.JSON.Objects.JSON_Object)
return Object_Type is (Type_Mapping (B (Type_String).To_String));
begin

View File

@ -1,15 +1,15 @@
pragma Ada_2022;
with Ada.Containers;
with Ada.Containers.Hashed_Maps;
with League.JSON.Objects;
with League.Strings.Hash;
with League.Strings;
with League.JSON.Values;
with League.JSON.Arrays;
package Pandoc is
type String_Array is array (Natural range <>) of
League.Strings.Universal_String;
type Object_Type is
(Block_Plain,
Block_Para,
@ -46,55 +46,42 @@ package Pandoc is
Inline_Note,
Inline_Span);
type Key_Value_Pair is
record
Key : League.Strings.Universal_String;
Value : League.Strings.Universal_String;
end record;
type Key_Value_Pairs is array (Natural range <>) of Key_Value_Pair;
type Content_Arr is array (Natural range <>)
of League.JSON.Values.JSON_Value;
function Get_Type (B : League.JSON.Objects.JSON_Object) return Object_Type;
function Type_To_String (T : Object_Type)
return League.Strings.Universal_String;
Type_String : constant League.Strings.Universal_String :=
League.Strings.To_Universal_String ("t");
Content_String : constant League.Strings.Universal_String :=
League.Strings.To_Universal_String ("c");
function Attr
(Id : League.Strings.Universal_String;
Key : League.Strings.Universal_String;
Value : League.Strings.Universal_String)
return League.JSON.Values.JSON_Value;
function Attr
(Id : League.Strings.Universal_String;
Key_Value : Key_Value_Pairs)
return League.JSON.Values.JSON_Value;
function Attr
(Key : League.Strings.Universal_String;
Value : League.Strings.Universal_String)
return League.JSON.Values.JSON_Value;
function Attr (Key_Value : Key_Value_Pairs)
return League.JSON.Values.JSON_Value;
Empty_Attribute : constant League.JSON.Values.JSON_Value := Attr([]);
private
type String_Array is array (Natural range <>) of
League.Strings.Universal_String;
function "+" (T : Wide_Wide_String) return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
function Attr
(Key : League.Strings.Universal_String;
Value : League.Strings.Universal_String;
Id : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String)
return League.JSON.Values.JSON_Value;
function Attr
(Id : League.Strings.Universal_String;
Key : String_Array;
Value : String_Array) return League.JSON.Values.JSON_Value;
function Div
(Attr : League.JSON.Values.JSON_Value;
Content : Content_Arr) return League.JSON.Values.JSON_Value;
function Div
(Attr : League.JSON.Values.JSON_Value;
Content : League.JSON.Values.JSON_Value)
return League.JSON.Values.JSON_Value;
Type_String : constant League.Strings.Universal_String := +"t";
Content_String : constant League.Strings.Universal_String := +"c";
private
Obj_String_Representation :
constant array (Object_Type) of League.Strings.Universal_String := [
constant array (Object_Type) of League.Strings.Universal_String := (
+"Plain",
+"Para",
+"LineBlock",
@ -129,7 +116,7 @@ private
+"Image",
+"Note",
+"Span"
];
);
package Type_Map is new Ada.Containers.Hashed_Maps (
Key_Type => League.Strings.Universal_String,