Factory 1.1.0

WARNING

This is documentation for legacy versions. For the most current version click here.

SpannableFactory is used to create Span implementations.

SpannableConfiguration.builder(context)
        .factory(SpannableFactory)
        .build();

Markwon provides default SpannableFactoryDef implementation that is used by default.

Spans:

  • strongEmphasis
  • emphasis
  • blockQuote
  • code
  • orderedListItem
  • bulletListItem
  • thematicBreak
  • heading
  • strikethrough
  • taskListItem
  • tableRow
  • paragraph 1.1.1
  • image
  • link
  • superScript (HTML content only)
  • subScript (HTML content only)
  • underline (HTML content only)

TIP

SpannableFactory can be used to ignore some kinds of text markup. If, for example, you do not wish to apply emphasis styling to your final result, just return null from emphasis factory method:

@Nullable
@Override
public Object emphasis() {
    return null;
}

TIP

All factory methods in SpannableFactory return an Object, but you can actually return an array of Objects if you wish to apply multiple Spans to a single styling node. For example, let's make all emphasis also red:

@Nullable
@Override
public Object emphasis() {
    return new Object[] {
            super.emphasis(),
            new ForegroundColorSpan(Color.RED)
    };
}
Last Updated: 6/17/2019, 2:08:33 PM