001/*
002    Licensed to the Apache Software Foundation (ASF) under one
003    or more contributor license agreements.  See the NOTICE file
004    distributed with this work for additional information
005    regarding copyright ownership.  The ASF licenses this file
006    to you under the Apache License, Version 2.0 (the
007    "License"); you may not use this file except in compliance
008    with the License.  You may obtain a copy of the License at
009
010       http://www.apache.org/licenses/LICENSE-2.0
011
012    Unless required by applicable law or agreed to in writing,
013    software distributed under the License is distributed on an
014    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015    KIND, either express or implied.  See the License for the
016    specific language governing permissions and limitations
017    under the License.
018*/
019package org.apache.wiki.htmltowiki.syntax.jspwiki;
020
021import org.apache.wiki.htmltowiki.WhitespaceTrimWriter;
022import org.apache.wiki.htmltowiki.XHtmlElementToWikiTranslator;
023import org.apache.wiki.htmltowiki.XHtmlToWikiConfig;
024import org.apache.wiki.htmltowiki.syntax.OptionDecorator;
025import org.apache.wiki.htmltowiki.syntax.PlainTextDecorator;
026import org.apache.wiki.htmltowiki.syntax.TableDecorator;
027import org.apache.wiki.htmltowiki.syntax.TbodyDecorator;
028import org.apache.wiki.htmltowiki.syntax.TextElementDecorator;
029import org.apache.wiki.htmltowiki.syntax.TheadDecorator;
030import org.apache.wiki.htmltowiki.syntax.TrDecorator;
031import org.apache.wiki.htmltowiki.syntax.WikiSyntaxDecorator;
032
033import java.io.PrintWriter;
034import java.util.Deque;
035
036
037/**
038 * JSPWiki wiki syntax decorator which translates to wiki syntax. Delegates each kind of XHTML element to its specific decorator.
039 */
040public class JSPWikiSyntaxDecorator extends WikiSyntaxDecorator {
041
042    /** {@inheritDoc} */
043    @Override
044    public void init( final PrintWriter out,
045                      final Deque< String > liStack,
046                      final Deque< String > preStack,
047                      final WhitespaceTrimWriter outTrimmer,
048                      final XHtmlToWikiConfig config,
049                      final XHtmlElementToWikiTranslator chain ) {
050        this.config = config;
051        this.outTrimmer = outTrimmer;
052        this.chain = chain;
053
054        this.cssStyle = new JSPWikiPlainTextCssSpecialDecorator( out, chain );
055        this.pre = new JSPWikiPlainTextMonospaceDecorator( cssStyle, out, preStack, chain );
056        this.em = new JSPWikiPlainTextItalicDecorator( pre, out, chain );
057        this.strong = new JSPWikiPlainTextBoldDecorator( em, out, chain );
058        this.css = new JSPWikiPlainTextCssDecorator( strong, out, chain );
059        this.plainText = new PlainTextDecorator( css, out, chain );
060
061        this.a = new JSPWikiADecorator( out, config, chain );
062        this.br = new JSPWikiBrDecorator( out, preStack, chain );
063        this.code = new JSPWikiCodeDecorator( out, preStack, chain );
064        this.dd = new JSPWikiDdDecorator( out, chain );
065        this.dl = new JSPWikiDlDecorator( out, chain );
066        this.dt = new JSPWikiDtDecorator( out, chain );
067        this.form = new JSPWikiFormDecorator( out, chain );
068        this.hr = new JSPWikiHrDecorator( out, chain );
069        this.h1 = new JSPWikiH1Decorator( out, chain );
070        this.h2 = new JSPWikiH2Decorator( out, chain );
071        this.h3 = new JSPWikiH3Decorator( out, chain );
072        this.h4 = new JSPWikiH4Decorator( out, chain );
073        this.img = new JSPWikiImageDecorator( out, config );
074        this.input = new JSPWikiInputDecorator( out, chain );
075        this.li = new JSPWikiLiDecorator( out, liStack, chain );
076        this.ol = new JSPWikiOlDecorator( out, liStack, chain );
077        this.option = new OptionDecorator( out, chain );
078        this.p = new JSPWikiPDecorator( out, chain );
079        this.table = new TableDecorator( out, outTrimmer, chain );
080        this.tbody = new TbodyDecorator( out, chain );
081        this.td = new JSPWikiTdDecorator( out, preStack, chain );
082        this.th = new JSPWikiThDecorator( out, preStack, chain );
083        this.thead = new TheadDecorator( out, chain );
084        this.tr = new TrDecorator( out, chain );
085        this.textarea = new JSPWikiTextAreaDecorator( out, chain );
086        this.textElement = new TextElementDecorator( out, preStack );
087        this.select = new JSPWikiSelectDecorator( out, chain );
088        this.strike = new JSPWikiStrikeDecorator( out, chain );
089        this.sub = new JSPWikiSubDecorator( out, chain );
090        this.sup = new JSPWikiSupDecorator( out, chain );
091        this.ul = new JSPWikiUlDecorator( out, liStack, chain );
092        this.underline = new JSPWikiUnderlineDecorator( out, chain );
093    }
094
095}