Giter VIP home page Giter VIP logo

react-latex's Issues

Latex not loading

When i put data from an api call and store it in redux then i put it in Latex, it does not show me the rendered format, it only shows the code that was given between $$, but when i change the location and go back to the home page, it shows the good format of latex, why is that happening ?

issue with curly brackets

When I try to render this component

const Math = props => (                                                                                                                                                         
  <div>                                                                                                                                                                                                                                                                                                                                       
    <Latex>What is $(3\times 4) \div \pm (5-3)$</Latex                                                                                                                                                                                                                                 
    <Latex>When $(a \ne 0)$, there are two solutions to $(ax^2 + bx + c = 0)$ and they are $x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}.$</Latex>                                                                                                                                             
  </div>                                                                                                                                                                                                                                                                               
) 

I get:

screen shot 2018-05-14 at 14 07 10

I think it is because of curly brackets in \frac{...}{...} but I have no idea how to fix it.

Does anyone have a suggestion?

\begin{equation} not working

\begin{equation} is not rendering.
Using the following code within elements.
$ \begin{equation} 3 \times 4 \end{equation} $

Problem with hyperlink

if I define a variable :
let text = "\\href{https://katex.org/}{\KaTeX}";

Then call
<Latex trust={true} throwOnError={false}>{text}</Latex>

it does not display a hyperlink. It directly prints the content of the text variable without interpreting it.
I also tried with \href instead of \href and I got the same result.

Some lines not rendering

Vertical and horizontal lines are not rendering in fractions and some other elements. I attached screenshots of what's showing up when I try to render the following latex.

<Latex displayMode={true}>{String.raw`$$\cfrac{a}{1 + \cfrac{1}{b}}$$`}</Latex>

What's rendering:
fraction example
What should be rendered:
image

       <Latex displayMode={true}>{String.raw`$$ \def\arraystretch{1.5}
   \begin{array}{c:c:c}
   a & b & c \\ \hline
   d & e & f \\
   \hdashline
   g & h & i
\end{array} $$`}</Latex>

What's rendering:
arraystrech example
What should be rendered:
image

Add the ability to enable/disable Latex "display mode".

As mentioned in the KaTeX readme:

Rendering options

You can provide an object of options as the last argument to katex.render and katex.renderToString. Available options are:

displayMode: boolean. If true the math will be rendered in display mode, which will put the math in display style (so \int and \sum are large, for example), and will center the math on the page on its own line. If false the math will be rendered in inline mode. (default: false)

It would be great to enable/disable this with something like:

<Latex displayMode={true}>$y = x$</Latex>

Html rendering not working

When i'm rendering a katex like this. {mylatex}. Any html that i put inside mylatex doenst get render. I check the props, and by default is rendering math + html. So i dont really no where to go with this. Any ideas? Thanks

Half of matrix is hidden

The following code snippet only renders half the matrix for some reason.

var Latex = require("react-latex");
function RenderBasisVector() {
    const LatexString = `$$ \\vert 0 \\rang = \\begin{pmatrix} 1 \\\\ 0  \\end{pmatrix} \\quad\\quad \\vert 1 \\rang = \\begin{pmatrix} 0 \\\\ 1  \\end{pmatrix}$$`    
    
    return (
        <h3><Latex displayMode={true}>{LatexString}</Latex></h3>
    );
}
export default RenderBasisVector;

In the index.html file I have imported both

<link href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.9.0/katex.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.css" integrity="sha384-ko6T2DjISesD0S+wOIeHKMyKsHvWpdQ1s/aiaQMbL+TIXx3jg6uyf9hlv3WWfwYv" crossorigin="anonymous">

halfmatrix
The expression works fine on katex.org and with a latex compiler. No matter how I change the matrices only half of it is rendered in react.

Missing @types/react-latex

The types for this package are needed for Typescript support. @ts-ignore can be added as a workaround to avoid warnings when using this package inside typescript files. But it would be great if I don't have to do that and have some awesome type completion.

dangerouslySetInnerHTML vulnerability?

Hi,
I'm quite new to FE-development and have a security question:
Is it a possible vulnerability that dangerouslySetInnerHTML is being used here, in the case of accepting user input?
Thanks for your help!

Question related using cloudflare served stylesheet vs katex npm package's stylesheet

As per README.md the expected behaviour is to add cloudflare served stylesheet link in head as

<head>
	<link
	    href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.9.0/katex.min.css"
            rel="stylesheet"
	/>
</head>

my questions are :

  1. instead of defining the stylesheet in head, can i add katex npm package to my code and import stylesheet defined in its dist folder ? something like this
import Latex from "react-latex";
import "katex/dist/katex.min.css";

const MathRender = ({ src }) => {
	return <Latex>{src}</Latex>;
};

export default MathRender;
  1. if i can add it, then whats the difference between the both ?

Project Details:

web app built with create-react-app

React Native

Is there an example of Latex for reacting native????

couldn't convert backslash delimited string

Hi,
Is there a way to handle both $ and \ delimited latex strings?

I currently have a string that isnt being rendered properly:

\Upsilon_{\mathrm{disc}}^{max} < \ 0.7 \;{\mathrm{M}_\odot}/{\mathrm{L}_\odot}

however, strings delimited like $LATEX$ are rendering correctly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.