Enum MarkdownSink.ElementContext

java.lang.Object
java.lang.Enum<MarkdownSink.ElementContext>
org.apache.maven.doxia.module.markdown.MarkdownSink.ElementContext
All Implemented Interfaces:
Serializable, Comparable<MarkdownSink.ElementContext>
Enclosing class:
MarkdownSink

static enum MarkdownSink.ElementContext extends Enum<MarkdownSink.ElementContext>
Most important contextual metadata (of elements). This contains information about necessary escaping rules, potential prefixes and newlines
  • Enum Constant Details

  • Field Details

    • type

      true if block element, otherwise false for inline elements
    • escapeFunction

      final MarkdownSink.TextEscapeFunction escapeFunction
      The function to call to escape the given text. The function is supposed to return the escaped text or return just the given text if no escaping is necessary in this context
    • requiresBuffering

      final boolean requiresBuffering
      if true requires buffering any text appearing inside this context
    • prefix

      final String prefix
      prefix to be used for each line of (nested) block elements inside the current container context (only not empty for type being MarkdownSink.ElementContext.Type.CONTAINER_BLOCK)
    • requiresSurroundingByBlankLines

      final boolean requiresSurroundingByBlankLines
      Only relevant for block element, if set to true the element requires to be surrounded by blank lines.
    • allowsMarkupLinebreaks

      final boolean allowsMarkupLinebreaks
      If markup linebreaks (i.e. insignificant linebreaks in the source) are allowed in this context. This is relevant for markdown as in some contexts (e.g. list items) linebreaks are always significant (while for HTML they wouldn't be)
  • Constructor Details

  • Method Details

    • values

      public static MarkdownSink.ElementContext[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static MarkdownSink.ElementContext valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • escape

      String escape(LastTwoLinesAwareWriter writer, String text)
      Must be called for each inline text to be emitted directly within this context (not relevant for nested context)
      Parameters:
      text -
      Returns:
      the escaped text (may be same as text when no escaping is necessary)
    • isBlock

      boolean isBlock()
      Returns:
      true for all block types, false otherwise
    • isHtml

      boolean isHtml()
      Returns:
      true if only HTML is allowed in this context
    • isContainer

      boolean isContainer()
      Returns:
      true for all containers (allowing block elements as children), false otherwise
    • isAllowsMarkupLinebreaks

      public boolean isAllowsMarkupLinebreaks()
    • escapeMarkdown

      private String escapeMarkdown(LastTwoLinesAwareWriter writer, String text)
      First use XML escaping (leveraging the predefined entities, for browsers) afterwards escape special characters in a text with a leading backslash (for markdown parsers)
      \, `, *, _, {, }, [, ], (, ), #, +, -, ., !
      
      Parameters:
      text - the string to escape, may be null
      Returns:
      the text escaped, "" if null String input
      See Also:
    • isAfterOnlyLeadingDigits

      private static boolean isAfterOnlyLeadingDigits(StringBuilder buffer, LastTwoLinesAwareWriter writer)
      A . only needs escaping when it would turn leading digits into the marker of an ordered list item, i.e. when nothing but whitespace and digits precede it on the line. Elsewhere (as in version numbers such as 1.6) it is an ordinary character.
    • isInBlankLine

      private static boolean isInBlankLine(StringBuilder buffer, LastTwoLinesAwareWriter writer)
    • escapeMarkdown

      private static String escapeMarkdown(char c)
    • escapeHtml

      private String escapeHtml(LastTwoLinesAwareWriter writer, String text)
    • escapeHtmlForMarkdown

      private static String escapeHtmlForMarkdown(String text)
      Escapes only those characters which would otherwise be interpreted as raw HTML inside a Markdown document. Unlike HtmlTools.escapeHTML(String, boolean) this leaves " and ' alone: Markdown is not XML, both are ordinary characters there, and turning them into &quot;/&apos; only makes the source unreadable.
      Parameters:
      text - the string to escape, may be null
      Returns:
      the escaped text, "" if null String input
    • escapeForTableCell

      private String escapeForTableCell(LastTwoLinesAwareWriter writer, String text)
      Escapes the pipe character according to GFM Table Extension in addition to the regular markdown escaping.
      Parameters:
      text -
      Returns:
      the escaped text