From 8d33bcc1c1b5c20267ad97e87e1794df267ddc54 Mon Sep 17 00:00:00 2001 From: Folkert Kevelam Date: Sun, 25 May 2025 20:16:02 +0200 Subject: [PATCH] Change table with codeblocks to nested div's --- source/aqs2mdx.adb | 24 ++++++++++++++++++------ source/pandoc.ads | 4 ++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/source/aqs2mdx.adb b/source/aqs2mdx.adb index eb57cd3..7799bb9 100644 --- a/source/aqs2mdx.adb +++ b/source/aqs2mdx.adb @@ -104,7 +104,8 @@ procedure Aqs2mdx is -- in .md declare -- Table structure in pandoc-types-1.23.1. See - -- https://hackage.haskell.org/package/pandoc-types-1.23.1/docs/ + -- https://hackage.haskell.org/package/pandoc-types-1.23.1/ + -- docs/ -- Text-Pandoc-Definition.html -- -- Table: @@ -138,6 +139,16 @@ procedure Aqs2mdx is Cell_List : constant League.JSON.Arrays.JSON_Array := Row (2).To_Array; + Columns_Div : Pandoc.Content_Arr (1 .. Cell_List.Length); + + Outer_Attr : constant League.JSON.Values.JSON_Value := + Pandoc.Attr ( + +"", ( 1 => +"className"), ( 1 => +"multi-column")); + + Inner_Attr : constant League.JSON.Values.JSON_Value := + Pandoc.Attr ( + +"", ( 1 => +"className"), ( 1 => +"multi-column-child")); + begin pragma Assert (Content.Length = 6); pragma Assert (Table_Body_List.Length = 1); @@ -152,16 +163,17 @@ procedure Aqs2mdx is Cell : constant League.JSON.Arrays.JSON_Array := Cell_List (J).To_Array; - Block_List : constant League.JSON.Arrays.JSON_Array := - Cell (5).To_Array; + Block_List : constant League.JSON.Values.JSON_Value := + Cell (5); + begin pragma Assert (Cell.Length = 5); - for K in 1 .. Block_List.Length loop - List.Append (Block_List (K)); - end loop; + Columns_Div (J) := Pandoc.Div (Inner_Attr, Block_List); end; end loop; + + List.Append (Pandoc.Div (Outer_Attr, Columns_Div)); end; when Block_Header => if Block (Pandoc.Content_String).To_Array.Element (1) diff --git a/source/pandoc.ads b/source/pandoc.ads index 91812a6..58167ad 100644 --- a/source/pandoc.ads +++ b/source/pandoc.ads @@ -81,7 +81,7 @@ private return Ada.Containers.Hash_Type; Obj_String_Representation : - constant array (Object_Type) of Ustr.Universal_String := [ + constant array (Object_Type) of Ustr.Universal_String := ( +"Plain", +"Para", +"LineBlock", @@ -116,7 +116,7 @@ private +"Image", +"Note", +"Span" - ]; + ); package Type_Map is new Ada.Containers.Hashed_Maps ( Key_Type => Ustr.Universal_String,