From cf173715c28c6ac820df44009dd5bc3222af46fb Mon Sep 17 00:00:00 2001
From: ulrich
Date: Sun, 10 Nov 2024 16:14:57 +0000
Subject: [PATCH] an AsciidoctorJ Version 3 angepasst
---
src/de/uhilger/neon/adoc/AdocFilter.java | 6 ++----
src/de/uhilger/neon/adoc/AdocWorker.java | 32 ++++++++++++++------------------
2 files changed, 16 insertions(+), 22 deletions(-)
diff --git a/src/de/uhilger/neon/adoc/AdocFilter.java b/src/de/uhilger/neon/adoc/AdocFilter.java
index c0cca3b..f02a607 100644
--- a/src/de/uhilger/neon/adoc/AdocFilter.java
+++ b/src/de/uhilger/neon/adoc/AdocFilter.java
@@ -38,13 +38,11 @@
@Override
public void doFilter(HttpExchange exchange, Chain chain) throws IOException {
URI uri = exchange.getRequestURI();
- //String path = uri.getPath();
try {
- String path = new HttpHelper().getFileName(exchange);
- if(path.endsWith(".adoc")) {
+ String fileName = new HttpHelper().getFileName(exchange);
+ if(fileName.endsWith(".adoc")) {
HttpContext ctx = exchange.getHttpContext();
String fileBase = ctx.getAttributes().get(FileServer.ATTR_FILE_BASE).toString();
- String fileName = path.substring(ctx.getPath().length());
String query = uri.getQuery();
if (query instanceof String && query.contains("pdf=true")) {
processAdocFile(new File(fileBase, fileName), true);
diff --git a/src/de/uhilger/neon/adoc/AdocWorker.java b/src/de/uhilger/neon/adoc/AdocWorker.java
index 6be83bf..4719032 100644
--- a/src/de/uhilger/neon/adoc/AdocWorker.java
+++ b/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);
}
}
--
Gitblit v1.9.3