Class LogoTextPostProcessor

java.lang.Object
org.ctan.markup.gfm.ext.LogoTextPostProcessor
All Implemented Interfaces:
org.commonmark.parser.PostProcessor

public final class LogoTextPostProcessor extends Object implements org.commonmark.parser.PostProcessor
Post-processor that replaces plain-text occurrences of logo names (e.g. LaTeX, TeX) with NamedEntityNodes so they receive the same styled HTML as the &LaTeX; / &TeX; entities.

Only Text nodes are affected. Nodes that are descendants of Code or FencedCodeBlock are left untouched, so text inside backtick spans and fenced code blocks is never altered.

Matching is case-sensitive and whole-token-aware: a match is only accepted when it is not immediately preceded or followed by an ASCII letter or digit, preventing partial matches inside words like "context" from matching "tex".

When multiple logo names could match at the same position the longest one wins (so LaTeX is preferred over TeX).

  • Constructor Details

    • LogoTextPostProcessor

      public LogoTextPostProcessor(Map<String,String> entityMap)
      Constructs a post-processor for the given entity map.

      The entity names are extracted from the map's key set and sorted longest-first so that longer names (e.g. LaTeX) are always tried before shorter ones that share a suffix (e.g. TeX). The HTML values are not needed here; resolution is handled at render time by NamedEntityNodeRenderer.

      Parameters:
      entityMap - the entity name → HTML map owned by NamedEntityExtension; only the keys are used
  • Method Details

    • process

      public org.commonmark.node.Node process(org.commonmark.node.Node document)
      Specified by:
      process in interface org.commonmark.parser.PostProcessor