Class Emitter

java.lang.Object
com.github.rjeschke.txtmark.Emitter

class Emitter extends Object
Emitter class responsible for generating HTML output.
  • Field Details

    • linkRefs

      private final HashMap<String,LinkRef> linkRefs
      Link references.
    • config

      private final Configuration config
      The configuration.
    • useExtensions

      public boolean useExtensions
      Extension flag.
  • Constructor Details

  • Method Details

    • addLinkRef

      public void addLinkRef(String key, LinkRef linkRef)
      Adds a LinkRef to this set of LinkRefs.
      Parameters:
      key - The key/id.
      linkRef - The LinkRef.
    • emit

      public void emit(StringBuilder out, Block root)
      Transforms the given block recursively into HTML.
      Parameters:
      out - The StringBuilder to write to.
      root - The Block to process.
    • emitLines

      private void emitLines(StringBuilder out, Block block)
      Transforms lines into HTML.
      Parameters:
      out - The StringBuilder to write to.
      block - The Block to process.
    • findToken

      private int findToken(String in, int start, MarkToken token)
      Finds the position of the given Token in the given String.
      Parameters:
      in - The String to search on.
      start - The starting character position.
      token - The token to find.
      Returns:
      The position of the token or -1 if none could be found.
    • checkLink

      private int checkLink(StringBuilder out, String in, int start, MarkToken token)
      Checks if there is a valid markdown link definition.
      Parameters:
      out - The StringBuilder containing the generated output.
      in - Input String.
      start - Starting position.
      token - Either LINK or IMAGE.
      Returns:
      The new position or -1 if there is no valid markdown link.
    • checkHtml

      private int checkHtml(StringBuilder out, String in, int start)
      Check if there is a valid HTML tag here. This method also transforms auto links and mailto auto links.
      Parameters:
      out - The StringBuilder to write to.
      in - Input String.
      start - Starting position.
      Returns:
      The new position or -1 if nothing valid has been found.
    • checkEntity

      private static int checkEntity(StringBuilder out, String in, int start)
      Check if this is a valid XML/HTML entity.
      Parameters:
      out - The StringBuilder to write to.
      in - Input String.
      start - Starting position
      Returns:
      The new position or -1 if this entity in invalid.
    • recursiveEmitLine

      private int recursiveEmitLine(StringBuilder out, String in, int start, MarkToken token)
      Recursively scans through the given line, taking care of any markdown stuff.
      Parameters:
      out - The StringBuilder to write to.
      in - Input String.
      start - Start position.
      token - The matching Token (for e.g. '*')
      Returns:
      The position of the matching Token or -1 if token was NONE or no Token could be found.
    • whitespaceToSpace

      private static char whitespaceToSpace(char c)
      Turns every whitespace character into a space character.
      Parameters:
      c - Character to check
      Returns:
      32 is c was a whitespace, c otherwise
    • getToken

      private MarkToken getToken(String in, int pos)
      Check if there is any markdown Token.
      Parameters:
      in - Input String.
      pos - Starting position.
      Returns:
      The Token.
    • emitMarkedLines

      private void emitMarkedLines(StringBuilder out, Line lines)
      Writes a set of markdown lines into the StringBuilder.
      Parameters:
      out - The StringBuilder to write to.
      lines - The lines to write.
    • emitRawLines

      private void emitRawLines(StringBuilder out, Line lines)
      Writes a set of raw lines into the StringBuilder.
      Parameters:
      out - The StringBuilder to write to.
      lines - The lines to write.
    • emitCodeLines

      private void emitCodeLines(StringBuilder out, Line lines, String meta, boolean removeIndent)
      Writes a code block into the StringBuilder.
      Parameters:
      out - The StringBuilder to write to.
      lines - The lines to write.
      meta - Meta information.