Skip to content

can add katex css to this html view ? #349

Open

Description

@todaysprint

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

Activity

  1. kabonKoda commented on Dec 1, 2022

    @kabonKoda

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions