Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can add katex css to this html view ? #349

Open
todaysprint opened this issue Oct 25, 2022 · 1 comment
Open

can add katex css to this html view ? #349

todaysprint opened this issue Oct 25, 2022 · 1 comment

Comments

@todaysprint
Copy link

katex css to this html view ?
any kind of help
thanks

@kabonKoda
Copy link

i use react native math view component to render latex in my html view

import React from 'react';
import { View, useWindowDimensions } from 'react-native';
import MathView from 'react-native-math-view'
import HTMLView from 'react-native-htmlview';
import { parseLatexInHTML } from './lib';

const NativeHTMLnTEXView = ({ defaultTextProps, source, delimiters }) => {
const { html } = source;

if (!delimiters) delimiters = [
  {left: '$$', right: '$$', display: true},
  {left: '$', right: '$', display: false},
  {left: '\\(', right: '\\)', display: false},
  {left: '\\[', right: '\\]', display: true}
];

const parsed = parseLatexInHTML(html, { ...delimiters, throwOnError : false });

const renderNode = (node, index, siblings, parent, defaultRenderer) => {
  if (node.name == 'math') {
    return (
      <View key={index} >
        <MathView math={node.children[0].data} />
      </View>
    );
  }
}

return (
  <HTMLView value={`<div>${parsed}<div>`} renderNode={renderNode} />
)

};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants