Index: src/com/ecyrd/jspwiki/parser/JSPWikiMarkupParser.java =================================================================== --- src/com/ecyrd/jspwiki/parser/JSPWikiMarkupParser.java (revision 644265) +++ src/com/ecyrd/jspwiki/parser/JSPWikiMarkupParser.java (working copy) @@ -119,6 +119,9 @@ private Element m_currentElement; + /** Keep track of duplicate header names */ + private Map m_titleSectionCounter = new HashMap(); + /** * This property defines the inline image pattern. It's current value * is jspwiki.translatorReader.inlinePattern @@ -1085,10 +1088,20 @@ { hd.m_titleText = title; title = MarkupParser.wikifyLink( title ); + hd.m_titleSection = m_engine.encodeName(title); + if (m_titleSectionCounter.containsKey(hd.m_titleSection)) { + Integer count = (Integer)m_titleSectionCounter.get(hd.m_titleSection); + count = new Integer(count.intValue() + 1); + m_titleSectionCounter.put(hd.m_titleSection, count); + hd.m_titleSection += "-"+count; + } + else { + m_titleSectionCounter.put(hd.m_titleSection, new Integer(1)); + } + hd.m_titleAnchor = "section-"+m_engine.encodeName(baseName)+ "-"+hd.m_titleSection; - hd.m_titleAnchor = hd.m_titleAnchor.replace( '%', '_' ); hd.m_titleAnchor = hd.m_titleAnchor.replace( '/', '_' ); return hd.m_titleAnchor;