diff --git a/portal-impl/src/com/liferay/portlet/wiki/engines/antlrwiki/translator/XhtmlTranslator.java b/portal-impl/src/com/liferay/portlet/wiki/engines/antlrwiki/translator/XhtmlTranslator.java
index 8e7961e700f07977add934755d5a8de0a55cf3fe..8d4d23a70f23b91d31b7c7e349ecfa2960c81dd3 100644
--- a/portal-impl/src/com/liferay/portlet/wiki/engines/antlrwiki/translator/XhtmlTranslator.java
+++ b/portal-impl/src/com/liferay/portlet/wiki/engines/antlrwiki/translator/XhtmlTranslator.java
@@ -187,16 +187,14 @@ public class XhtmlTranslator extends XhtmlTranslationVisitor {
 	protected void appendTableOfContents(
 		TreeNode<HeadingNode> tableOfContents, int depth) {
 
-		append("<ol>");
-
 		List<TreeNode<HeadingNode>> treeNodes = tableOfContents.getChildNodes();
 
-		if (treeNodes == null) {
-			append("</ol>");
-
+		if ((treeNodes == null) || treeNodes.isEmpty()) {
 			return;
 		}
 
+		append("<ol>");
+
 		for (TreeNode<HeadingNode> treeNode : treeNodes) {
 			append("<li class=\"toc-level-");
 			append(depth);
