Skip to content

🐞 Empty fields result in extra commas in monster statblocks 5e #491

@SamBardwell

Description

@SamBardwell

Check for existing bug reports before submitting.

  • I searched for existing Bug Reports and found no similar reports.

Expected Behavior

When using template monsters, the commas should be ommited if there are empty fields. For example,

source: 5e SRD
size: Small
type: beast
subtype: "" <--- this should not be rendered in the list, and should be ommited
alignment: unaligned
... omitted the rest of the code as it does not pertain to the issue

This should have rendered like the example in the Bestiary page. Like below,

Image

However, it does not, at least I cannot figure out if their is a custom command I need to put in order to omit these commas.

Current behaviour

Empty fields result in extra commas in monster statblocks, example below when viewing "Octopus".

Image

In bestiary section of the website, the documentation points out that the octopus will look like this,

Image

However, when using the plugin, it does not.

Reproduction

There are two ways you can reproduce this,

  1. Go to the Plugin settings and view any monster that has a missing field, in my example I used Octopus. You can view what this will look like and see the extra commas.
  2. Import the preset monster in a note through the presented documentation in the Bestiary site. Example below,
Image Image

Which Operating Systems are you using?

  • Android
  • iPhone/iPad
  • Linux
  • macOS
  • Windows

Obsidian Version Check

1.8.10

Plugin Version

4.9.1

Confirmation

  • I have disabled all other plugins and the issue still persists.

Possible solution

I am not sure what under the hood looks like for this yet. Or if maybe I am just having a weird quirk. But I think you could do something like this,

let properties = [monster.size, monster.type, monster.alignment];
let filtered = properties.filter(prop => prop && prop.trim() !== "");
let output = filtered.join(", ");

Where you can filter out empty or whitespace only properties before joining them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions