This is an automated email from the ASF dual-hosted git repository. juanpablo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/jspwiki.git
commit 0268bcd7a0185615e285e75d751f4ee5ed8df993 Author: juanpablo <[email protected]> AuthorDate: Wed Dec 27 23:15:26 2017 +0100 include the custom node renderer on the JSPWiki extensions. Also move static inner classes from MarkdownForJSPWikiExtension to first class citizen classes --- .../wiki/markdown/MarkdownForJSPWikiExtension.java | 50 +++------------------ .../JSPWikiLinkAttributeProviderFactory.java | 50 +++++++++++++++++++++ .../JSPWikiNodePostProcessorFactory.java | 51 ++++++++++++++++++++++ 3 files changed, 107 insertions(+), 44 deletions(-) diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/MarkdownForJSPWikiExtension.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/MarkdownForJSPWikiExtension.java index 4d784a0..993c8cd 100755 --- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/MarkdownForJSPWikiExtension.java +++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/MarkdownForJSPWikiExtension.java @@ -19,25 +19,17 @@ package org.apache.wiki.markdown; import org.apache.wiki.WikiContext; -import org.apache.wiki.markdown.extensions.jspwikilinks.attributeprovider.JSPWikiLinkAttributeProvider; -import org.apache.wiki.markdown.extensions.jspwikilinks.postprocessor.JSPWikiLinkNodePostProcessor; +import org.apache.wiki.markdown.extensions.jspwikilinks.attributeprovider.JSPWikiLinkAttributeProviderFactory; +import org.apache.wiki.markdown.extensions.jspwikilinks.postprocessor.JSPWikiNodePostProcessorFactory; +import org.apache.wiki.markdown.renderer.JSPWikiNodeRendererFactory; -import com.vladsch.flexmark.ast.Document; -import com.vladsch.flexmark.ast.Link; -import com.vladsch.flexmark.html.AttributeProvider; -import com.vladsch.flexmark.html.AttributeProviderFactory; import com.vladsch.flexmark.html.HtmlRenderer; -import com.vladsch.flexmark.html.IndependentAttributeProviderFactory; -import com.vladsch.flexmark.html.renderer.NodeRendererContext; import com.vladsch.flexmark.parser.Parser; -import com.vladsch.flexmark.parser.block.NodePostProcessor; -import com.vladsch.flexmark.parser.block.NodePostProcessorFactory; -import com.vladsch.flexmark.util.options.DataHolder; import com.vladsch.flexmark.util.options.MutableDataHolder; /** - * Flexmark entry point for JSPWiki extensions + * Flexmark entry point to bootstrap JSPWiki extensions. */ public class MarkdownForJSPWikiExtension implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension { @@ -66,7 +58,8 @@ public class MarkdownForJSPWikiExtension implements Parser.ParserExtension, Html */ @Override public void extend( final HtmlRenderer.Builder rendererBuilder, final String rendererType ) { - rendererBuilder.attributeProviderFactory( jspWikiAttributeProviderFactory( context ) ); + rendererBuilder.nodeRendererFactory( new JSPWikiNodeRendererFactory( context ) ); + rendererBuilder.attributeProviderFactory( new JSPWikiLinkAttributeProviderFactory( context ) ); } /** @@ -77,35 +70,4 @@ public class MarkdownForJSPWikiExtension implements Parser.ParserExtension, Html parserBuilder.postProcessorFactory( new JSPWikiNodePostProcessorFactory( context, parserBuilder ) ); } - AttributeProviderFactory jspWikiAttributeProviderFactory( final WikiContext wContext ) { - return new IndependentAttributeProviderFactory() { - /** - * {@inheritDoc} - */ - @Override - public AttributeProvider create( final NodeRendererContext context ) { - return new JSPWikiLinkAttributeProvider( wContext ); - } - }; - } - - static class JSPWikiNodePostProcessorFactory extends NodePostProcessorFactory { - - private final WikiContext m_context; - - public JSPWikiNodePostProcessorFactory( final WikiContext m_context, final DataHolder options ) { - super( true ); - addNodes( Link.class ); // needs to be called before create( Document ) - this.m_context = m_context; - } - - /** - * {@inheritDoc} - */ - @Override - public NodePostProcessor create( final Document document ) { - return new JSPWikiLinkNodePostProcessor( m_context, document ); - } - } - } diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/JSPWikiLinkAttributeProviderFactory.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/JSPWikiLinkAttributeProviderFactory.java new file mode 100755 index 0000000..a7dab2d --- /dev/null +++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/JSPWikiLinkAttributeProviderFactory.java @@ -0,0 +1,50 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + */ +package org.apache.wiki.markdown.extensions.jspwikilinks.attributeprovider; + +import org.apache.wiki.WikiContext; + +import com.vladsch.flexmark.html.AttributeProvider; +import com.vladsch.flexmark.html.AttributeProviderFactory; +import com.vladsch.flexmark.html.IndependentAttributeProviderFactory; +import com.vladsch.flexmark.html.renderer.NodeRendererContext; + + +/** + * Simple {@link AttributeProviderFactory} to instantiate {@link JSPWikiLinkAttributeProvider}s. + */ +public class JSPWikiLinkAttributeProviderFactory extends IndependentAttributeProviderFactory { + + final WikiContext wikiContext; + + public JSPWikiLinkAttributeProviderFactory( final WikiContext wikiContext ) { + this.wikiContext = wikiContext; + } + + /** + * {@inheritDoc} + * + * @see com.vladsch.flexmark.html.AttributeProviderFactory#create(com.vladsch.flexmark.html.renderer.NodeRendererContext) + */ + @Override + public AttributeProvider create( final NodeRendererContext context ) { + return new JSPWikiLinkAttributeProvider( wikiContext ); + } + +} diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/JSPWikiNodePostProcessorFactory.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/JSPWikiNodePostProcessorFactory.java new file mode 100755 index 0000000..cddf27f --- /dev/null +++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/JSPWikiNodePostProcessorFactory.java @@ -0,0 +1,51 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +package org.apache.wiki.markdown.extensions.jspwikilinks.postprocessor; + +import org.apache.wiki.WikiContext; + +import com.vladsch.flexmark.ast.Document; +import com.vladsch.flexmark.ast.Link; +import com.vladsch.flexmark.parser.block.NodePostProcessor; +import com.vladsch.flexmark.parser.block.NodePostProcessorFactory; +import com.vladsch.flexmark.util.options.DataHolder; + + +/** + * Simple {@link NodePostProcessorFactory} to instantiate {@link JSPWikiLinkNodePostProcessor}s. + */ +public class JSPWikiNodePostProcessorFactory extends NodePostProcessorFactory { + + private final WikiContext m_context; + + public JSPWikiNodePostProcessorFactory( final WikiContext m_context, final DataHolder options ) { + super( true ); + addNodes( Link.class ); // needs to be called before create( Document ) + this.m_context = m_context; + } + + /** + * {@inheritDoc} + */ + @Override + public NodePostProcessor create( final Document document ) { + return new JSPWikiLinkNodePostProcessor( m_context, document ); + } + +} -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
