/** * <p>escapeSGML</p> * * @param text The text to escape. * @param xmlMode xmlMode. * @return The escaped text. * @deprecated Use HtmlTools#escapeHTML(String,boolean). */ public static final String escapeSGML( String text, boolean xmlMode ) { return HtmlTools.escapeHTML( text, xmlMode ); }
private String chopExtension( String name ) { String anchor = name; int dot = anchor.lastIndexOf( "." ); if ( dot != -1 && dot != anchor.length() && anchor.charAt( dot + 1 ) != '/' ) { int hash = anchor.indexOf( "#", dot ); if ( hash != -1 ) { int dot2 = anchor.indexOf( ".", hash ); if ( dot2 != -1 ) { anchor = anchor.substring( 0, dot ) + "#" + HtmlTools.encodeId( anchor.substring( hash + 1, dot2 ) ); } else { anchor = anchor.substring( 0, dot ) + "#" + HtmlTools.encodeId( anchor.substring( hash + 1, anchor.length() ) ); } } else { anchor = anchor.substring( 0, dot ); } } return anchor; }
if ( DoxiaUtils.isExternalLink( name ) ) writeStartTag( BASIC_LINK_TAG, "external-destination", HtmlTools.escapeHTML( name ) ); writeStartTag( INLINE_TAG, "href.external" ); else if ( DoxiaUtils.isInternalLink( name ) ) if ( !DoxiaUtils.isValidId( anchor ) ) anchor = DoxiaUtils.encodeId( anchor, true ); writeStartTag( BASIC_LINK_TAG, "internal-destination", HtmlTools.escapeHTML( anchor ) ); writeStartTag( INLINE_TAG, "href.internal" ); writeStartTag( BASIC_LINK_TAG, "internal-destination", HtmlTools.escapeHTML( anchor ) ); writeStartTag( INLINE_TAG, "href.internal" );
/** * {@inheritDoc} * @see SimplifiedDocbookMarkup#ULINK_TAG * @see SimplifiedDocbookMarkup#URL_ATTRIBUTE * @see SimplifiedDocbookMarkup#LINK_TAG * @see SimplifiedDocbookMarkup#LINKEND_ATTRIBUTE */ public void link( String name ) { if ( name == null ) { throw new NullPointerException( "Link name cannot be null!" ); } if ( DoxiaUtils.isInternalLink( name ) ) { String linkend = name.substring( 1 ); MutableAttributeSet att = new SimpleAttributeSet(); att.addAttribute( SimplifiedDocbookMarkup.LINKEND_ATTRIBUTE, HtmlTools.escapeHTML( linkend ) ); writeStartTag( SimplifiedDocbookMarkup.LINK_TAG, att ); } else { externalLinkFlag = true; MutableAttributeSet att = new SimpleAttributeSet(); att.addAttribute( SimplifiedDocbookMarkup.URL_ATTRIBUTE, HtmlTools.escapeHTML( name, true ) ); writeStartTag( SimplifiedDocbookMarkup.ULINK_TAG, att ); } }
@Override public synchronized void parse( Reader source, Sink sink, String reference ) throws ParseException { ByLineSource src = new ByLineReaderSource( source, reference ); try { List<Block> blocks = parse( src ); sink.head(); sink.head_(); sink.body(); for ( Block block : blocks ) { block.traverse( sink ); } sink.body_(); } catch ( Exception e ) { // TODO handle column number throw new ParseException( e, src.getName(), src.getLineNumber(), -1 ); } finally { setSecondParsing( false ); init(); } }
/** {@inheritDoc} */ public Block visit( String line, ByLineSource source ) throws ParseException { StringBuilder text = new StringBuilder(); while ( ( line = source.getNextLine() ) != null ) { if ( line.startsWith( "{code}" ) || line.startsWith( "{noformat}" ) ) { break; } // TODO text.append( line ).append( LS ); } return new VerbatimBlock( text.toString() ); } }
String name = source.getName(); if ( name != null )
/** * Forward to HtmlTools.escapeHTML( text ). * * @param text the String to escape, may be null * @return the text escaped, "" if null String input * @see org.apache.maven.doxia.util.HtmlTools#escapeHTML(String) */ protected static String escapeHTML( String text ) { return HtmlTools.escapeHTML( text ); } }
/** * Write subsection index for the book index. * * @param sink the XdocSink. * @param sectionIndex the section IndexEntry. * @param subsectionIndex the subsection IndexEntry. */ private void writeSubsectionIndexForBookIndex( XdocSink sink, IndexEntry sectionIndex, IndexEntry subsectionIndex ) { sink.listItem(); sink.link( sectionIndex.getId() + ".html#" + HtmlTools.encodeId( subsectionIndex.getId() ) ); sink.text( subsectionIndex.getTitle() ); sink.link_(); sink.listItem_(); }
/** * Forward to HtmlTools.escapeHTML( text ). * * @param text the String to escape, may be null * @return the text escaped, "" if null String input * @see org.apache.maven.doxia.util.HtmlTools#escapeHTML(String) */ protected static String escapeHTML( String text ) { return HtmlTools.escapeHTML( text ); } }
/** {@inheritDoc} */ public void anchor( String name, SinkEventAttributes attributes ) { if ( name == null ) { throw new NullPointerException( "Anchor name cannot be null!" ); } String anchor = name; if ( !DoxiaUtils.isValidId( anchor ) ) { anchor = DoxiaUtils.encodeId( name, true ); String msg = "Modified invalid anchor name: '" + name + "' to '" + anchor + "'"; logMessage( "modifiedLink", msg ); } anchor = "#" + name; writeStartTag( INLINE_TAG, "id", anchor ); }
/** * Write SGML escaped text to output, not preserving white space. * * @param text The text to write. */ protected void content( String text ) { if ( !skip ) { out.write( HtmlTools.escapeHTML( text, true ) ); } }
/** * {@inheritDoc} */ public void anchor( String name, SinkEventAttributes attributes ) { if ( name == null ) { throw new NullPointerException( "Anchor name cannot be null!" ); } String anchor = name; if ( !DoxiaUtils.isValidId( anchor ) ) { anchor = DoxiaUtils.encodeId( name, true ); String msg = "Modified invalid anchor name: '" + name + "' to '" + anchor + "'"; logMessage( "modifiedLink", msg ); } anchor = "#" + anchor; if ( docName != null ) { anchor = docName + anchor; } writeStartTag( INLINE_TAG, "id", anchor ); }
/** * Write SGML escaped text to output, preserving white space. * * @param text The text to write. */ protected void verbatimContent( String text ) { if ( !skip ) { out.write( HtmlTools.escapeHTML( text, true ) ); } }
/** {@inheritDoc} */ @Override public void author_() { if ( getTextBuffer().length() > 0 ) { String text = HtmlTools.escapeHTML( getTextBuffer().toString() ); text = StringUtils.replace( text, "&#", "&#" ); authors.add( text.trim() ); } resetTextBuffer(); }
/** * {@inheritDoc} * @see XdocMarkup#AUTHOR_TAG */ public void author_() { if ( getTextBuffer().length() > 0 ) { writeStartTag( AUTHOR_TAG ); String text = HtmlTools.escapeHTML( getTextBuffer().toString() ); // hack: un-escape numerical entities that have been escaped above // note that numerical entities should really be written as one unicode character in the first place text = StringUtils.replace( text, "&#", "&#" ); write( text ); writeEndTag( AUTHOR_TAG ); resetTextBuffer(); } }
/** {@inheritDoc} */ public void figureGraphics( String name ) { String format = FileUtils.extension( name ).toUpperCase( Locale.ENGLISH ); writeStartTag( SimplifiedDocbookMarkup.IMAGEOBJECT_TAG ); MutableAttributeSet att = new SimpleAttributeSet(); att.addAttribute( SimplifiedDocbookMarkup.FORMAT_ATTRIBUTE, format ); att.addAttribute( SimplifiedDocbookMarkup.FILEREF_ATTRIBUTE, HtmlTools.escapeHTML( name, true ) ); writeSimpleTag( SimplifiedDocbookMarkup.IMAGEDATA_TAG, att ); writeEndTag( SimplifiedDocbookMarkup.IMAGEOBJECT_TAG ); }
/** * Adds a link with an optional target. * * @param name the link name. * @param target the link target, may be null. */ public void link( String name, String target ) { if ( isHeadFlag() ) { return; } MutableAttributeSet att = new SinkEventAttributeSet(); att.addAttribute( Attribute.HREF, HtmlTools.escapeHTML( name ) ); if ( target != null ) { att.addAttribute( Attribute.TARGET, target ); } writeStartTag( A, att ); }