Skip to content

Commit

Permalink
Merge pull request #14 from DylanHojnoski/mathjax
Browse files Browse the repository at this point in the history
Mathjax
  • Loading branch information
DylanHojnoski authored Mar 12, 2024
2 parents ddda8fe + 9bae496 commit 7ae8304
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
24 changes: 17 additions & 7 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { loadMathJax, Plugin } from 'obsidian';
import { Board, boards, JSXGraph } from 'jsxgraph';
import { Plugin } from 'obsidian';
import { renderError } from 'src/error';
import { GraphInfo, JSXElement } from 'src/types';
import { addElement, createBoard, parseCodeBlock, setMathFunctions } from 'src/utils';
Expand All @@ -9,8 +9,20 @@ export default class ObsidianGraphs extends Plugin {
currentFileName: string;
count = 0;


async onload () {
await loadMathJax();

//@ts-ignore
if (typeof MathJax !== "undefined") {
//@ts-ignore
MathJax.config.tex.inlineMath = [["$", "$"]];
//@ts-ignore
MathJax.config.tex.processEscapes = true;
//@ts-ignore
MathJax.config.chtml.adaptiveCSS = false;
//@ts-ignore
await MathJax.startup.getComponents();
}

setMathFunctions();

Expand Down Expand Up @@ -44,11 +56,13 @@ export default class ObsidianGraphs extends Plugin {

// it is not in active files so delete
if (!active) {
//@ts-ignore
boards[key].containerObj.remove();
//@ts-ignore
JSXGraph.freeBoard(boards[key]);
}
}
})
});

this.registerMarkdownCodeBlockProcessor("graph", (source, element, context) => {

Expand Down Expand Up @@ -99,10 +113,7 @@ export default class ObsidianGraphs extends Plugin {
}
}
}

element.replaceWith(graphDiv);
});

}

onunload() {
Expand All @@ -116,5 +127,4 @@ export default class ObsidianGraphs extends Plugin {
div.remove();
}
}

}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "graphs",
"name": "Graphs",
"version": "1.4.1",
"version": "1.5.0",
"minAppVersion": "0.15.0",
"description": "Create interactive graphs by writing YAML",
"author": "Dylan Hojnoski",
Expand Down
9 changes: 9 additions & 0 deletions src/theme/obsidian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ JXG.themes['obsidian'] = {
ticks: {
strokeColor: textNormal,
highlightStrokeColor: textMuted,
label: {
useMathJax: false,
}
},
label: {
strokeColor: textNormal,
Expand Down Expand Up @@ -148,6 +151,9 @@ JXG.themes['obsidian'] = {
label: {
strokeColor: textNormal,
highlightStrokeColor: textMuted,
useMathJax: true,
display: "html",
parse: false,
},

line: {
Expand Down Expand Up @@ -299,6 +305,9 @@ JXG.themes['obsidian'] = {
text: {
strokeColor: textNormal,
highlightStrokeColor: textMuted,
useMathJax: true,
display: "html",
parse: false,
},

tracecurve: {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export type Attributes = {
highlightStrokeColor: string,
fillOpacity: number,
anchor: string | GeometryElement,
useMathJax: boolean,
}

export type Axis = {
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"1.3.3": "0.15.0",
"1.3.4": "0.15.0",
"1.4.0": "0.15.0",
"1.4.1": "0.15.0"
"1.4.1": "0.15.0",
"1.5.0": "0.15.0"
}

0 comments on commit 7ae8304

Please sign in to comment.