All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.cukedoctor.extension.CukedoctorScriptExtension Maven / Gradle / Ivy

There is a newer version: 3.9.0
Show newest version
package com.github.cukedoctor.extension;

import static com.github.cukedoctor.extension.CukedoctorExtensionRegistry.*;

import org.asciidoctor.ast.Document;
import org.asciidoctor.extension.Postprocessor;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;

import java.util.Map;

/**
 * Created by pestano on 20/07/15.
 * adds javascript functions to html documentation
 */
public class CukedoctorScriptExtension extends Postprocessor{

    public CukedoctorScriptExtension(Map config) {
        super(config);
    }

    @Override
    public String process(Document document, String output) {
        if(document.basebackend("html") ){
            org.jsoup.nodes.Document doc = Jsoup.parse(output, "UTF-8");

            Element contentElement = doc.getElementById("footer");
                if(System.getProperty(FILTER_DISABLE_EXT_KEY) == null) {
                        addSearchScript(contentElement);
                }
                if(System.getProperty(MINMAX_DISABLE_EXT_KEY) == null){
                        addMinMaxScript(contentElement);
                }
                if(System.getProperty(THEME_DISABLE_EXT_KEY) == null){
                        addThemeScript(contentElement);
                }
            return doc.html();

        }else{
            return output;
        }
    }

        private void addThemeScript(Element contentElement) {
             String themeScript = "       ";

                contentElement.after(themeScript);
        }

        private void addMinMaxScript(Element contentElement) {
        String minMaxScript = "";
        contentElement.after(minMaxScript);
    }

    private void addSearchScript(Element contentElement) {
        String searchScripts = "";
        contentElement.after(searchScripts);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy