diff --git a/source/aqs2mdx.adb b/source/aqs2mdx.adb index ceb3bfb..caea3a0 100644 --- a/source/aqs2mdx.adb +++ b/source/aqs2mdx.adb @@ -188,6 +188,15 @@ 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 diff --git a/source/pandoc.adb b/source/pandoc.adb index b052a2f..cc6073b 100644 --- a/source/pandoc.adb +++ b/source/pandoc.adb @@ -1,7 +1,5 @@ pragma Ada_2022; -with League.JSON.Arrays; - package body Pandoc is function Attr @@ -95,6 +93,88 @@ package body Pandoc is return Block.To_JSON_Value; end Div; + function HTML_Block (Text : League.Strings.Universal_String) return + League.JSON.Values.JSON_Value + is + Output : League.JSON.Objects.JSON_Object; + Content_Arr : League.JSON.Arrays.JSON_Array; + begin + Output.Insert ( + Type_String, + League.JSON.Values.To_JSON_Value (+"RawBlock")); + + Content_Arr.Append ( + League.JSON.Values.To_JSON_Value (+"html")); + + Content_Arr.Append ( + League.JSON.Values.To_JSON_Value (Text)); + + Output.Insert ( + Content_String, + Content_Arr.To_JSON_Value); + + return Output.To_JSON_Value; + end HTML_Block; + + function Plain (Inlines : League.JSON.Values.JSON_Value) return + League.JSON.Values.JSON_Value + is + Output : League.JSON.Objects.JSON_Object; + begin + Output.Insert ( + Type_String, + League.JSON.Values.To_JSON_Value (+"Plain")); + + Output.Insert ( + Content_String, + Inlines); + + return Output.To_JSON_Value; + end Plain; + + function Definition_List (B : League.JSON.Objects.JSON_Object) return + League.JSON.Arrays.JSON_Array + is + Output : League.JSON.Arrays.JSON_Array; + Content : constant League.JSON.Arrays.JSON_Array := + B (Content_String).To_Array; + begin + Output.Append (HTML_Block (+"
")); + + for I in 1 .. Content.Length loop + declare + Def_Item : constant League.JSON.Arrays.JSON_Array := + Content (I).To_Array; + Def_Header : constant League.JSON.Arrays.JSON_Array := + Def_Item (1).To_Array; + Def_Content : constant League.JSON.Arrays.JSON_Array := + Def_Item (2).To_Array; + begin + Output.Append (HTML_Block (+"
")); + Output.Append (Plain (Def_Header.To_JSON_Value)); + Output.Append (HTML_Block (+"
")); + + for J in 1 .. Def_Content.Length loop + declare + Def_Sub_Content : constant League.JSON.Arrays.JSON_Array := + Def_Content (J).To_Array; + begin + for K in 1 .. Def_Sub_Content.Length loop + Output.Append (Def_Sub_Content (K)); + end loop; + end; + end loop; + + Output.Append (HTML_Block (+"
")); + end; + end loop; + + Output.Append (HTML_Block (+"
")); + + return Output; + + end Definition_List; + function Get_Type (B : League.JSON.Objects.JSON_Object) return Object_Type is (Type_Mapping (B (Type_String).To_String)); diff --git a/source/pandoc.ads b/source/pandoc.ads index 9f02fc1..1128702 100644 --- a/source/pandoc.ads +++ b/source/pandoc.ads @@ -4,6 +4,7 @@ with League.JSON.Objects; with League.Strings.Hash; with League.Strings; with League.JSON.Values; +with League.JSON.Arrays; package Pandoc is @@ -75,6 +76,15 @@ package Pandoc is Content : League.JSON.Values.JSON_Value) return League.JSON.Values.JSON_Value; + function HTML_Block (Text : League.Strings.Universal_String) + return League.JSON.Values.JSON_Value; + + function Plain (Inlines : League.JSON.Values.JSON_Value) return + League.JSON.Values.JSON_Value; + + function Definition_List (B : League.JSON.Objects.JSON_Object) return + League.JSON.Arrays.JSON_Array; + Type_String : constant League.Strings.Universal_String := +"t"; Content_String : constant League.Strings.Universal_String := +"c";