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; end if;
when Inline_Link => when Inline_Link =>
List.Append (Traverse_Link (Block)); 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 => when others =>
if Block (Pandoc.Content_String).To_Array.Length > 0 then if Block (Pandoc.Content_String).To_Array.Length > 0 then
declare 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 package body Pandoc is
function Get_Type (B : League.JSON.Objects.JSON_Object) function Attr
return Object_Type is (Type_Mapping (B (Type_String).To_String)); (Key : League.Strings.Universal_String;
Value : League.Strings.Universal_String;
function Type_To_String (T : Object_Type) Id : League.Strings.Universal_String :=
return League.Strings.Universal_String League.Strings.Empty_Universal_String)
is return League.JSON.Values.JSON_Value is
begin (Attr (Id, [Key], [Value]));
return Obj_String_Representation (T);
end Type_To_String;
function Attr function Attr
(Id : League.Strings.Universal_String; (Id : League.Strings.Universal_String;
Key : League.Strings.Universal_String; Key : String_Array;
Value : League.Strings.Universal_String) Value : String_Array) return League.JSON.Values.JSON_Value
return League.JSON.Values.JSON_Value
is is
Key_Value_Pair : League.JSON.Arrays.JSON_Array; Outer : League.JSON.Arrays.JSON_Array;
Attr_Map : League.JSON.Arrays.JSON_Array; Other : League.JSON.Arrays.JSON_Array;
Attr : League.JSON.Arrays.JSON_Array; Inner : League.JSON.Arrays.JSON_Array;
begin begin
Key_Value_Pair.Append ( Outer.Append (League.JSON.Values.To_JSON_Value (Id));
League.JSON.Values.To_JSON_Value (Key)); Outer.Append (Other.To_JSON_Value);
Key_Value_Pair.Append (
League.JSON.Values.To_JSON_Value (Value));
Attr_Map.Append (Key_Value_Pair.To_JSON_Value); for K in Key'Range 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
(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 declare
Pair : League.JSON.Arrays.JSON_Array; Pair : League.JSON.Arrays.JSON_Array;
begin begin
Pair.Append ( Pair.Append (League.JSON.Values.To_JSON_Value (Key (K)));
League.JSON.Values.To_JSON_Value (Key_Value (J).Key)); Pair.Append (League.JSON.Values.To_JSON_Value (Value (K)));
Pair.Append ( Inner.Append (Pair.To_JSON_Value);
League.JSON.Values.To_JSON_Value (Key_Value (J).Value));
Attr_Map.Append (Pair.To_JSON_Value);
end; end;
end loop; end loop;
Attr.Append ( Outer.Append (Inner.To_JSON_Value);
League.JSON.Values.To_JSON_Value (Id));
Attr.Append (Attr_Map.To_JSON_Value); return Outer.To_JSON_Value;
return Attr.To_JSON_Value;
end Attr; end Attr;
function Attr function Div (
(Key : League.Strings.Universal_String; Attr : League.JSON.Values.JSON_Value;
Value : League.Strings.Universal_String) Content : Content_Arr) return League.JSON.Values.JSON_Value
return League.JSON.Values.JSON_Value
is is
Block : League.JSON.Objects.JSON_Object;
Out_Content : League.JSON.Arrays.JSON_Array;
Content_Block : League.JSON.Arrays.JSON_Array;
begin begin
return Attr (+"", Key, Value); Block.Insert (
end Attr; Type_String,
League.JSON.Values.To_JSON_Value (
Obj_String_Representation (Block_Div)
)
);
function Attr (Key_Value : Key_Value_Pairs) for C in Content'Range loop
return League.JSON.Values.JSON_Value 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 is
Block : League.JSON.Objects.JSON_Object;
Out_Content : League.JSON.Arrays.JSON_Array;
begin begin
return Attr (+"", Key_Value); Block.Insert (
end Attr; 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 begin

View File

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