Interface LinkProcessor

All Known Implementing Classes:
CoreLinkProcessor, FootnoteLinkProcessor

public interface LinkProcessor
An interface to decide how links/images are handled.

Implementations need to be registered with a parser via Parser.Builder.linkProcessor(org.commonmark.parser.beta.LinkProcessor). Then, when inline parsing is run, each parsed link/image is passed to the processor. This includes links like these:


 [text](destination)
 [text]
 [text][]
 [text][label]
 
And images:

 ![text](destination)
 ![text]
 ![text][]
 ![text][label]
 
See LinkInfo for accessing various parts of the parsed link/image.

The processor can then inspect the link/image and decide what to do with it by returning the appropriate LinkResult. If it returns LinkResult.none(), the next registered processor is tried. If none of them apply, the link is handled as it normally would.

  • Method Details

    • process

      LinkResult process(LinkInfo linkInfo, Scanner scanner, InlineParserContext context)
      Parameters:
      linkInfo - information about the parsed link/image
      scanner - the scanner at the current position after the parsed link/image
      context - context for inline parsing
      Returns:
      what to do with the link/image, e.g. do nothing (try the next processor), wrap the text in a node, or replace the link/image with a node