Class WikiRenderer

  • All Implemented Interfaces:
    JcmsConstants, JaliosConstants
    Direct Known Subclasses:
    WikiRenderer

    public class WikiRenderer
    extends java.lang.Object
    implements JcmsConstants
    This class contains a set of utility static methods to process wiki text.
    Since:
    jcms-5.5.0
    Version:
    $Revision: 124679 $
    Author:
    Olivier Dedieu, Olivier Jaquemet
    • Constructor Detail

      • WikiRenderer

        public WikiRenderer()
    • Method Detail

      • wiki2html

        public static java.lang.String wiki2html​(java.lang.String text,
                                                 java.util.Locale userLocale,
                                                 WikiRenderingHints hints)
        Transform a given string formatted according the wiki text formatting rules in an HTML string. The wiki formatting rules used follows the twiki.org text formatting rules:
        formatting rules
        Wiki formatHTML output
        *bold*<b>bold</b>
        _italic_<i>italic</i>
        __bold italic__<b><i>bold italic</i></b>
        =fixed font=<code>fixed font</code>
        ==bold fixed font==<code><b>bold fixed font</b></code>
        Paragraphe
        A blank line
        <p>
        Heading
        At least three dashes at the beginning of a line, followed by plus sign and the heading text. One plus creates a level 1 heading (most important), two pluses a level 2 heading ; the maximum is 6.
        ---++ 1. A title
        ---+++ 1.1 A subtitle
        <h1>A title</h1>
        <h2>A subtitle</h2>
        Separator
        At least 3 dashes at the beginning of a line
        ---------
        <hr>
        List item
        A multiple of three spaces and an asterisk
           * A list item
        * A nested list item
        <ul>
        <li>A list item</li>
        <ul>
        <li>A nested list item</li>
        </ul>
        </ul>
        Ordered list
        A multiple of three spaces and a number
           1 A first item
        2 A second item
        <ol>
        <li>A first item</li>
        <li>A second item</li>
        </ol>
        Definition list
        Three spaces, the term, a colon, followed by the definition

        Note: Terms with spaces are not supported. In case you do have a term with more than one word, separate the words with dashes or with the &nbsp; non-breaking-space entity.

           USB: Universal Serial Bus
        Firewire&nbsp;(IEEE&nbsp;1394): High Performance Serial Bus
        <dl>
        <dt>USB</dt><dd>Universal Serial Bus</dd>
        <dt>Firewire&amp;nbsp;(IEEE&amp;nbsp;1394)</dt><dd>High Performance Serial Bus</dd>
        </dl>
        Publication Links
        A publication's title or id enclosed in double square brackets.
        [[The title of a publication]]
        [[c_1234]]
        <a href="link to the publication">Title of the publication</a>
        Images insertion
        A valid image file name (ending with .jpg, .jpeg, .gif or .png)
        upload/gallery/image.jpg
        <img src="upload/gallery/image.jpg">
        File Links
        A valid image file name enclosed in double square brackets.
        [[upload/pdf/overview.pdf]]
        <a href="upload/pdf/overview.pdf">overview.pdf</a>
        Parameters:
        text - the wiki text to format. if null or empty, an empty string is immediately returned.
        userLocale - an optional (though highly recommended) Locale of the user for which the text will be generated. if null, the channel default locale will be used.
        hints - the rendering options to use, if null, the default options will be used.
        Returns:
        an HTML formatted text.
        Since:
        jcms-5.7.0
      • wiki2RawText

        public static java.lang.String wiki2RawText​(java.lang.String wiki,
                                                    java.util.Locale userLocale,
                                                    WikiRenderingHints hints)
        Transform the specified string formatted according the wiki text formatting rules in a raw text string without any format.

        The returned text is NOT suitable for presentation to the end user, it is meant only to extract text without wiki tags.

        Parameters:
        wiki - the wiki text to format. if null or empty, an empty string is immediately returned.
        userLocale - an optional (though highly recommended) Locale of the user for which the text will be generated. if null, the channel default locale will be used.
        hints - the rendering options to use, if null, the default options will be used.
        Returns:
        a raw text (without wiki or HTML tags).
        Since:
        jcms-9.0.4 - JCMS-5429
      • extractSection

        public static java.lang.String extractSection​(java.lang.String text,
                                                      java.lang.String section)
      • updateSection

        public static java.lang.String updateSection​(java.lang.String text,
                                                     java.lang.String section,
                                                     java.lang.String update)
      • encodeSection

        public static java.lang.String encodeSection​(Data data,
                                                     java.lang.String field,
                                                     java.lang.String update)
      • extractPubSetFromWiki

        public static java.util.Set<Publication> extractPubSetFromWiki​(java.lang.String text)
        Returns the set of publication referenced through wiki link in the given text.
        Parameters:
        text - the text
        Returns:
        the set of publication referenced through wiki link in the given text.
        Since:
        jcms-5.5.0
      • extractPubSetFromUrl

        public static java.util.Set<Publication> extractPubSetFromUrl​(java.lang.String text)
        Returns the set of publication referenced through URL in the given text.
        Parameters:
        text - the text
        Returns:
        the set of publication referenced through URL in the given text.
        Since:
        jcms-5.5.0