From 29a3253c60bcb351907a0e4e4d030adc09c6fcf4 Mon Sep 17 00:00:00 2001 From: miscoined Date: Fri, 12 Jul 2024 18:14:54 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=F0=9F=90=9B=20Add=20a=20QuteDataTr?= =?UTF-8?q?aits=20and=20fix=20some=20trait/tag=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add a QuteDataTraits - dedicated class to hold traits so we can have easier bare linking - Rename collectTraitsFrom to getTraits, and pull Tag adding into QuteDataTraits - Fix creature statblock so it doesn't generate traits property when we don't have any generic traits - Fix some items being incorrectly tagged with their source (e.g. tagged as "trait/preparation-sog2" rather than "trait/preparation") - Fix some incorrectly formatted markdown links when the trait is surrounded in square brackets (e.g. for classes and magical traditions) Fix --- .../pf2etools/creature2md-yamlStatblock.txt | 23 ++- .../convert/tools/pf2e/Json2QuteBase.java | 7 +- .../convert/tools/pf2e/Json2QuteDeity.java | 10 +- .../convert/tools/pf2e/Json2QuteItem.java | 2 +- .../convert/tools/pf2e/JsonSource.java | 7 +- .../tools/pf2e/JsonTextReplacement.java | 24 ++- .../tools/pf2e/Pf2eJsonNodeReader.java | 6 +- .../convert/tools/pf2e/qute/QuteCreature.java | 21 --- .../convert/tools/pf2e/qute/QuteDataRef.java | 2 +- .../tools/pf2e/qute/QuteDataTraits.java | 142 ++++++++++++++++++ .../tools/pf2e/qute/QuteInlineAttack.java | 15 +- .../convert/tools/pf2e/qute/QuteItem.java | 4 +- .../templates/toolsPf2e/inline-ability2md.txt | 2 +- .../templates/toolsPf2e/inline-attack2md.txt | 6 +- 14 files changed, 185 insertions(+), 86 deletions(-) create mode 100644 src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteDataTraits.java diff --git a/examples/templates/pf2etools/creature2md-yamlStatblock.txt b/examples/templates/pf2etools/creature2md-yamlStatblock.txt index 40c8e3743..746daf136 100644 --- a/examples/templates/pf2etools/creature2md-yamlStatblock.txt +++ b/examples/templates/pf2etools/creature2md-yamlStatblock.txt @@ -26,21 +26,18 @@ sourcebook: {source.quoted} name: {name.quoted} level: Creature {level} -{#if alignment} -alignment: {alignment} -{/if}{#if rarity} -rarity: {rarity} -{/if}{#if size} -size: {size} -{/if}{#if traits} +{#with traits.getFirst("Alignment")} +alignment: {withoutTitle.quoted} +{/with}{#with traits.getFirst("Rarity")} +rarity: {withoutTitle.quoted} +{/with}{#with traits.getFirst("Size")} +size: {withoutTitle.quoted} +{/with}{#with traits.genericTraits} traits: - {#each traits} - {! Don't include traits which are already included above by the statblock layout !} - {#if !it.title || !(it.title.contains("Alignment Trait") || it.title.contains("Size Trait") || it.title.contains("Rarity Trait"))} - - "{it.withoutTitle}" - {/if} + {#each this} + - {it.withoutTitle.quoted} {/each} -{/if} +{/with} {#if perception} modifier: {perception} diff --git a/src/main/java/dev/ebullient/convert/tools/pf2e/Json2QuteBase.java b/src/main/java/dev/ebullient/convert/tools/pf2e/Json2QuteBase.java index f8972d50b..7fe17696f 100644 --- a/src/main/java/dev/ebullient/convert/tools/pf2e/Json2QuteBase.java +++ b/src/main/java/dev/ebullient/convert/tools/pf2e/Json2QuteBase.java @@ -2,13 +2,12 @@ import java.util.ArrayList; import java.util.List; -import java.util.Set; import com.fasterxml.jackson.databind.JsonNode; import dev.ebullient.convert.tools.Tags; import dev.ebullient.convert.tools.pf2e.qute.Pf2eQuteBase; import dev.ebullient.convert.tools.pf2e.qute.Pf2eQuteNote; -import dev.ebullient.convert.tools.pf2e.qute.QuteDataRef; +import dev.ebullient.convert.tools.pf2e.qute.QuteDataTraits; public abstract class Json2QuteBase implements JsonSource { protected final Pf2eIndex index; @@ -16,7 +15,7 @@ public abstract class Json2QuteBase implements JsonSource { protected final JsonNode rootNode; protected final Pf2eSources sources; protected final Tags tags; - protected final Set traits; + protected final QuteDataTraits traits; protected final List entries; public Json2QuteBase(Pf2eIndex index, Pf2eIndexType type, JsonNode rootNode) { @@ -29,7 +28,7 @@ public Json2QuteBase(Pf2eIndex index, Pf2eIndexType type, JsonNode rootNode, Pf2 this.rootNode = rootNode; this.sources = sources; this.tags = new Tags(sources); - this.traits = collectTraitsFrom(rootNode, tags); + this.traits = getTraits(rootNode).addToTags(tags); this.entries = new ArrayList<>(SourceField.entries.transformListFrom(rootNode, this, "##")); } diff --git a/src/main/java/dev/ebullient/convert/tools/pf2e/Json2QuteDeity.java b/src/main/java/dev/ebullient/convert/tools/pf2e/Json2QuteDeity.java index 24a2adbff..5a3d4c3c3 100644 --- a/src/main/java/dev/ebullient/convert/tools/pf2e/Json2QuteDeity.java +++ b/src/main/java/dev/ebullient/convert/tools/pf2e/Json2QuteDeity.java @@ -6,7 +6,6 @@ import static dev.ebullient.convert.StringUtil.toOrdinal; import static dev.ebullient.convert.StringUtil.toTitleCase; -import java.util.Collection; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -19,7 +18,6 @@ import dev.ebullient.convert.qute.NamedText; import dev.ebullient.convert.tools.pf2e.Pf2eJsonNodeReader.Pf2eAttack; import dev.ebullient.convert.tools.pf2e.qute.QuteDataActivity.Activity; -import dev.ebullient.convert.tools.pf2e.qute.QuteDataRef; import dev.ebullient.convert.tools.pf2e.qute.QuteDeity; import dev.ebullient.convert.tools.pf2e.qute.QuteInlineAttack; import dev.ebullient.convert.tools.pf2e.qute.QuteInlineAttack.AttackRangeType; @@ -154,10 +152,6 @@ private NamedText buildAvatarAbility(JsonNode abilityNode) { } private QuteInlineAttack buildAvatarAttack(JsonNode actionNode, AttackRangeType rangeType) { - Collection traits = collectTraitsFrom(actionNode, tags); - Pf2eDeity.preciousMetal.getListOfStrings(actionNode, tui()).stream().map(QuteDataRef::new).forEach(traits::add); - Pf2eDeity.traitNote.getTextFrom(actionNode).map(QuteDataRef::new).ifPresent(traits::add); - return new QuteInlineAttack( Pf2eAttack.name.getTextOrDefault(actionNode, "attack"), Pf2eActivity.toQuteActivity(this, Activity.single, null), @@ -167,7 +161,9 @@ private QuteInlineAttack buildAvatarAttack(JsonNode actionNode, AttackRangeType .map(field -> field.getTextOrEmpty(actionNode)) .filter(StringUtil::isPresent) .toList(), - traits, + getTraits(actionNode).addToTags(tags) + .addTraits(Pf2eDeity.preciousMetal.getListOfStrings(actionNode, tui())) + .addTrait(Pf2eDeity.traitNote.getTextOrEmpty(actionNode)), Pf2eDeity.note.replaceTextFrom(actionNode, this), this); } diff --git a/src/main/java/dev/ebullient/convert/tools/pf2e/Json2QuteItem.java b/src/main/java/dev/ebullient/convert/tools/pf2e/Json2QuteItem.java index f4a2c09a1..6cec20b81 100644 --- a/src/main/java/dev/ebullient/convert/tools/pf2e/Json2QuteItem.java +++ b/src/main/java/dev/ebullient/convert/tools/pf2e/Json2QuteItem.java @@ -318,7 +318,7 @@ public static QuteItemWeaponData buildWeaponData(JsonNode source, JsonSource convert, Tags tags) { QuteItemWeaponData weaponData = new QuteItemWeaponData(); - weaponData.traits = convert.collectTraitsFrom(source, tags); + weaponData.traits = convert.getTraits(source).addToTags(tags); weaponData.type = SourceField.type.getTextOrEmpty(source); weaponData.damage = getDamageString(source, convert); diff --git a/src/main/java/dev/ebullient/convert/tools/pf2e/JsonSource.java b/src/main/java/dev/ebullient/convert/tools/pf2e/JsonSource.java index baf2a9b3d..0910764c9 100644 --- a/src/main/java/dev/ebullient/convert/tools/pf2e/JsonSource.java +++ b/src/main/java/dev/ebullient/convert/tools/pf2e/JsonSource.java @@ -3,7 +3,6 @@ import static dev.ebullient.convert.StringUtil.join; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.stream.Collectors; import com.fasterxml.jackson.databind.JsonNode; @@ -13,11 +12,9 @@ import dev.ebullient.convert.io.Tui; import dev.ebullient.convert.qute.QuteUtil; import dev.ebullient.convert.tools.JsonNodeReader.FieldValue; -import dev.ebullient.convert.tools.Tags; import dev.ebullient.convert.tools.pf2e.Json2QuteItem.Pf2eItem; import dev.ebullient.convert.tools.pf2e.qute.Pf2eQuteBase; import dev.ebullient.convert.tools.pf2e.qute.QuteDataActivity; -import dev.ebullient.convert.tools.pf2e.qute.QuteDataRef; public interface JsonSource extends JsonTextReplacement { @@ -584,9 +581,7 @@ default List embedGenericData(String tag, JsonNode data) { text.add("title: " + title); // Add traits - Tags tags = new Tags(); - Collection traits = collectTraitsFrom(data, tags); - text.add(join(" ", traits) + " "); + text.add(join(" ", getTraits(data)) + " "); maybeAddBlankLine(text); // Add rendered sections diff --git a/src/main/java/dev/ebullient/convert/tools/pf2e/JsonTextReplacement.java b/src/main/java/dev/ebullient/convert/tools/pf2e/JsonTextReplacement.java index 02a8397e8..5b7ddcf8f 100644 --- a/src/main/java/dev/ebullient/convert/tools/pf2e/JsonTextReplacement.java +++ b/src/main/java/dev/ebullient/convert/tools/pf2e/JsonTextReplacement.java @@ -6,11 +6,9 @@ import java.util.ArrayList; import java.util.List; -import java.util.Set; -import java.util.TreeSet; import java.util.regex.MatchResult; import java.util.regex.Pattern; -import java.util.stream.Collectors; +import java.util.stream.Collector; import com.fasterxml.jackson.databind.JsonNode; import dev.ebullient.convert.config.CompendiumConfig; @@ -18,9 +16,9 @@ import dev.ebullient.convert.tools.JsonNodeReader; import dev.ebullient.convert.tools.JsonNodeReader.FieldValue; import dev.ebullient.convert.tools.JsonTextConverter; -import dev.ebullient.convert.tools.Tags; import dev.ebullient.convert.tools.pf2e.qute.QuteDataActivity.Activity; import dev.ebullient.convert.tools.pf2e.qute.QuteDataRef; +import dev.ebullient.convert.tools.pf2e.qute.QuteDataTraits; public interface JsonTextReplacement extends JsonTextConverter { enum Field implements Pf2eJsonNodeReader { @@ -219,17 +217,15 @@ default String replaceActionAs(MatchResult match) { /** * Collect and linkify traits from the specified node. * - * @param tags The tags to populate while collecting traits. If null, then don't populate any tags. - * - * @return a set of {@link QuteDataRef}s to trait notes, or an empty set (never null) + * @return a {@link QuteDataTraits} which may be empty (never null) */ - default Set collectTraitsFrom(JsonNode sourceNode, Tags tags) { + default QuteDataTraits getTraits(JsonNode sourceNode) { return Field.traits.getListOfStrings(sourceNode, tui()).stream() - .peek(tags == null ? (t -> {}) : t -> tags.add("trait", t)) - .sorted() - .map(s -> linkify(Pf2eIndexType.trait, s)) - .map(QuteDataRef::fromMarkdownLink) - .collect(Collectors.toCollection(TreeSet::new)); + .map(s -> QuteDataRef.fromMarkdownLink(linkify(Pf2eIndexType.trait, s))) + .collect(Collector.of(QuteDataTraits::new, QuteDataTraits::add, (a, b) -> { + a.addAll(b); + return b; + })); } default String linkifyRuneItem(MatchResult match) { @@ -373,6 +369,8 @@ default String linkifyTrait(String match) { default String linkifyTrait(JsonNode traitNode, String linkText) { if (traitNode != null) { String source = SourceField.source.getTextOrEmpty(traitNode); + // Some traits are surrounded in square brackets. Strip this out to avoid messing up link rendering. + linkText = linkText.replaceFirst("^\\[(.*)]$", "$1"); return "[%s](%s/%s%s.md \"%s\")".formatted( linkText, diff --git a/src/main/java/dev/ebullient/convert/tools/pf2e/Pf2eJsonNodeReader.java b/src/main/java/dev/ebullient/convert/tools/pf2e/Pf2eJsonNodeReader.java index 9b570903e..c082aaa17 100644 --- a/src/main/java/dev/ebullient/convert/tools/pf2e/Pf2eJsonNodeReader.java +++ b/src/main/java/dev/ebullient/convert/tools/pf2e/Pf2eJsonNodeReader.java @@ -7,11 +7,11 @@ import static java.util.Objects.requireNonNullElse; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.Set; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collector; @@ -95,7 +95,7 @@ default List getAttacksFrom(JsonNode source, JsonSource conver * traits from these activation components to {@code traits}. Return an empty list if we couldn't get activation * components. */ - default List getActivationComponentsFrom(JsonNode source, Set traits, JsonSource convert) { + default List getActivationComponentsFrom(JsonNode source, Collection traits, JsonSource convert) { List rawComponents = getListOfStrings(source, convert.tui()).stream() .map(s -> s.replaceFirst("^\\((%s)\\)$", "\1")) // remove parens .toList(); @@ -655,7 +655,7 @@ public static QuteInlineAttack getAttack(JsonNode node, JsonSource convert) { attack.getIntFrom(node).orElse(null), formattedDamage, types.replaceTextFromList(node, convert), - convert.collectTraitsFrom(node, null), + convert.getTraits(node), hasMultilineEffect ? List.of() : attackEffects, hasMultilineEffect ? String.join("\n", attackEffects) : null, noMAP.booleanOrDefault(node, false) ? List.of() : List.of("no multiple attack penalty"), diff --git a/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteCreature.java b/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteCreature.java index ddc484fee..f51a5817a 100644 --- a/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteCreature.java +++ b/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteCreature.java @@ -95,27 +95,6 @@ public QuteCreature( this.ritualCasting = ritualCasting; } - /** Return the size of this creature, or null if it has none. */ - public String getSize() { - return traits.stream() - .filter(ref -> ref.title() != null && ref.title().contains("Size Trait")) - .findAny().map(QuteDataRef::displayText).orElse(null); - } - - /** The alignment of this creature, or null if it has none. */ - public String getAlignment() { - return traits.stream() - .filter(ref -> ref.title() != null && ref.title().contains("Alignment Trait")) - .findAny().map(QuteDataRef::displayText).orElse(null); - } - - /** The rarity of this creature, or null if it has none. */ - public String getRarity() { - return traits.stream() - .filter(ref -> ref.title() != null && ref.title().contains("Rarity Trait")) - .findAny().map(QuteDataRef::displayText).orElse(null); - } - /** * The languages and language features known by a creature. Example default output: * diff --git a/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteDataRef.java b/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteDataRef.java index d7cd43c83..d689a82b7 100644 --- a/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteDataRef.java +++ b/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteDataRef.java @@ -16,7 +16,7 @@ */ public record QuteDataRef(String displayText, String notePath, String title) implements Comparable { - private static final Pattern MARKDOWN_LINK_PAT = Pattern.compile("^\\[(?[^]]+)]\\((?.*?)(?: \"(?.*)\")?\\)$"); + private static final Pattern MARKDOWN_LINK_PAT = Pattern.compile("^\\[(?<display>.+)]\\((?<path>.*?)(?: \"(?<title>.*)\")?\\)$"); public QuteDataRef(String displayText) { this(displayText, null, null); diff --git a/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteDataTraits.java b/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteDataTraits.java new file mode 100644 index 000000000..9ef5d84dd --- /dev/null +++ b/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteDataTraits.java @@ -0,0 +1,142 @@ +package dev.ebullient.convert.tools.pf2e.qute; + +import static dev.ebullient.convert.StringUtil.isPresent; +import static dev.ebullient.convert.StringUtil.join; +import static dev.ebullient.convert.StringUtil.joiningNonEmpty; + +import java.util.Collection; +import java.util.Iterator; +import java.util.Optional; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; + +import dev.ebullient.convert.tools.Tags; + +/** A collection of traits stored as {@link QuteDataRef}s to the trait note. */ +public class QuteDataTraits implements Collection<QuteDataRef> { + private final Set<QuteDataRef> refs = new TreeSet<>(); + + public QuteDataTraits() {} + + /** The first trait which has this category, as a {@link QuteDataRef}. Case-sensitive. */ + public QuteDataRef getFirst(String category) { + return refs.stream().filter(ref -> ref.title() != null && ref.title().contains(category)).findFirst().orElse(null); + } + + /** Return these traits as a comma-delimited string without any extra formatting (eg no title attributes). */ + public String formattedWithoutTitles() { + return refs.stream().map(QuteDataRef::withoutTitle).collect(joiningNonEmpty(", ")); + } + + /** Return traits without any size, alignment, or rarity traits. */ + public QuteDataTraits getGenericTraits() { + return refs.stream() + .filter(ref -> !isPresent(ref.title()) + || ref.title().contains("Alignment") || ref.title().contains("Size") || ref.title().contains("Rarity")) + .collect(Collectors.toCollection(QuteDataTraits::new)); + } + + public QuteDataTraits addToTags(Tags tags) { + for (QuteDataRef ref : this) { + tags.add("trait", ref.displayText()); + } + return this; + } + + public QuteDataTraits addTrait(String trait) { + if (isPresent(trait)) { + refs.add(new QuteDataRef(trait)); + } + return this; + } + + public QuteDataTraits addTraits(Collection<String> c) { + c.forEach(this::addTrait); + return this; + } + + @Override + public String toString() { + return join(", ", refs); + } + + @Override + public int size() { + return refs.size(); + } + + @Override + public boolean isEmpty() { + return refs.isEmpty(); + } + + @Override + public boolean contains(Object o) { + if (o instanceof QuteDataRef) { + return refs.contains(o); + } else if (o instanceof String) { + return refs.stream().anyMatch(ref -> ref.displayText().equals(o)); + } + return false; + } + + @Override + public boolean remove(Object o) { + if (o instanceof QuteDataRef) { + return refs.remove(o); + } else if (o instanceof String) { + Optional<QuteDataRef> ref = refs.stream().filter(r -> r.displayText().equals(o)).findAny(); + if (ref.isEmpty()) { + return false; + } + return refs.remove(ref); + } + return false; + } + + @Override + public boolean add(QuteDataRef quteDataRef) { + return refs.add(quteDataRef); + } + + @Override + public Iterator<QuteDataRef> iterator() { + return refs.iterator(); + } + + @Override + public Object[] toArray() { + return refs.toArray(); + } + + @Override + public <T> T[] toArray(T[] a) { + return refs.toArray(a); + } + + @Override + public boolean containsAll(Collection<?> c) { + return c.stream().allMatch(this::contains); + } + + @Override + public boolean addAll(Collection<? extends QuteDataRef> c) { + return c.stream().allMatch(this::add); + } + + @Override + public boolean removeAll(Collection<?> c) { + return c.stream().allMatch(this::remove); + } + + @Override + public boolean retainAll(Collection<?> c) { + return refs.removeIf(ref -> !c.contains(ref) && !c.contains(ref.displayText())); + } + + @Override + public void clear() { + refs.clear(); + } +} diff --git a/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteInlineAttack.java b/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteInlineAttack.java index bc26ff048..22321e741 100644 --- a/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteInlineAttack.java +++ b/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteInlineAttack.java @@ -1,7 +1,5 @@ package dev.ebullient.convert.tools.pf2e.qute; -import static dev.ebullient.convert.StringUtil.join; -import static dev.ebullient.convert.StringUtil.parenthesize; import static dev.ebullient.convert.StringUtil.toTitleCase; import java.util.Collection; @@ -48,8 +46,8 @@ public final class QuteInlineAttack implements QuteDataGenericStat, QuteUtil.Ren */ public final Collection<String> damageTypes; - /** Any traits associated with the attack (collection of {@link QuteDataRef}) */ - public final Collection<QuteDataRef> traits; + /** Traits associated with the attack as a {@link QuteDataTraits} */ + public final QuteDataTraits traits; /** * Any additional effects associated with the attack e.g. grab (list of strings). Effects listed here @@ -68,7 +66,7 @@ public final class QuteInlineAttack implements QuteDataGenericStat, QuteUtil.Ren public QuteInlineAttack( String name, QuteDataActivity activity, AttackRangeType rangeType, Integer attackBonus, String damage, - Collection<String> damageTypes, Collection<QuteDataRef> traits, List<String> effects, String multilineEffect, + Collection<String> damageTypes, QuteDataTraits traits, List<String> effects, String multilineEffect, List<String> notes, JsonTextConverter<?> converter) { this.name = name; this.activity = activity; @@ -85,7 +83,7 @@ public QuteInlineAttack( public QuteInlineAttack( String name, QuteDataActivity activity, AttackRangeType rangeType, String damage, - Collection<String> damageTypes, Collection<QuteDataRef> traits, String note, + Collection<String> damageTypes, QuteDataTraits traits, String note, JsonTextConverter<?> converter) { this( name, activity, rangeType, null, @@ -118,11 +116,6 @@ public String toString() { return render(); } - /** Return traits formatted as a single string, e.g. {@code (agile, trip, finesse)} */ - public String formattedTraits() { - return parenthesize(join(", ", traits)); - } - public enum AttackRangeType { RANGED, MELEE; diff --git a/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteItem.java b/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteItem.java index 474194291..0c1922f8b 100644 --- a/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteItem.java +++ b/src/main/java/dev/ebullient/convert/tools/pf2e/qute/QuteItem.java @@ -234,8 +234,8 @@ public String toString() { public static class QuteItemWeaponData implements QuteUtil { /** Formatted string. Weapon type */ public String type; - /** Formatted string. List of traits ({@link QuteDataRef}) */ - public Collection<QuteDataRef> traits; + /** Traits as a {@link QuteDataTraits} */ + public QuteDataTraits traits; public Collection<NamedText> ranged; public String damage; public String group; diff --git a/src/main/resources/templates/toolsPf2e/inline-ability2md.txt b/src/main/resources/templates/toolsPf2e/inline-ability2md.txt index 3511ebbb0..6b6fc97dc 100644 --- a/src/main/resources/templates/toolsPf2e/inline-ability2md.txt +++ b/src/main/resources/templates/toolsPf2e/inline-ability2md.txt @@ -1,5 +1,5 @@ {#with resource} -{#let componentsTraits = (components.join(", ") + (components && traits ? " " : "") + (traits ? (str:format("(%s)", bareTraitList)) : ""))} +{#let componentsTraits = (components.join(", ") + (components && traits ? " " : "") + (traits ? (str:format("(%s)", traits.formattedWithoutTitles)) : ""))} {#if asYamlStatblock} - name: {reference.or(name).quoted} {#if hasDetails && hasAttributes} diff --git a/src/main/resources/templates/toolsPf2e/inline-attack2md.txt b/src/main/resources/templates/toolsPf2e/inline-attack2md.txt index c060d2897..394c8c817 100644 --- a/src/main/resources/templates/toolsPf2e/inline-attack2md.txt +++ b/src/main/resources/templates/toolsPf2e/inline-attack2md.txt @@ -2,7 +2,7 @@ {#if asYamlStatblock} - name: ___{rangeType}___ {activity.unicodeGlyphOrText} {name} {#if traits} - desc: ({#each traits}{it.withoutTitle}{#if it_hasNext}, {/if}{/each}) + desc: ({traits.formattedWithoutTitles}) {/if} bonus: {attackBonus} {#if multilineEffect} @@ -14,7 +14,7 @@ {#else} {#if multilineEffect} ```ad-inline-attack -title: {rangeType} {activity} {name.capitalized}{bonus.prefixSpace}{formattedTraits.prefixSpace} +title: {rangeType} {activity} {name.capitalized}{bonus.prefixSpace}{#if traits} ({traits}){/if} {#if damage} **Damage** {damage} {/if}{#if multilineEffect} @@ -22,7 +22,7 @@ title: {rangeType} {activity} {name.capitalized}{bonus.prefixSpace}{formattedTra {/if} ``` {#else} -- **{rangeType}** {activity} {name}{bonus.prefixSpace}{formattedTraits.prefixSpace}{#if damage}, **Damage** {damage}{/if} +- **{rangeType}** {activity} {name}{bonus.prefixSpace}{#if traits} ({traits}){/if}{#if damage}, **Damage** {damage}{/if} {/if} {/if} {/with}