Browse files

Fixing tables

  • Loading branch information...
1 parent f66ffc0 commit 822c0f95698d5a9b45e8473342c4bef898c37a2a @andrelrs andrelrs committed Apr 26, 2012
View
8 src/main/java/br/com/caelum/tubaina/parser/latex/TableTag.java
@@ -16,19 +16,19 @@ public TableTag(boolean noborder, int columns) {
public String parse(String text, String title) {
if (this.columns <= 0)
throw new TubainaException("There are no columns inside table " + title);
- String tag = "\\begin{table}[!h]\n\\caption{" + title + "}\n\\begin{center}\n";
+ String tag = "\\begin{table}[!h]\n\\begin{center}\n";
if (!noborder)
tag += "\\rowcolors[]{1}{gray!30}{gray!15}\n";
- tag += "\\begin{tabularx}{";
+ tag += "\\begin{tabular}{";
for (int i = 0; i < columns; i++)
- tag += "X";
+ tag += "c";
tag += "}\n";
if (!noborder)
tag += "\\hline\n";
tag += text;
if (!noborder)
tag += "\n\\hline";
- tag += "\n\\end{tabularx}\n\\end{center}\n\\end{table}";
+ tag += "\n\\caption{" + title + "}\n\\end{tabular}\n\\end{center}\n\\end{table}";
return tag;
}
View
24 src/test/java/br/com/caelum/tubaina/parser/latex/TableTagTest.java
@@ -14,14 +14,14 @@ public void testTable() {
String result = tag.parse("texto da tabela", "");
Assert.assertEquals(
"\\begin{table}[!h]\n" +
- "\\caption{}\n" +
"\\begin{center}\n" +
"\\rowcolors[]{1}{gray!30}{gray!15}\n" +
- "\\begin{tabularx}{XX}\n" +
+ "\\begin{tabular}{cc}\n" +
"\\hline\n" +
"texto da tabela\n" +
"\\hline\n" +
- "\\end{tabularx}\n\\end{center}\n\\end{table}", result);
+ "\\caption{}\n" +
+ "\\end{tabular}\n\\end{center}\n\\end{table}", result);
}
@Test
@@ -30,14 +30,14 @@ public void testTableWithTitle() {
String result = tag.parse("texto da tabela", "titulo");
Assert.assertEquals(
"\\begin{table}[!h]\n" +
- "\\caption{titulo}\n" +
"\\begin{center}\n" +
"\\rowcolors[]{1}{gray!30}{gray!15}\n" +
- "\\begin{tabularx}{XX}\n" +
+ "\\begin{tabular}{cc}\n" +
"\\hline\n" +
"texto da tabela\n" +
"\\hline\n" +
- "\\end{tabularx}\n\\end{center}\n\\end{table}", result);
+ "\\caption{titulo}\n" +
+ "\\end{tabular}\n\\end{center}\n\\end{table}", result);
}
@Test
@@ -46,11 +46,11 @@ public void testTableWithoutBorder() {
String result = tag.parse("texto da tabela", "");
Assert.assertEquals(
"\\begin{table}[!h]\n" +
- "\\caption{}\n" +
"\\begin{center}\n" +
- "\\begin{tabularx}{XX}\n" +
+ "\\begin{tabular}{cc}\n" +
"texto da tabela\n" +
- "\\end{tabularx}\n\\end{center}\n\\end{table}", result);
+ "\\caption{}\n" +
+ "\\end{tabular}\n\\end{center}\n\\end{table}", result);
}
@Test
@@ -59,11 +59,11 @@ public void testTableWithTitleAndWithoutBorder() {
String result = tag.parse("texto da tabela", "titulo");
Assert.assertEquals(
"\\begin{table}[!h]\n" +
- "\\caption{titulo}\n" +
"\\begin{center}\n" +
- "\\begin{tabularx}{XX}\n" +
+ "\\begin{tabular}{cc}\n" +
"texto da tabela\n" +
- "\\end{tabularx}\n\\end{center}\n\\end{table}", result);
+ "\\caption{titulo}\n" +
+ "\\end{tabular}\n\\end{center}\n\\end{table}", result);
}
@Test

0 comments on commit 822c0f9

Please sign in to comment.