in src/main/java/com/atlassian/uwc/converters/swiki/HTMLListConverter.java [65:153]
public String convertHTMLLists(String prefix, String input)
{
StringBuffer sb = new StringBuffer();
boolean found=false;
int begin=-1, end=-1;
int itemBegin=input.indexOf(HtmlItemBegin);
String output=input;
String append="";
int olBegin=input.indexOf(HtmlOrderListBegin);
int olEnd=input.lastIndexOf(HtmlOrderListEnd);
int ulBegin=input.indexOf(HtmlUnOrderListBegin);
int ulEnd=input.lastIndexOf(HtmlUnOrderListEnd);
if (olBegin >= 0 && olEnd >=0)
{
begin=olBegin;
end=olEnd;
append = ConfluenceNumberList;
found=true;
}
if (ulBegin >= 0 && ulEnd >= 0)
{
if (begin < 0 || (ulBegin < begin && ulEnd > end))
{
begin=ulBegin;
end=ulEnd;
append=ConfluenceBulletList;
}
found=true;
}
//convert the item first if it appears first.
if (itemBegin >= 0 && ( begin < 0 || itemBegin < begin))
{
String temp=input.substring(itemBegin + HtmlTagBeginLength);
int itemEnd=temp.indexOf(HtmlItemEnd);
String otherTag=this.getFirstTag(temp, new String [] {
HtmlOrderListBegin, HtmlUnOrderListBegin, HtmlItemBegin});
int otherItemIndex=-1;
if (otherTag != null)
otherItemIndex=itemBegin + HtmlTagBeginLength + temp.indexOf(otherTag);
//item missing closing tag
if (itemEnd < 0 && otherItemIndex >= 0)
output=appendEndOfLine(input.substring(0, itemBegin )) +
appendEndOfLine(prefix + " " + input.substring(itemBegin + HtmlTagBeginLength, otherItemIndex)) +
appendEndOfLine(input.substring(otherItemIndex));
//item closing tag after other tags. Need to check if item tag has nested
//tag like <ol> or <ul>
else if (otherItemIndex >= 0 && itemEnd > otherItemIndex)
{
temp=getHTMLList(temp);
if (temp == null)
output=appendEndOfLine(input.substring(0, itemBegin )) +
appendEndOfLine(prefix + " " + input.substring(itemBegin + HtmlTagBeginLength, otherItemIndex)) +
appendEndOfLine(input.substring(otherItemIndex));
//with valid ol and ul inside
else
{
output=appendEndOfLine(input.substring(0, itemBegin + HtmlTagBeginLength)) +
appendEndOfLine(convertHTMLLists(prefix, temp)) +
appendEndOfLine(input.substring(itemBegin + HtmlTagBeginLength + temp.length()));
}
}
//item missing closing tag, but no other begin tag after either
else if (itemEnd < 0 && otherItemIndex < 0)
output=appendEndOfLine(input.substring(0, itemBegin )) +
appendEndOfLine(prefix + " " + input.substring(itemBegin + HtmlTagBeginLength));
//item with closing tag -- normal case
else
output=appendEndOfLine(input.substring(0, itemBegin )) +
appendEndOfLine(prefix + " " + input.substring(itemBegin + HtmlTagBeginLength, itemBegin + HtmlTagBeginLength + itemEnd)) +
appendEndOfLine(input.substring(itemBegin + HtmlTagBeginLength + itemEnd + HtmlTagEndLength));
return output=convertHTMLLists(prefix, output);
}
//now convert the order or non-order list
if (found)
{
output = appendEndOfLine(input.substring(0, begin)) +
appendEndOfLine(convertHTMLLists (prefix+append, input.substring(begin + HtmlTagBeginLength, end))) +
appendEndOfLine(convertHTMLLists (prefix,input.substring(end + HtmlTagEndLength)));
}
return output;
}