/** * Generates HTML Output for a {@link DefinitionList}. */ private static String definitionListToHtml( DefinitionList dl){ if( dl == null ) { return "null"; } StringBuilder result = new StringBuilder(); result.append("<table class=\"DefinitionList\">\n" + "<tr><th class=\"DefinitionList\">DefinitionList</th></tr>\n"+ "<tr><td class=\"DefinitionList\">" ); if( dl.getDefinedTerm() != null ) { result.append( contentElementToHtml( dl.getDefinedTerm() )+ "\n"); } result.append("<ul>"); for( ContentElement ce: dl.getDefinitions() ) { result.append("<li>"+contentElementToHtml(ce)+"</li>" ); } result.append("</ul>\n"); result.append("</td></tr>\n" ); result.append("</table>\n"); return result.toString(); }
/** * Removes all empty Structures from a DefinitionList and all substructures. */ public static DefinitionList eliminateEmptyStructures( DefinitionList dl ){ ContentElement dt = dl.getDefinedTerm(); if( dt!=null && dt.empty() ) dl.setDefinedTerm( null ); for(int i=dl.nrOfDefinitions()-1; i>=0; i-- ){ ContentElement ce = dl.getDefinition(i); if( ce.empty() )dl.removeDefinition( ce ); } return dl; } }
private void setLists(Article article, ParsedPage page) { List<List<String>> lists = new ArrayList<List<String>>(); for (DefinitionList dl : page.getDefinitionLists()) { List<String> l = new ArrayList<String>(); for (ContentElement c : dl.getDefinitions()) { l.add(c.getText()); } lists.add(l); } for (NestedListContainer dl : page.getNestedLists()) { List<String> l = new ArrayList<String>(); for (NestedList nl : dl.getNestedLists()) { l.add(nl.getText()); } lists.add(l); } article.setLists(lists); }
DefinitionList result = new DefinitionList(content); result.setSrcSpan(new SrcSpan(sm.getSrcPos(s.getStart()), content .get(content.size() - 1).getSrcSpan().getEnd()));
private static void checkRange( SectionContent s ){ List<SrcSpan> eil = new ArrayList<SrcSpan>(); if( s.getTitleElement()!= null ){ checkRange( s.getTitleElement() ); eil.add( s.getTitleElement().getSrcSpan() ); } for( Paragraph p: s.getParagraphs() ){ checkRange( p ); eil.add( p.getSrcSpan() ); } for( DefinitionList dl: s.getDefinitionLists() ){ checkRange( dl ); eil.add( dl.getSrcSpan() ); } for( NestedListContainer nl: s.getNestedLists() ){ checkRange( nl ); eil.add( nl.getSrcSpan() ); } for( Table t: s.getTables() ){ checkRange( t ); eil.add( t.getSrcSpan() ); } s.setSrcSpan( getEvalInfo( s.getSrcSpan(), eil)); }
/** * Removes all empty Structures from a SectionContent and all substructures. */ public static SectionContent eliminateEmptyStructures( SectionContent sc ){ for( int i=sc.nrOfParagraphs()-1; i>=0; i-- ){ Paragraph p = sc.getParagraph(i); if( p.empty() ) sc.removeParagraph( p ); } for( int i=sc.nrOfDefinitionLists()-1; i>=0; i--){ DefinitionList dl = sc.getDefinitionList(i); eliminateEmptyStructures( dl ); if( dl.empty() ) sc.removeDefinitionList( dl ); } for( int i=sc.nrOfNestedLists()-1; i>=0; i--){ NestedListContainer nl = sc.getNestedList(i); eliminateEmptyStructures( nl ); if( nl.empty() ) sc.removeNestedList( nl ); } for( int i=sc.nrOfTables()-1; i>=0; i--){ Table t = sc.getTable(i); eliminateEmptyStructures( t ); if( t.empty() ) sc.removeTable( t ); } return sc; }