Skip to content

Commit

Permalink
Merge pull request #2228 from Sintuz/master
Browse files Browse the repository at this point in the history
Fixing a couple issues with LaTeX
  • Loading branch information
zsviczian authored Jan 25, 2025
2 parents 15ba414 + 9956fd1 commit ef785e5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions MathjaxToSVG/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ export async function tex2dataURL(
{ display: true, scale }
);
const svg = new DOMParser().parseFromString(adaptor.innerHTML(node), "image/svg+xml").firstChild as SVGSVGElement;

//https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2195
//https://stackoverflow.com/a/77181931
let styleNode = document.createElement('style');
styleNode.setAttribute("type", "text/css");
styleNode.appendChild(document.createTextNode(".mjx-solid { stroke-width: 80px; }"));
svg.appendChild(styleNode);

if (svg) {
if(svg.width.baseVal.valueInSpecifiedUnits < 2) {
svg.width.baseVal.valueAsString = `${(svg.width.baseVal.valueInSpecifiedUnits+1).toFixed(3)}ex`;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/ExcalidrawAutomate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ export class ExcalidrawAutomate {
Object.keys(this.imagesDict).forEach((key: FileId)=> {
const item = this.imagesDict[key];
if(item.latex) {
outString += `${key}: $$${item.latex}$$\n\n`;
outString += `${key}: $$${item.latex.trim()}$$\n\n`;
} else {
if(item.file) {
if(item.file instanceof TFile) {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/ExcalidrawData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,7 @@ export class ExcalidrawData {
: "";
if (this.equations.size > 0) {
for (const key of this.equations.keys()) {
outString += `${key}: $$${this.equations.get(key).latex}$$\n\n`;
outString += `${key}: $$${this.equations.get(key).latex.trim()}$$\n\n`;
}
}
if (this.files.size > 0) {
Expand Down

0 comments on commit ef785e5

Please sign in to comment.