1 package org.apache.maven.doxia.book.services.renderer.xhtml;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.doxia.module.xhtml.XhtmlSink;
23 import org.apache.maven.doxia.sink.render.RenderingContext;
24 import org.codehaus.plexus.util.StringUtils;
25
26 import java.io.Writer;
27
28
29
30
31
32
33
34 public class XhtmlBookSink
35 extends XhtmlSink
36 {
37 private RenderingContext renderingContext;
38
39
40
41
42
43
44
45 public XhtmlBookSink( Writer out, RenderingContext context )
46 {
47 super( out );
48 this.renderingContext = context;
49 }
50
51
52
53
54
55
56
57
58
59
60 public void head()
61 {
62 init();
63
64 setHeadFlag( true );
65 }
66
67
68
69
70
71
72 public void head_()
73 {
74 setHeadFlag( false );
75 }
76
77
78
79
80
81
82 public void title()
83 {
84
85 }
86
87
88
89
90
91
92 public void title_()
93 {
94 resetTextBuffer();
95 }
96
97
98
99
100
101
102 public void author_()
103 {
104 resetTextBuffer();
105 }
106
107
108
109
110
111
112 public void date_()
113 {
114 resetTextBuffer();
115 }
116
117
118
119
120
121
122 public void body()
123 {
124
125 }
126
127
128
129
130
131
132 public void body_()
133 {
134
135 }
136
137
138
139
140 public void bookHead()
141 {
142 super.head();
143 }
144
145
146
147
148 public void bookHead_()
149 {
150 super.head_();
151 }
152
153
154
155
156 public void bookTitle()
157 {
158 super.title();
159 }
160
161
162
163
164 public void bookTitle_()
165 {
166 super.title_();
167 }
168
169
170
171
172 public void bookAuthor()
173 {
174 super.author();
175 }
176
177
178
179
180 public void bookAuthor_()
181 {
182 super.author_();
183 }
184
185
186
187
188 public void bookDate()
189 {
190 super.date();
191 }
192
193
194
195
196 public void bookDate_()
197 {
198 super.date_();
199 }
200
201
202
203
204 public void bookBody()
205 {
206 super.body();
207 }
208
209
210
211
212 public void bookBody_()
213 {
214 super.body_();
215 }
216
217
218 public void sectionTitle()
219 {
220 writeStartTag( H1 );
221 }
222
223
224 public void sectionTitle_()
225 {
226 writeEndTag( H1 );
227 }
228
229
230 protected void write( String text )
231 {
232 if ( renderingContext != null )
233 {
234 String relativePathToBasedir = renderingContext.getRelativePath();
235
236 if ( relativePathToBasedir == null )
237 {
238 text = StringUtils.replace( text, "$relativePath", "." );
239 }
240 else
241 {
242 text = StringUtils.replace( text, "$relativePath", relativePathToBasedir );
243 }
244 }
245
246 super.write( text );
247 }
248 }