Enveloppe / obsidian-enveloppe

Enveloppe helps you to publish your notes on a GitHub repository from your Obsidian Vault, for free!
https://enveloppe.github.io/
Apache License 2.0
618 stars 38 forks source link

[BUG]: [Dataview] Math rendering #227

Closed mclearc closed 11 months ago

mclearc commented 11 months ago

Issue validation

Command used

Refresh published and upload new notes

Plugin version

6.7.3

Describe the bug

I seem to be unable to render inline math. Here's an example:

>[!infobox|left]  
>![[er_dhampir-portrait_4.png|vh-sm]]
>###### Stats
> > -  :fas_dice_d20: \+`$= Math.floor((dv.current().dexterity -10) / 2)` ⋅ :fas_running: `=this.speed`ft
> > - :rif_shield_star: `=this.ac` ⋅ :fas_heart: `=this.hp`
> > - :fas_eye: `=this.perception` ⋅ :rif_spy: `=this.stealth`
> >
> > | Ability      | Score                | Mod                                        |
> > |--------------|----------------------|--------------------------------------------|
> > | Strength     | `=this.strength`     | `$= Math.floor((dv.current().strength -10) / 2)`     |
> > | Dexterity    | `=this.dexterity`    | `$= Math.floor((dv.current().dexterity -10) / 2)`    |
> > | Constitution | `=this.constitution` | `$= Math.floor((dv.current().constitution -10) / 2)` |
> > | Intelligence | `=this.intelligence` | `$= Math.floor((dv.current().intelligence -10) / 2)` |
> > | Wisdom       | `=this.wisdom`       | `$= Math.floor((dv.current().wisdom -10) / 2)`       |
> > | Charisma     | `=this.charisma`     | `$= Math.floor((dv.current().charisma -10) / 2)`     |

The inline =this.ability renders fine, but the math does not. In this case, since the "Mod" table is thus valueless, it doesn't even render in the final result.

How to reproduce ?

try and do some inline math...

Minimal Reproducible Example

Here's the entire note:

---
share: true
tags:
  - erspace/ermis
type: pc
linter-yaml-title-alias: "**`=this.file.name`**"
art: "![[er_dhampir-portrait_5.png|75]]"
player: Griffin
name: Stigs the Stiff
aliases:
  - "**`=this.file.name`**"
class: Artificer
subclass: 
level: 1
background: Shipwright
alignment: 
strength: 12
dexterity: 17
constitution: 15 
intelligence: 18
wisdom: 12
charisma: 10
perception: 13
stealth: 15
hd: 1d8
hp: 12
ac: 15
pb: +2
speed: 35 
condition: Healthy
action: 
skill-proficiencies: Arcana, History, Investigation, Perception, Sleight of Hand, Stealth 
save-proficiencies: Constitution, Intelligence
languages: Common
overview: A shipwright for House Ororos
traits: 
ideals: 
bonds: 
flaws: 
pronouns: 
pronounced: 
ancestry: Dhampir
gender: 
age: 
sexuality: 
height: 
weight: 
location: 
occupation: Shipwright
friends-family: [House Ororos]
rivals: 
associatedGroup: House Ororos
associatedReligion: Er
date created: Saturday, September 23rd 2023, 7:45:19 pm
date modified: Monday, October 2nd 2023, 1:06:28 pm
---

>[!infobox|left]  
>![[er_dhampir-portrait_4.png|vh-sm]]
>###### Stats
> > -  :fas_dice_d20: \+`$= Math.floor((dv.current().dexterity -10) / 2)` ⋅ :fas_running: `=this.speed`ft
> > - :rif_shield_star: `=this.ac` ⋅ :fas_heart: `=this.hp`
> > - :fas_eye: `=this.perception` ⋅ :rif_spy: `=this.stealth`
> >
> > | Ability      | Score                | Mod                                        |
> > |--------------|----------------------|--------------------------------------------|
> > | Strength     | `=this.strength`     | `$= Math.floor((dv.current().strength -10) / 2)`     |
> > | Dexterity    | `=this.dexterity`    | `$= Math.floor((dv.current().dexterity -10) / 2)`    |
> > | Constitution | `=this.constitution` | `$= Math.floor((dv.current().constitution -10) / 2)` |
> > | Intelligence | `=this.intelligence` | `$= Math.floor((dv.current().intelligence -10) / 2)` |
> > | Wisdom       | `=this.wisdom`       | `$= Math.floor((dv.current().wisdom -10) / 2)`       |
> > | Charisma     | `=this.charisma`     | `$= Math.floor((dv.current().charisma -10) / 2)`     |
> > ||||
> >  - **Skill Proficiencies:** `=this.skill-proficiencies`
> >  - **Save Proficiencies:** `=this.save-proficiencies`
> >  - **Default Action:** `=this.action`
> >  -  **Condition:** `=this.condition`

# **`=this.file.name`**
>[!info|bg-c-purple]- Overview
> - `=this.overview`

>[!column|clean no-title] Characteristics
>> [!metadata|bg-c-blue]+ Traits
>> - `=this.traits`
>
>> [!metadata|bg-c-blue]+ Ideals, Bonds, & Flaws
>> -  `=this.ideals`
>> -  `=this.bonds`
>> -  `=this.flaws`

>[!column|flex 3 clean no-title]
>> [!info|bg-c-gray]+ Bio
>> - **Alias(es):** `=this.aliases` 
>> - **Age:**  `=this.age` 
>> - **Sex:**  `=this.gender` 
>> - **Sexuality:**  `=this.sexuality` 
>> - **Height:**  `=this.height` 
>> - **Weight:**  `=this.weight` 
>> - **Occupation(s):**  `=this.occupation` 
>> - **Group(s):**  `=link(this.associatedGroup)` 
>> - **Religion(s):**  `=link(this.associatedReligion)` 
>
>> [!info|bg-c-gray]+ Other Info 
>> - **Ancestry:**  `=this.ancestry`
>> - **Background:** `=this.background`
>> - **Class:** `=this.class`
>> - **Level:** `=this.level`
>> - **Alignment:** `=this.alignment`
>> - **Current Location:**  `=link(this.location)` 

## Relationships
>[!column|dataview|clean no-title] Relationships
>> [!metadata|bg-c-green]- Friends & Family
>> - `=this.friends-family`
>
>> [!metadata|bg-c-orange]- Rivals
>> - `=this.rivals`

## Biographical Details

Configuration

{
  "github": {
    "branch": "main",
    "automaticallyMergePR": true,
    "tokenPath": "%configDir%/plugins/%pluginID%/env",
    "api": {
      "tiersForApi": "Github Free/Pro/Team (default)",
      "hostname": ""
    },
    "workflow": {
      "commitMessage": "Merge",
      "name": ""
    },
    "verifiedRepo": true
  },
  "upload": {
    "behavior": "obsidian",
    "defaultName": "docs",
    "rootFolder": "",
    "yamlFolderKey": "",
    "frontmatterTitle": {
      "enable": false,
      "key": "title"
    },
    "replaceTitle": [],
    "replacePath": [],
    "autoclean": {
      "enable": true,
      "excluded": [
        "docs/assets/js",
        "docs/assets/meta",
        "docs/assets/css",
        "tags.md",
        "graph.md"
      ]
    },
    "folderNote": {
      "enable": true,
      "rename": "index.md"
    },
    "metadataExtractorPath": ""
  },
  "conversion": {
    "hardbreak": false,
    "dataview": true,
    "censorText": [],
    "tags": {
      "inline": false,
      "exclude": [],
      "fields": []
    },
    "links": {
      "internal": true,
      "unshared": false,
      "wiki": false,
      "slugify": false
    }
  },
  "embed": {
    "attachments": true,
    "keySendFile": [],
    "notes": false,
    "folder": "docs/assets/img",
    "convertEmbedToLinks": "keep",
    "charConvert": "->"
  }
}

Relevant log output

No errors in log output

OS

MacOS

Anything else?

Here's the displayed site: https://lichfactory.com/adventures/ad%20astra/the%20party/stigs%20the%20stiff/

Obsidian information

SYSTEM INFO:
    Obsidian version: v1.4.14
    Installer version: v1.4.13
    Operating system: Darwin Kernel Version 22.6.0: Fri Sep 15 13:41:28 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_ARM64_T6020 22.6.0
    Login status: not logged in
    Insider build toggle: off
    Live preview: off
    Legacy editor: off
    Base theme: adapt to system
    Community theme: Ebullientworks v0.7.15
    Snippets enabled: 11
    Restricted mode: off
    Plugins installed: 58
    Plugins enabled: 54
        1: Style Settings v1.0.7
        2: Auto Note Mover v1.2.0
        3: Admonition v10.1.1
        4: Advanced Tables v0.19.1
        5: Dataview v0.5.59
        6: Dice Roller v9.4.1
        7: Excel to Markdown Table v0.4.0
        8: Image Toolkit v1.4.0
        9: Kanban v1.5.3
        10: Media Extended v2.11.1
        11: Obsidian Leaflet v5.7.3
        12: Pane Relief v0.5.1
        13: Table Extended v1.6.1
        14: Text Format v2.2.8
        15: Timelines v0.3.2
        16: Second Window v1.1.0
        17: Various Complements v9.0.0
        18: JSON/CSV Importer v0.31.2
        19: DB Folder v3.5.0
        20: Org Mode v1.3.3
        21: Annotator v0.2.10
        22: Webpage HTML Export v1.7.3
        23: Quick Switcher++ v3.3.7
        24: Buttons v0.4.19
        25: Folder notes v1.5.13
        26: Text Generator v0.3.20
        27: Fantasy Content Generator v1.2.2
        28: Force note view mode v1.2.0
        29: Hover External Link Plugin v1.0.0
        30: Linter v1.20.0
        31: Breadcrumbs v3.6.4
        32: Hover Editor v0.11.14
        33: Multi-Column Markdown v0.8.3
        34: Note Auto Creator v1.4.0
        35: Link with alias v1.0.7
        36: Better Word Count v0.10.0
        37: Custom Frames v2.4.6
        38: Settings Search v1.3.8
        39: Obsidian42 - BRAT v0.7.0
        40: Text Mapper v1.0.0
        41: Export Image plugin v1.0.3
        42: Mousewheel Image zoom v1.0.19
        43: Fantasy name generator v0.1.0
        44: Tag Wrangler v0.5.13
        45: Pandoc Plugin v0.4.1
        46: Icon Shortcodes v0.9.7
        47: Templater v1.16.1
        48: Excalidraw v1.9.20
        49: Fantasy Statblocks v3.13.4
        50: Initiative Tracker v12.2.6
        51: Iconize v2.3.1
        52: Github Publisher v6.7.3
        53: Meta Bind Plugin v0.6.5
        54: Calendarium v1.0.0-b29

RECOMMENDATIONS:
    Custom theme and snippets: for cosmetic issues, please first try updating your theme and disabling your snippets. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community theme and snippets.
    Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.
Mara-Li commented 11 months ago

Maybe it's a limitation of the dataview API :/

mclearc commented 11 months ago

Yes it certainly could be -- though it's hard for me to tell why some aspects of dataview render fine and some don't.

Mara-Li commented 11 months ago

I tried to check but sadly, impossible to come to a conclusion. To be honest, seems to be a problem around the dv Api…

Mara-Li commented 11 months ago

Well, keep the issue open but we need to open a issue on obsidian-dataview to ask about the problem.

Little question : are the other $= function work ? (outside Math.floor)

EDIT : Seems dataviewJS doesn't work in inline. The same queries work with code blocks

Mara-Li commented 11 months ago

Okay, think I found a temporary solution

mclearc commented 11 months ago

Looks great!