private void emitDelimiter(int newlineCount) throws IOException { if (getLastChar() != 0) { int delimiterSize = newlineCount - getTrailingNewlineCount(); for (int x = delimiterSize; x > 0; --x) { emitContent('\n'); } } }
private void maybeInsertAdjacentWhitespace(int c) throws IOException { if (adjacentSeparatorRequired) { if (!isSeparator(c)) { char lastChar = getLastChar(); if (lastChar != 0 && !isSeparator(lastChar)) { writer.write(' '); } } adjacentSeparatorRequired = false; } }
@Override public void charactersUnescaped(String literal) { characters(literal); }
void emitEscapedContent(int c) throws IOException { if (c == '\\') { super.emitContent("\"); } else { if ((c == '#' && getLastChar() == '&') || (c == '{' || c == '\\' || c == '[' || c == ']')) { super.emitContent('\\'); } super.emitContent(c); } }
@Override public void beginSpan(SpanType type, Attributes attributes) { assertOpenBlock(); Block block = computeSpan(type, attributes); try { block.open(); } catch (IOException e) { throw new RuntimeException(e); } }
@Override protected boolean isSeparator(int i) { return !isSpanMarkup((char) i) && super.isSeparator(i); }
@Override public void endSpan() { closeCurrentBlock(); }
@Override public void flush() { while (currentBlock != null) { endBlock(); } }
@Override public void beginHeading(int level, Attributes attributes) { Block block = computeHeading(level, attributes); try { block.open(); } catch (IOException e) { throw new RuntimeException(e); } }
protected void assertOpenBlock() { if (currentBlock == null) { Block block = createImplicitParagraphBlock(); try { block.open(); } catch (IOException e) { throw new RuntimeException(e); } } }
@Override public void beginBlock(BlockType type, Attributes attributes) { try { if (currentBlock != null && currentBlock.isImplicitBlock()) { currentBlock.close(); currentBlock = null; } Block block = computeBlock(type, attributes); block.open(); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public void write(int c) throws IOException { hasContent = true; emitContent(normalizeWhitespace(c)); }
@Override public void endBlock() { closeCurrentBlock(); }
@Override public void endHeading() { endBlock(); }
@Override public void close() throws IOException { if (hasContent) { emitContent("\n\n"); //$NON-NLS-1$ } super.close(); }
@Override public void close() throws IOException { emitContent(suffix); super.close(); } }
@Override public void write(String s) throws IOException { hasContent = true; emitContent(normalizeWhitespace(s)); }
@Override public void entityReference(String entity) { assertOpenBlock(); String literal = entityToLiteral.get(entity); if (literal == null) { literal = EntityReferences.instance().equivalentString(entity); if (literal == null) { literal = "&" + entity + ";"; //$NON-NLS-1$//$NON-NLS-2$ } } try { super.emitContent(literal); } catch (IOException e) { throw new RuntimeException(e); } }