~ubuntu-branches/ubuntu/vivid/doxia/vivid-proposed

« back to all changes in this revision

Viewing changes to doxia-modules/doxia-module-latex/src/test/java/org/apache/maven/doxia/module/latex/LatexSinkTest.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-10-08 14:20:22 UTC
  • mfrom: (2.3.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091008142022-f6ccxganfr2tbaig
Tags: 1.1-3build1
Upload to karmic, avoiding new version from unstable. LP: #443292.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
import java.io.Writer;
23
23
 
24
 
import org.apache.maven.doxia.module.latex.LatexSink;
25
24
import org.apache.maven.doxia.sink.Sink;
26
25
import org.apache.maven.doxia.sink.AbstractSinkTest;
27
26
 
28
27
/**
29
28
 * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
30
 
 * @version $Id: LatexSinkTest.java 599204 2007-11-28 23:49:33Z hboutemy $
 
29
 * @version $Id: LatexSinkTest.java 707983 2008-10-26 12:37:49Z vsiveton $
31
30
 */
32
31
public class LatexSinkTest
33
32
    extends AbstractSinkTest
45
44
    }
46
45
 
47
46
    /** {@inheritDoc} */
 
47
    protected boolean isXmlSink()
 
48
    {
 
49
        return false;
 
50
    }
 
51
 
 
52
    /** {@inheritDoc} */
48
53
    protected String getTitleBlock( String title )
49
54
    {
50
 
        return "\\ptitle{" + title + "}";
 
55
        return "\\title{" + LatexSink.escaped( title ) + "}" + EOL;
51
56
    }
52
57
 
53
58
    /** {@inheritDoc} */
54
59
    protected String getAuthorBlock( String author )
55
60
    {
56
 
        return "\\pauthor{" + author + "}";
 
61
        return "\\author{" + LatexSink.escaped( author ) + "}" + EOL;
57
62
    }
58
63
 
59
64
    /** {@inheritDoc} */
60
65
    protected String getDateBlock( String date )
61
66
    {
62
 
        return "\\pdate{" + date + "}";
 
67
        return "\\date{" + LatexSink.escaped( date ) + "}" + EOL;
63
68
    }
64
69
 
65
70
    /** {@inheritDoc} */
66
71
    protected String getHeadBlock()
67
72
    {
68
 
        return LatexSink.defaultSinkCommands()
69
 
            + "\\documentclass[a4paper]{article}"
70
 
            + LatexSink.defaultPreamble()
71
 
            + "\\begin{document}";
 
73
        return ((LatexSink) getSink()).defaultSinkCommands()
 
74
            + "\\documentclass[a4paper]{article}" + EOL + EOL
 
75
            + ((LatexSink) getSink()).defaultPreamble()
 
76
            + "\\begin{document}" + EOL + EOL;
72
77
    }
73
78
 
74
79
    /** {@inheritDoc} */
75
80
    protected String getBodyBlock()
76
81
    {
77
 
        return "\\end{document}";
 
82
        return "\\end{document}" + EOL;
78
83
    }
79
84
 
80
85
    /** {@inheritDoc} */
81
86
    protected String getSectionTitleBlock( String title )
82
87
    {
83
 
        // TODO: closing bracket?
84
 
        return title + "}";
 
88
        return title;
85
89
    }
86
90
 
87
91
    /** {@inheritDoc} */
88
92
    protected String getSection1Block( String title )
89
93
    {
90
 
        return "\\psectioni{" + title + "}";
 
94
        return EOL + "\\section{" + title + "}" + EOL;
91
95
    }
92
96
 
93
97
    /** {@inheritDoc} */
94
98
    protected String getSection2Block( String title )
95
99
    {
96
 
        return "\\psectionii{" + title + "}";
 
100
        return EOL + "\\subsection{" + title + "}" + EOL;
97
101
    }
98
102
 
99
103
    /** {@inheritDoc} */
100
104
    protected String getSection3Block( String title )
101
105
    {
102
 
        return "\\psectioniii{" + title + "}";
 
106
        return EOL + "\\subsubsection{" + title + "}" + EOL;
103
107
    }
104
108
 
105
109
    /** {@inheritDoc} */
106
110
    protected String getSection4Block( String title )
107
111
    {
108
 
        return "\\psectioniv{" + title + "}";
 
112
        return EOL + "\\paragraph{" + title + "}" + EOL;
109
113
    }
110
114
 
111
115
    /** {@inheritDoc} */
112
116
    protected String getSection5Block( String title )
113
117
    {
114
 
        return "\\psectionv{" + title + "}";
 
118
        return EOL + "\\subparagraph{" + title + "}" + EOL;
115
119
    }
116
120
 
117
121
    /** {@inheritDoc} */
118
122
    protected String getListBlock( String item )
119
123
    {
120
 
        return "\\begin{plist}\\item{} " + item + "\\end{plist}";
 
124
        return EOL + "\\begin{itemize}" + EOL + "\\item " + LatexSink.escaped( item ) + EOL + "\\end{itemize}" + EOL;
121
125
    }
122
126
 
123
127
    /** {@inheritDoc} */
124
128
    protected String getNumberedListBlock( String item )
125
129
    {
126
 
        return "\\begin{pnumberedlist}\\renewcommand{\\theenumi}{\\roman{enumi}}\\item{} " + item + "\\end{pnumberedlist}";
 
130
        return EOL + "\\begin{enumerate}" + EOL + "\\renewcommand{\\theenumi}{\\roman{enumi}}" + EOL + "\\item "
 
131
            + LatexSink.escaped( item ) + EOL + "\\end{enumerate}" + EOL;
127
132
    }
128
133
 
129
134
    /** {@inheritDoc} */
130
135
    protected String getDefinitionListBlock( String definum, String definition )
131
136
    {
132
 
        return "\\begin{pdefinitionlist}\\item[\\mbox{" + definum + "}] " + definition + "\\end{pdefinitionlist}";
 
137
        return EOL + "\\begin{description}" + EOL + "\\item[\\mbox{" + definum + "}] " + definition + EOL + "\\end{description}" + EOL;
133
138
    }
134
139
 
135
140
    /** {@inheritDoc} */
136
141
    protected String getFigureBlock( String source, String caption )
137
142
    {
138
 
        return "\\begin{pfigure}\\pfiguregraphics{" + source + "}\\pfigurecaption{" + caption + "}\\end{pfigure}";
 
143
        return EOL + "\\begin{figure}[htb]" + EOL + "\\begin{center}" + EOL + "\\includegraphics{" + source + "}" + EOL
 
144
            + "\\end{center}" + EOL + "\\caption{Figure\\_caption}" + EOL + "\\end{figure}" + EOL;
139
145
    }
140
146
 
141
147
    /** {@inheritDoc} */
142
148
    protected String getTableBlock( String cell, String caption )
143
149
    {
144
 
        // TODO: something's wrong
145
 
        return "\\begin{ptable}\\begin{ptablerows}{c}\\begin{pcell}{c}cell\\end{pcell}\\\\\\end{ptablerows}\\ptablecaption{" + caption + "}\\end{ptable}";
 
150
        return EOL + "\\begin{table}[htp]" + EOL + "\\begin{center}" + EOL + "\\begin{tabular}{c}" + EOL
 
151
            + "\\begin{tabular}[t]{c}cell\\end{tabular}\\\\" + EOL + "\\end{tabular}" + EOL
 
152
            + "\\end{center}" + EOL + "\\caption{Table\\_caption}" + EOL + "\\end{table}" + EOL;
146
153
    }
147
154
 
148
155
    /** {@inheritDoc} */
149
156
    protected String getParagraphBlock( String text )
150
157
    {
151
 
        return text;
 
158
        return  EOL + EOL + text + EOL;
152
159
    }
153
160
 
154
161
    /** {@inheritDoc} */
155
162
    protected String getVerbatimBlock( String text )
156
163
    {
157
 
        return "\\begin{pverbatimbox}\\begin{verbatim}" + text + "\\end{verbatim}\\end{pverbatimbox}";
 
164
        return EOL + "\\begin{small}" + EOL + "\\begin{Verbatim}[frame=single]" + EOL + text + EOL
 
165
            + "\\end{Verbatim}" + EOL + "\\end{small}" + EOL;
158
166
    }
159
167
 
160
168
    /** {@inheritDoc} */
161
169
    protected String getHorizontalRuleBlock()
162
170
    {
163
 
        return "\\phorizontalrule";
 
171
        return EOL + "\\begin{center}\\rule[0.5ex]{\\linewidth}{1pt}\\end{center}" + EOL;
164
172
    }
165
173
 
166
174
    /** {@inheritDoc} */
167
175
    protected String getPageBreakBlock()
168
176
    {
169
 
        return "\\newpage";
 
177
        return EOL + "\\newpage" + EOL;
170
178
    }
171
179
 
172
180
    /** {@inheritDoc} */
173
181
    protected String getAnchorBlock( String anchor )
174
182
    {
175
 
        return "\\panchor{" + anchor + "}";
 
183
        return "\\hypertarget{" + anchor + "}{" + anchor + "}";
176
184
    }
177
185
 
178
186
    /** {@inheritDoc} */
179
187
    protected String getLinkBlock( String link, String text )
180
188
    {
181
 
        return "\\plink{" + text + "}";
 
189
        return "\\hyperlink{" + link + "}{" + text + "}";
182
190
    }
183
191
 
184
192
    /** {@inheritDoc} */
185
193
    protected String getItalicBlock( String text )
186
194
    {
187
 
        return "\\pitalic{" + text + "}";
 
195
        return "\\textit{" + text + "}";
188
196
    }
189
197
 
190
198
    /** {@inheritDoc} */
191
199
    protected String getBoldBlock( String text )
192
200
    {
193
 
        return "\\pbold{" + text + "}";
 
201
        return "\\textbf{" + text + "}";
194
202
    }
195
203
 
196
204
    /** {@inheritDoc} */
197
205
    protected String getMonospacedBlock( String text )
198
206
    {
199
 
        return "\\pmonospaced{" + text + "}";
 
207
        return "\\texttt{\\small " + text + "}";
200
208
    }
201
209
 
202
210
    /** {@inheritDoc} */
203
211
    protected String getLineBreakBlock()
204
212
    {
205
 
        return "\\newline";
 
213
        return "\\newline" + EOL;
206
214
    }
207
215
 
208
216
    /** {@inheritDoc} */
215
223
    protected String getTextBlock( String text )
216
224
    {
217
225
        // TODO: how to retrieve those outside the sink?
218
 
        return "\\textasciitilde , =, \\symbol{45}, +, *, [, ], \\symbol{60}, \\symbol{62}, \\{,\\}, \\textbackslash";
 
226
        return "\\textasciitilde" + EOL + ",\\_=,\\_\\symbol{45},\\_+,\\_*,\\_[,\\_],\\_\\symbol{60},\\_\\symbol{62},\\_\\{,\\_\\},\\_\\textbackslash";
219
227
    }
220
228
 
221
229
    /** {@inheritDoc} */