1 ------------------------------------------------------------------------------
4 -- Copyright (C) 2007-2008 --
7 -- This library is free software; you can redistribute it and/or modify --
8 -- it under the terms of the GNU General Public License as published by --
9 -- the Free Software Foundation; either version 2 of the License, or (at --
10 -- your option) any later version. --
12 -- This library is distributed in the hope that it will be useful, but --
13 -- WITHOUT ANY WARRANTY; without even the implied warranty of --
14 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
15 -- General Public License for more details. --
17 -- You should have received a copy of the GNU General Public License --
18 -- along with this library; if not, write to the Free Software Foundation, --
19 -- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. --
20 ------------------------------------------------------------------------------
22 with Ada
.Containers
.Vectors
;
24 package body Diouzhtu
is
27 use Ada
.Strings
.Unbounded
;
29 type Callback
is record
33 package Callbacks
is new Containers
.Vectors
34 (Index_Type
=> Positive,
35 Element_Type
=> Callback
,
39 Blocks
: Vector
:= Empty_Vector
;
40 Inlines
: Vector
:= Empty_Vector
;
47 (Base_URL
: in String;
48 Img_Base_URL
: in String;
49 Text_Directory
: in String)
50 return Wiki_Information
is
52 return Wiki_Information
'
53 (Base_URL => To_Unbounded_String (Base_URL),
54 Img_Base_URL => To_Unbounded_String (Img_Base_URL),
55 Text_Directory => To_Unbounded_String (Text_Directory));
58 -----------------------
59 -- Internal_Register --
60 -----------------------
62 procedure Internal_Register
63 (Level : in Register_Level;
64 To_HTML : in Converter)
66 Register_Callback : Callback;
68 Register_Callback.To_HTML := To_HTML;
69 if Level = Block_Level then
70 Blocks.Append (Register_Callback);
72 Inlines.Append (Register_Callback);
74 end Internal_Register;
81 (Wiki : in Wiki_Information;
82 Level : in Register_Level;
84 Index : in Natural := 0)
90 if Level = Block_Level then
97 Current := Container.First_Index;
102 if Last_Index (Container) >= Current then
103 return Callback (Element (Container, Current)).To_HTML
104 (Wiki, Current, Content);
115 (Level : in Register_Level;
118 Register_Callback : Callback;
121 -- First Inlines callback is code and user callbacks should
123 -- Insert them after code callback
125 Register_Callback.To_HTML := To_HTML;
126 if Level = Block_Level then
127 Blocks.Prepend (New_Item => Register_Callback);
129 Inlines.Insert (Before => Next (Inlines.First),
130 New_Item => Register_Callback);