Dmytro-Shulha / obsidian-plotly

Obsidian plugin to embed Plotly charts into markdown notes.
MIT License
70 stars 4 forks source link

Math support #10

Closed Zottelchen closed 1 year ago

Zottelchen commented 2 years ago

How can I enable math support? Currently, the graph does just not render when text contains latex notation. The Obsidian console shows: image

The chart-studio.plotly.com -Export contains the following section:

<script type="text/javascript">
    window.MathJax = {
        root: 'mathjax',
        config: 'TeX-AMS-MML_SVG.js',
        extensions: ['Safe.js']
    };
</script>
<script type="text/javascript" src="mathjax/MathJax.js"></script>

I am not certain how Obsidian handles math, maybe there is another/a better way.

Sample Graph (click to open) ```javascript let path = app.vault.adapter.basePath;//absolute path to your vault var d3 = require(path+"\\Attachments\\d3.v7.min.js"); var data = [ { "mode": "markers", "type": "scatter", "x": [ "0" ], "y": [ "0" ] } ]; var layout = { "title": { "text": "$Division: \\frac{z1}{z2}$" }, "xaxis": { "type": "linear", "range": [ -0.03357993312190732, 0.601359413680969 ], "title": { "text": "$\\text{Re} z$" }, }, "yaxis": { "type": "linear", "range": [ -0.03635300993571011, 0.002220923436586791 ], "title": { "text": "$i \\text{Im} z$" }, }, "annotations": [ { "x": 0.5862068965517241, "y": -0.034482758620689655, "ax": 0, "ay": 0, "font": { "size": 12, "family": "Arial" }, "text": "", "xref": "x", "yref": "y", "align": "center", "axref": "x", "ayref": "y", "xanchor": "left", "yanchor": "bottom", "arrowhead": 2, "arrowsize": 1.5, "showarrow": true, "arrowcolor": "rgb(51, 129, 228)", "arrowwidth": 2 }, { "x": 0.5862068965517241, "y": -0.034482758620689655, "text": "$\\frac{34}{58}+\\frac{-2}{58}i$", "yanchor": "top", "showarrow": false } ] }; var config = {staticPlot: true}; window.renderPlotly(this.container, data, layout, config) ```