Class RenderingScriptService

  • All Implemented Interfaces:
    org.xwiki.script.service.ScriptService

    @Component
    @Named("rendering")
    @Singleton
    public class RenderingScriptService
    extends Object
    implements org.xwiki.script.service.ScriptService
    Provides Rendering-specific Scripting APIs.
    Since:
    2.3M1
    Version:
    $Id: da02fb9e4e1f6ceb717d78c2efc63239d009a223 $
    • Constructor Detail

      • RenderingScriptService

        public RenderingScriptService()
    • Method Detail

      • getAvailableParserSyntaxes

        public List<org.xwiki.rendering.syntax.Syntax> getAvailableParserSyntaxes()
        Returns:
        the list of syntaxes for which a Parser is available
      • getAvailableRendererSyntaxes

        public List<org.xwiki.rendering.syntax.Syntax> getAvailableRendererSyntaxes()
        Returns:
        the list of syntaxes for which a Renderer is available
      • getDefaultTransformationNames

        public List<String> getDefaultTransformationNames()
        Returns:
        the names of Transformations that are configured in the Rendering Configuration and which are used by the Transformation Manager when running all transformations
      • parse

        public org.xwiki.rendering.block.XDOM parse​(String text,
                                                    String syntaxId)
        Parses a text written in the passed syntax.
        Parameters:
        text - the text to parse
        syntaxId - the id of the syntax in which the text is written in
        Returns:
        the XDOM representing the AST of the parsed text or null if an error occurred
        Since:
        3.2M3
      • render

        public String render​(org.xwiki.rendering.block.Block block,
                             String outputSyntaxId)
        Render a list of Blocks into the passed syntax.
        Parameters:
        block - the block to render
        outputSyntaxId - the syntax in which to render the blocks
        Returns:
        the string representing the passed blocks in the passed syntax or null if an error occurred
        Since:
        3.2M3
      • resolveSyntax

        public org.xwiki.rendering.syntax.Syntax resolveSyntax​(String syntaxId)
        Converts a Syntax specified as a String into a proper Syntax object.
        Parameters:
        syntaxId - the syntax as a string (eg "xwiki/2.0", "html/4.01", etc)
        Returns:
        the proper Syntax object representing the passed syntax
      • escape

        public String escape​(String content,
                             org.xwiki.rendering.syntax.Syntax syntax)
        Escapes a give text using the escaping method specific to the given syntax.

        One example of escaping method is using escape characters like ~ for the Syntax.XWIKI_2_1 syntax on all or just some characters of the given text.

        The current implementation only escapes XWiki 1.0, 2.0 and 2.1 syntaxes.

        Parameters:
        content - the text to escape
        syntax - the syntax to escape the content in (e.g. Syntax.XWIKI_1_0, Syntax.XWIKI_2_0, Syntax.XWIKI_2_1, etc.). This is the syntax where the output will be used and not necessarily the same syntax of the input content
        Returns:
        the escaped text or null if the given content or the given syntax are null, or if the syntax is not supported
        Since:
        7.1M1
      • getConfiguredSyntaxes

        public List<org.xwiki.rendering.syntax.Syntax> getConfiguredSyntaxes()
        Returns:
        the list of Rendering Syntaxes that are configured for the current wiki (i.e. that are proposed to the user when editing wiki pages). These are input Syntaxes only (i.e. Syntaxes having a Parser for them).
        Since:
        8.2M1
      • getDisabledSyntaxes

        public List<org.xwiki.rendering.syntax.Syntax> getDisabledSyntaxes()
        Returns:
        the list of Rendering Syntaxes that are disabled for the current wiki (i.e. that should not be proposed to the user when editing wiki pages)
        Since:
        8.2M1
      • getMacroDescriptors

        public List<org.xwiki.rendering.macro.descriptor.MacroDescriptor> getMacroDescriptors​(org.xwiki.rendering.syntax.Syntax syntax)
                                                                                       throws org.xwiki.rendering.macro.MacroLookupException
        Parameters:
        syntax - the syntax for which to return the list of Macro descriptors
        Returns:
        the macro descriptors for the macros registered and available to the passed syntax
        Throws:
        org.xwiki.rendering.macro.MacroLookupException - if a macro component descriptor cannot be loaded
        Since:
        9.7RC1
      • resolveMacroId

        public org.xwiki.rendering.macro.MacroId resolveMacroId​(String macroIdAsString)
        Parameters:
        macroIdAsString - a string representing a macro id
        Returns:
        the resolved macro id or null if resolving the given string fails
        Since:
        10.10RC1
      • getMacroDescriptor

        public org.xwiki.rendering.macro.descriptor.MacroDescriptor getMacroDescriptor​(org.xwiki.rendering.macro.MacroId macroId)
        Parameters:
        macroId - the macro id
        Returns:
        the descriptor of the specified macro if it exists, null otherwise
        Since:
        10.10RC1
      • getMacroCategories

        @Unstable
        public Set<String> getMacroCategories​(org.xwiki.rendering.macro.MacroId macroId)
        Return the list of categories of a given macro.
        Parameters:
        macroId - the macro id
        Returns:
        the list of categories of the macro
        Since:
        14.6RC1
      • getHiddenMacroCategories

        @Unstable
        public Set<String> getHiddenMacroCategories()
        Returns:
        the set of hidden macro categories
        Since:
        14.8RC1