jmilldotdev / obsidian-wikipedia

Grabs information from Wikipedia for a topic and brings it into Obsidian notes
MIT License
99 stars 16 forks source link

LaTeX formatting issues #9

Open JohnFNovak opened 2 years ago

JohnFNovak commented 2 years ago

I think that this issue is closely related to issue #4, but pages that have latex in them are returned with the formulas almost unreadable. Specifically, formulas are returned twice, once in a string representation with a lot of (seemingly) random spaces, and then in proper latex format but wrapped in {displaystyle <formula> }, instead of $<formula>$.

ex (note that github removes all the gnarly extra spaces):

In functional analysis and operator theory, a bounded linear operator is a linear transformation L : X → Y {\displaystyle L:X\to Y} between topological vector spaces (TVSs) X {\displaystyle X} and Y {\displaystyle Y} that maps bounded subsets of X {\displaystyle X} to bounded subsets of Y . {\displaystyle Y.} If X {\displaystyle X} and Y {\displaystyle Y} are normed vector spaces (a special type of TVS), then L {\displaystyle L} is bounded if and only if there exists some M > 0 {\displaystyle M>0} such that for all x ∈ X , {\displaystyle x\in X,} The smallest such M {\displaystyle M} is called the operator norm of L {\displaystyle L} and denoted by ‖ L ‖ . {\displaystyle |L|.} A bounded operator between normed spaces is continuous and vice versa.The concept of a bounded linear operator has been extended from normed spaces to certain to all topological vector spaces.Outside of functional analysis, when a function f : X → Y {\displaystyle f:X\to Y} is called "bounded" then this usually means that its image f ( X ) {\displaystyle f(X)} is a bounded subset of its codomain. A linear map has this property if and only if it is identically 0. {\displaystyle 0.} Consequently, in functional analysis, when a linear operator is called "bounded" then it is never meant in this abstract sense (of having a bounded image).

instead of

In functional analysis and operator theory, a bounded linear operator is a linear transformation $L:X\to Y$ between topological vector spaces (TVSs) $X$ and $Y$ that maps bounded subsets of $X$ to bounded subsets of $Y.$ If $X$ and $Y$ are normed vector spaces (a special type of TVS), then $L$ is bounded if and only if there exists some $M>0$ such that for all $x\in X,$ The smallest such $M$ is called the operator norm of $L$ and denoted by $|L|.$ A bounded operator between normed spaces is continuous and vice versa.

The concept of a bounded linear operator has been extended from normed spaces to certain to all topological vector spaces.

Outside of functional analysis, when a function $f:X\to Y$ is called "bounded" then this usually means that its image $f(X)$ is a bounded subset of its codomain. A linear map has this property if and only if it is identically $0.$ Consequently, in functional analysis, when a linear operator is called "bounded" then it is never meant in this abstract sense (of having a bounded image).

I have made a sincere effort to get to the bottom of this, and #4, and I've made some headway. This problem seems to arise from the explaintext flag in the PHP api request url. Interested parties can experiment for themselves, the explaintext flag is in the prop=extracts section: https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&format=json&prop=extracts&titles=Bounded_operator&redirects=1&converttitles=1&formatversion=latest&explaintext=1

One option would be to not use the explaintext flag and parse the HTML, but that would create a lot of additional parsing work for the plugin.