Erweiterung von neon zur Transformation von Asciidoc
ulrich
4 days ago cf173715c28c6ac820df44009dd5bc3222af46fb
src/de/uhilger/neon/adoc/AdocWorker.java
@@ -18,11 +18,10 @@
package de.uhilger.neon.adoc;
import java.io.File;
import java.util.Map;
import org.asciidoctor.Asciidoctor;
import static org.asciidoctor.Asciidoctor.Factory.create;
import static org.asciidoctor.AttributesBuilder.attributes;
import static org.asciidoctor.OptionsBuilder.options;
import org.asciidoctor.Attributes;
import org.asciidoctor.Options;
import org.asciidoctor.SafeMode;
/**
@@ -48,43 +47,40 @@
   * nach PDF transformiert werden soll
   */
  public void transform(String fileName, String backend) {    
    //logger.fine("fileName: " + fileName + ", backend: " + backend);
    Map<String, Object> attributes;
    Attributes attributes;
    File outFile = new File(fileName);
    String thisDirName = outFile.getParent();
    File pdfStyles = new File(outFile.getParentFile(), "custom-theme.yml");
    if(pdfStyles.exists()) {
      attributes = attributes()
      attributes = Attributes.builder()
              .attribute("pdf-themesdir", thisDirName)
              .attribute("pdf-theme","custom")
              .attribute("pdf-fontsdir", thisDirName + "/fonts")
              .attribute("allow-uri-read")
              .sourceHighlighter("highlightjs")
              .asMap();
              .build();
    } else {
      attributes = attributes()
      attributes = Attributes.builder()
              .sourceHighlighter("highlightjs")
              .asMap();
              .build();
    }
    Map<String, Object> options;
    Options options;
    if(null != backend) {
      options = options().inPlace(false)
      options = Options.builder()
              .inPlace(false)
              .safe(SafeMode.SERVER)
              .backend(backend).attributes(attributes).asMap();
              .backend(backend).attributes(attributes).build();
      
    } else {
      options = options().inPlace(false)
      options = Options.builder()
              .inPlace(false)
              .safe(SafeMode.SERVER)
              .attributes(attributes).asMap();
              .attributes(attributes).build();
    }
    
    File adcf = new File(fileName);
    //logger.fine("before asciidoctor create, adcf: " + adcf.getAbsolutePath());
    Asciidoctor asciidoctor = create();    
    //logger.fine("asciidoctor created.");
    asciidoctor.requireLibrary("asciidoctor-diagram");
    //logger.fine("asciidoctor requireLibrary diagram passed.");
    //logger.fine("calling asciidoctor.convert for file " + adcf.getAbsolutePath());
    asciidoctor.convertFile(adcf, options);    
  }  
}