secure-77 / Perlite

A web-based markdown viewer optimized for Obsidian
https://perlite.secure77.de/
MIT License
1.03k stars 87 forks source link

Latex math not being rendered correctly #44

Closed mcpeixoto closed 1 year ago

mcpeixoto commented 1 year ago

Hello, I just uploaded my notes to my Perlite website and I'm having some issues rendering math.

For example Screenshot from 2022-11-28 22-48-54

image

Vs how it appears in obsidian locally

image image

image

I believe the boxes are from a plugin I have installed but why do the equations and image aren't rendering correctly? Also, is there a way to make my locally installed plugins work on the website? Thanks in advance!

Source code:

> [!todo] Definition
> Given two bit-strings $x, y ∈ {0, 1}^n$  we define their product $x · y ∈ {0, 1}$ as:
> $$x · y = (x_1 ∧ y_1) ⊕ · · · ⊕ (x_n ∧ y_n)$$

> [!note] Lemma 2
> For any three binary strings $x , a, b ∈ {0, 1}^n$ the equation $(x · a) ⊕ (x · b) = x · (a ⊕ b)$ holds

> [!note] Lemma 3
> For any element $|b⟩$ in the computational basis of $C^2$ we have 
> $$H |b⟩ = \frac{1}{\sqrt{ 2 }} \sum_{z \in 2} (-1)^{b \land Z}|z⟩$$

> [!summary] Theorem 1
> For any element $|b⟩$ in the computational basis of $C^{2^n}$ we have 
> $$H^{⊗n} |b⟩ =\frac{1}{\sqrt{ 2^n }}  \sum_{z \in 2} (-1)^{b \cdot z} \ket{z} $$

> [!example] Example of Theorem 1
> For $n=1$ and $b=\ket{0}$ for example:
> $$
> H \ket{0} = \frac{1}{\sqrt{ 2 }} ((-1)^{0 \cdot 0} \ket{0})  + (-1)^{0 \cdot 1} \ket{1}) = \ket{+}  
> $$
> > [!caution] How the dot product works
> > $0 \cdot 0 = 0$
> > $0 \cdot 1 = 0$
> > $1 \cdot 0 = 0$
> > $1 \cdot 1 = 1$
> > 
> > Now what happens when we have **multiple qubits?** 
> > If $b$ is an multi qubit state..
> > 
> > $b_{1} \cdot z_{1} \oplus b_{2} \cdot z_{2} \oplus \dots$

- [ ] Prove theorems/lemmas, specially theorem 1 🔼 #Universidade 

# The Problem

> [!info] The Problem
> Take a function $f : \{0, 1\}^n \rightarrow \{0, 1\}$.
> You are promised that $f (x) = s · x$ for some fixed bit-string $s$. 
> Find $s$

Classically, we run $f$ $n$-times by computing

$$f (1 . . . 0) = ({\color{orange}s_1} ∧ 1) ⊕ · · · ⊕ (sn ∧ 0) = {\color{orange}s_1}$$
$$\dots$$
$$f (0 . . . 1) = (s1 ∧ 0) ⊕ · · · ⊕ ({\color{orange}s_{n}} ∧ 1) = {\color{orange}s_{n}}$$

Quantumly, we discover $s$ by running $f$ only $\color{orange}\text{once}$
secure-77 commented 1 year ago

Hi @mcpeixoto,

The block / callout problem should be fixed in the next release, see #40. About your image problem: I cant find a image in your provided source code, so I cant reproduce this. This is how your source looks in version 1.5.1 image

which seems more or less correct for me, about the latex blocks I would need to check if there is an option to enable this but I dont think I will support any plugins in Perlite.

secure-77 commented 1 year ago

I took a look at the not renderd latex formel and I found the reason was related to the color switch, from Katex

In early versions of both KaTeX (<0.8.0) and MathJax, the \color function expected the content to be a function argument, as in \color{blue}{hello}. In current KaTeX, \color is a switch, as in \color{blue} hello. This matches LaTeX behavior. If you want the old \color behavior, set option colorIsTextColor to true.

This means that you need to use the current color switch, so the block from above should look like this


$$f (1 . . . 0) = ({\color{orange}s_1} ∧ 1) ⊕ · · · ⊕ (sn ∧ 0) = {\color{orange}s_1}$$
$$\dots$$
$$f (0 . . . 1) = (s1 ∧ 0) ⊕ · · · ⊕ ({\color{orange} s_n} ∧ 1) = {\color{orange}s_n}$$

Then Perlite (Katex) will render this correct:

image