markdown_24.0.0_70ffe37b/source/parser/implementation/markdown-implementation-list_items.ads

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--
--  Copyright (C) 2021-2023, AdaCore
--
--  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--

--  Internal representation of a markdown list item

package Markdown.Implementation.List_Items is

   pragma Preelaborate;

   type List_Item is new Abstract_Container_Block with private;
   --  The List_Item is a node for markdown list item representation

   type List_Item_Access is access all List_Item;

   procedure Detector
     (Input : Input_Position;
      Tag   : in out Ada.Tags.Tag;
      CIP   : out Can_Interrupt_Paragraph);
   --  The detector procedure to find start of a list item

   function Is_Ordered (Self : List_Item'Class) return Boolean;
   --  Return True if list item has an ordered list marker.

   function Marker (Self : List_Item'Class) return VSS.Strings.Virtual_String;
   --  List item marker as a string

   function Marker (Self : List_Item'Class) return Natural
     with Pre => Self.Is_Ordered;
   --  List item marker as an integer

private
   type List_Item is new Abstract_Container_Block with record
      Is_Ordered             : Boolean;
      Marker                 : VSS.Strings.Virtual_String;
      --  Marker it-self, like `-`, `11.`, etc.
      Marker_Value           : Natural;  --  Marker value if ordered, like 11
      Marker_Width           : VSS.Strings.Character_Count;
      --  Number of spaces to skip in subsequent lines
      Starts_With_Blank_Line : Boolean := False;
      --  The item starts with an empty line
      Ends_With_Blank_Line   : Boolean := False;
      --  The last known line of the item was empty
      Has_Blank_Line         : Boolean := False;
      --  The item has at least one empty line (excluding line with the marker)
      First_Line             : Boolean := False;
      --  This is true only for the line with the marker
   end record;

   overriding function Create (Input : not null access Input_Position)
     return List_Item;

   overriding procedure Consume_Continuation_Markers
     (Self  : in out List_Item;
      Input : in out Input_Position;
      Ok    : out Boolean);

end Markdown.Implementation.List_Items;