Skip to content

Commit

Permalink
Fix counter issue #637
Browse files Browse the repository at this point in the history
  • Loading branch information
rahmanusta committed May 5, 2024
1 parent c85f79d commit 297a31e
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/main/java/com/kodedu/config/AsciidoctorConfigBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;

import static com.kodedu.other.Constants.DOC_FILE_ATTR;
import static com.kodedu.service.AsciidoctorFactory.getPlainDoctor;
Expand Down Expand Up @@ -346,8 +347,13 @@ public Attributes getAsciiDocAttributes(Map<String, Object> originalDocAttribute
}
}
Map<String, Object> cloneMap = new LinkedHashMap<>(map);
List<String> ignoredAttributes = getIgnoredAttributes(originalDocAttributes);
for (Map.Entry<String, Object> entry : originalDocAttributes.entrySet()) {
cloneMap.put(entry.getKey(), entry.getValue());
String key = entry.getKey();
Object value = entry.getValue();
if (!ignoredAttributes.contains(key)) {
cloneMap.put(key, value);
}
}

String docdir = (String) originalDocAttributes.get("docdir");
Expand All @@ -366,6 +372,24 @@ public Attributes getAsciiDocAttributes(Map<String, Object> originalDocAttribute
return attributesBuilder.build();
}

private List<String> getIgnoredAttributes(Map<String, Object> attributes) {
return attributes.entrySet().stream().flatMap(e -> {
String attr = e.getKey();
Object value = e.getValue();
List<String> attrs = new ArrayList<>();
if (attr.contains("count") && value instanceof Number) {
attrs.add(attr);
}
if (attr.contains("count") && value instanceof String s) {
String[] split = s.split(":");
if (split.length > 0) {
attrs.add(split[0].trim());
}
}
return attrs.stream();
}).collect(Collectors.toList());
}

List<String> node_extensions = List.of("mmdc","vg2png","vg2svg","nomnoml","bytefield");
Map<String, Path> extensionPathMap = new HashMap<>();
private Map<String, Object> resolveExtensionBuilderAttributes(String docdir, Map<String, Object> docAttributes) {
Expand Down

0 comments on commit 297a31e

Please sign in to comment.