Class Formatter.MainNodeFormatter.SubNodeFormatter

    • Method Detail

      • nodesOfType

        @NotNull
        public final @NotNull java.lang.Iterable<? extends Node> nodesOfType​(@NotNull
                                                                             @NotNull java.util.Collection<java.lang.Class<?>> classes)
        Specified by:
        nodesOfType in interface NodeFormatterContext
      • reversedNodesOfType

        @NotNull
        public final @NotNull java.lang.Iterable<? extends Node> reversedNodesOfType​(@NotNull
                                                                                     @NotNull java.util.Collection<java.lang.Class<?>> classes)
        Specified by:
        reversedNodesOfType in interface NodeFormatterContext
      • getTrackedSequence

        @NotNull
        public @NotNull BasedSequence getTrackedSequence()
        Description copied from interface: NodeFormatterContext
        NOTE: parser can only use a contiguous sequence, not segmented. Therefore, the AST offsets and base sequence from AST nodes has always an index into sequence equal to the offset. This sequence is set to not BasedSequence.NULL when the format sequence used for tracked offsets is not contiguous and TrackedOffset.offset is an offset from this sequence and need to be converted to index into this sequence to be used as an offset into AST sequence for offset conversion
        Specified by:
        getTrackedSequence in interface NodeFormatterContext
        Returns:
        original sequence used for tracked offsets.
      • render

        public void render​(@NotNull
                           @NotNull Node node)
        Description copied from interface: NodeFormatterContext
        Render the specified node and its children using the configured renderers. This should be used to render child nodes; be careful not to pass the node that is being rendered, that would result in an endless loop.
        Specified by:
        render in interface LinkResolverContext
        Specified by:
        render in interface NodeFormatterContext
        Parameters:
        node - the node to render
      • getSubContext

        @NotNull
        public @NotNull NodeFormatterContext getSubContext()
        Description copied from interface: NodeContext
        Creates a child rendering context that can be used to collect rendered html text. The child context inherits everything but the HtmlRenderer and doNotRenderLinksNesting from the parent.
        Specified by:
        getSubContext in interface NodeContext<Node,​NodeFormatterContext>
        Returns:
        a new rendering context with a given appendable for its output
      • getSubContext

        @NotNull
        public @NotNull NodeFormatterContext getSubContext​(@Nullable
                                                           @Nullable DataHolder options)
        Description copied from interface: NodeContext
        Creates a child rendering context that can be used to collect rendered html text. The child context inherits everything but the HtmlRenderer and doNotRenderLinksNesting from the parent.
        Specified by:
        getSubContext in interface NodeContext<Node,​NodeFormatterContext>
        Parameters:
        options - options to use for the context (only options which do not affect the context construction will be used)
        Returns:
        a new rendering context with a given appendable for its output
      • getSubContext

        @NotNull
        public @NotNull NodeFormatterContext getSubContext​(@Nullable
                                                           @Nullable DataHolder options,
                                                           @NotNull
                                                           @NotNull ISequenceBuilder<?,​?> builder)
        Description copied from interface: NodeContext
        Creates a child rendering context that can be used to collect rendered html text. The child context inherits everything but the HtmlRenderer and doNotRenderLinksNesting from the parent.
        Specified by:
        getSubContext in interface NodeContext<Node,​NodeFormatterContext>
        Parameters:
        options - options to use for the context (only options which do not affect the context construction will be used)
        builder - sequence builder to user for appended text for tracking original base offsets
        Returns:
        a new rendering context with a given appendable for its output
      • transformNonTranslating

        @NotNull
        public @NotNull java.lang.CharSequence transformNonTranslating​(java.lang.CharSequence prefix,
                                                                       @NotNull
                                                                       @NotNull java.lang.CharSequence nonTranslatingText,
                                                                       java.lang.CharSequence suffix,
                                                                       java.lang.CharSequence suffix2)
        Description copied from interface: TranslationContext
        Transform non-translating text

        During RenderPurpose.TRANSLATION_SPANS this converts text to non-translating placeholder based on ordinal id During RenderPurpose.TRANSLATED_SPANS this returns the non-translating placeholder based on ordinal id During RenderPurpose.TRANSLATED this returns the original non-translating text for the nonTranslatingText (placeholder)

        Specified by:
        transformNonTranslating in interface TranslationContext
        Parameters:
        prefix - prefix to use on non-translating placeholder so it is interpreted as a proper element during parsing
        nonTranslatingText - non-rendering text of the node (content will depend on translation phase)
        suffix - suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing
        suffix2 - suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing
        Returns:
        text to be used in rendering for this phase
      • transformTranslating

        @NotNull
        public @NotNull java.lang.CharSequence transformTranslating​(java.lang.CharSequence prefix,
                                                                    @NotNull
                                                                    @NotNull java.lang.CharSequence translatingText,
                                                                    java.lang.CharSequence suffix,
                                                                    java.lang.CharSequence suffix2)
        Description copied from interface: TranslationContext
        Transform translating text but which is contextually isolated from the text block in which it is located ie. link reference or image reference

        During RenderPurpose.TRANSLATION_SPANS this converts text to non-translating placeholder based on ordinal id and adds it to translation snippets During RenderPurpose.TRANSLATED_SPANS this returns the non-translating placeholder based on ordinal id During RenderPurpose.TRANSLATED this returns the translated text for the translatingText (placeholder)

        Specified by:
        transformTranslating in interface TranslationContext
        Parameters:
        prefix - prefix to use on non-translating placeholder so it is interpreted as a proper element during parsing
        translatingText - translating but isolated text of the node (content will depend on translation phase)
        suffix - suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing
        suffix2 - suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing
        Returns:
        text to be used in rendering for this phase
      • transformAnchorRef

        @NotNull
        public @NotNull java.lang.CharSequence transformAnchorRef​(@NotNull
                                                                  @NotNull java.lang.CharSequence pageRef,
                                                                  @NotNull
                                                                  @NotNull java.lang.CharSequence anchorRef)
        Description copied from interface: TranslationContext
        During RenderPurpose.TRANSLATION_SPANS this converts anchorRef to ordinal placeholder id During RenderPurpose.TRANSLATED_SPANS this returns the ordinal placeholder During RenderPurpose.TRANSLATED this returns new anchorRef for the AnchorRefTarget original was referring to
        Specified by:
        transformAnchorRef in interface TranslationContext
        Parameters:
        pageRef - url part without the anchor ref to resolve reference
        anchorRef - anchor ref
        Returns:
        anchorRef for the phase to be used for rendering
      • encodeUrl

        @NotNull
        public @NotNull java.lang.String encodeUrl​(@NotNull
                                                   @NotNull java.lang.CharSequence url)
        Specified by:
        encodeUrl in interface LinkResolverContext
        Parameters:
        url - to be encoded
        Returns:
        an encoded URL (depending on the configuration)
      • resolveLink

        @NotNull
        public @NotNull ResolvedLink resolveLink​(@NotNull
                                                 @NotNull LinkType linkType,
                                                 @NotNull
                                                 @NotNull java.lang.CharSequence url,
                                                 java.lang.Boolean urlEncode)
        Description copied from interface: LinkResolverContext
        Resolve link for rendering. Link Resolvers are going to be called until one returns ResolvedLink with getStatus() != LinkStatus.Unknown

        A resolver can replace the url but not change the status letting downstream resolvers handle the rest. This is useful when a resolver does partial processing like macro expansion but does not know how to handle the rest.

        Core processing will simply pass the link as is. It is up to extension LinkResolvers and AttributeProviders to make sense of the link and applicable attributes based on status.

        Specified by:
        resolveLink in interface LinkResolverContext
        Parameters:
        linkType - type of link being rendered. Core defined links are Link, Image. Extensions can define their own
        url - link url text
        urlEncode - whether the link should be url encoded, if null then the value of HtmlRenderer.PERCENT_ENCODE_URLS will be used to determine whether the resolved URL is to be encoded.
        Returns:
        resolved link url for this link and its resolved status
      • resolveLink

        @NotNull
        public @NotNull ResolvedLink resolveLink​(@NotNull
                                                 @NotNull LinkType linkType,
                                                 @NotNull
                                                 @NotNull java.lang.CharSequence url,
                                                 Attributes attributes,
                                                 java.lang.Boolean urlEncode)
        Description copied from interface: LinkResolverContext
        Resolve link for rendering. Link Resolvers are going to be called until one returns ResolvedLink with getStatus() != LinkStatus.Unknown

        A resolver can replace the url but not change the status letting downstream resolvers handle the rest. This is useful when a resolver does partial processing like macro expansion but does not know how to handle the rest.

        Core processing will simply pass the link as is. It is up to extension LinkResolvers and AttributeProviders to make sense of the link and applicable attributes based on status.

        Specified by:
        resolveLink in interface LinkResolverContext
        Parameters:
        linkType - type of link being rendered. Core defined links are Link, Image. Extensions can define their own
        url - link url text
        attributes - link attributes
        urlEncode - whether the link should be url encoded, if null then the value of HtmlRenderer.PERCENT_ENCODE_URLS will be used to determine whether the resolved URL is to be encoded.
        Returns:
        resolved link url for this link and its resolved status
      • postProcessNonTranslating

        public void postProcessNonTranslating​(@NotNull
                                              @NotNull java.util.function.Function<java.lang.String,​java.lang.CharSequence> postProcessor,
                                              @NotNull
                                              @NotNull java.lang.Runnable scope)
        Specified by:
        postProcessNonTranslating in interface TranslationContext
        Parameters:
        postProcessor - id post processor for TRANSLATED purpose
        scope - code to which the post processor applies
      • postProcessNonTranslating

        @NotNull
        public <T> T postProcessNonTranslating​(@NotNull
                                               @NotNull java.util.function.Function<java.lang.String,​java.lang.CharSequence> postProcessor,
                                               @NotNull
                                               @NotNull java.util.function.Supplier<T> scope)
        Specified by:
        postProcessNonTranslating in interface TranslationContext
        Parameters:
        postProcessor - id post processor for TRANSLATED purpose
        scope - code to which the post processor applies