package me.qwq.doghouse.flexmark.ext.fancyquote;

import org.jetbrains.annotations.NotNull;

import com.vladsch.flexmark.html.HtmlRenderer;
import com.vladsch.flexmark.html.HtmlRenderer.Builder;
import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.util.data.DataKey;
import com.vladsch.flexmark.util.data.MutableDataHolder;

public class FancyQuoteExtension implements Parser.ParserExtension
, HtmlRenderer.HtmlRendererExtension{

    final public static DataKey<Boolean> FANCY_QUOTE_PARSER = new DataKey<>("FANCY_QUOTE_PARSER", true);
    final public static DataKey<String> FANCY_QUOTE_DEFAULT_TYPE = new DataKey<>("FANCY_QUOTE_DEFAULT_TYPE", "div");
    final public static DataKey<String> FANCY_QUOTE_DEFAULT_CLASS = new DataKey<>("FANCY_QUOTE_DEFAULT_CLASS", "fancyquote");
    
    private FancyQuoteExtension() {
    }
    
    public static FancyQuoteExtension create() {
        return new FancyQuoteExtension();
    }

    @Override
    public void rendererOptions(@NotNull MutableDataHolder options) {
    }

    @Override
    public void extend(@NotNull Builder htmlRendererBuilder,
            @NotNull String rendererType) {
        if (htmlRendererBuilder.isRendererType("HTML")) {
            htmlRendererBuilder.nodeRendererFactory(new FancyQuoteRenderer.Factory());
        } else {
            //rendererBuilder.nodeRendererFactory(new GitLabJiraRenderer.Factory());
        }
        
    }

    @Override
    public void parserOptions(MutableDataHolder options) {
        
    }

    @Override
    public void extend(com.vladsch.flexmark.parser.Parser.Builder parserBuilder) {
        parserBuilder.customBlockParserFactory(new FancyQuoteParser.Factory());
    }

}
