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.markdown; 020 021import org.apache.wiki.WikiContext; 022import org.apache.wiki.markdown.extensions.jspwikilinks.attributeprovider.JSPWikiLinkAttributeProviderFactory; 023import org.apache.wiki.markdown.extensions.jspwikilinks.postprocessor.JSPWikiNodePostProcessorFactory; 024import org.apache.wiki.markdown.renderer.JSPWikiNodeRendererFactory; 025 026import com.vladsch.flexmark.html.HtmlRenderer; 027import com.vladsch.flexmark.parser.Parser; 028import com.vladsch.flexmark.util.options.MutableDataHolder; 029 030 031/** 032 * Flexmark entry point to bootstrap JSPWiki extensions. 033 */ 034public class MarkdownForJSPWikiExtension implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension { 035 036 private final WikiContext context; 037 038 public MarkdownForJSPWikiExtension( final WikiContext context ) { 039 this.context = context; 040 } 041 042 /** 043 * {@inheritDoc} 044 */ 045 @Override 046 public void rendererOptions( final MutableDataHolder options ) { 047 } 048 049 /** 050 * {@inheritDoc} 051 */ 052 @Override 053 public void parserOptions( final MutableDataHolder options ) { 054 } 055 056 /** 057 * {@inheritDoc} 058 */ 059 @Override 060 public void extend( final HtmlRenderer.Builder rendererBuilder, final String rendererType ) { 061 rendererBuilder.nodeRendererFactory( new JSPWikiNodeRendererFactory( context ) ); 062 rendererBuilder.attributeProviderFactory( new JSPWikiLinkAttributeProviderFactory( context ) ); 063 } 064 065 /** 066 * {@inheritDoc} 067 */ 068 @Override 069 public void extend( final Parser.Builder parserBuilder ) { 070 parserBuilder.postProcessorFactory( new JSPWikiNodePostProcessorFactory( context, parserBuilder ) ); 071 } 072 073}