react-native-htmlview icon indicating copy to clipboard operation
react-native-htmlview copied to clipboard

can add katex css to this html view ?

Open todaysprint opened this issue 3 years ago • 1 comments

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

todaysprint avatar Oct 25 '22 07:10 todaysprint

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} />
)

};

kabonKoda avatar Dec 01 '22 06:12 kabonKoda