File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,15 +13,34 @@ interface IKaTeXProps {
1313 value : KaTeXProps [ 'value' ] ;
1414}
1515
16+ const BLOCK_ENV_PATTERN = / \\ b e g i n \s * \{ \s * ( a r r a y | m a t r i x | p m a t r i x | b m a t r i x | B m a t r i x | v m a t r i x | V m a t r i x ) \s * \} / ;
17+
1618export const KaTeX = ( { value } : IKaTeXProps ) : React . ReactElement | null => {
1719 const { colors } = useTheme ( ) ;
1820 const fixAndroidWebviewCrashStyle : StyleProp < ViewStyle > = isAndroid ? { opacity : 0.99 , overflow : 'hidden' } : { } ;
21+ // KaTeX array does not render correctly in MathView (shows gray box).
22+ // MathView does not throw, so renderError is never triggered.
23+ if ( BLOCK_ENV_PATTERN . test ( value ) ) {
24+ return (
25+ < Katex
26+ expression = { value }
27+ displayMode = { true }
28+ style = { [ { flex : 1 , height : DEFAULT_MESSAGE_HEIGHT } , fixAndroidWebviewCrashStyle ] }
29+ />
30+ ) ;
31+ }
32+
1933 return (
2034 < MathView
2135 math = { value }
36+ config = { { inline : false } }
2237 style = { { color : colors . fontDefault } }
2338 renderError = { ( ) => (
24- < Katex expression = { value } style = { [ { flex : 1 , height : DEFAULT_MESSAGE_HEIGHT } , fixAndroidWebviewCrashStyle ] } />
39+ < Katex
40+ expression = { value }
41+ displayMode = { true }
42+ style = { [ { flex : 1 , height : DEFAULT_MESSAGE_HEIGHT } , fixAndroidWebviewCrashStyle ] }
43+ />
2544 ) }
2645 />
2746 ) ;
Original file line number Diff line number Diff line change @@ -2238,6 +2238,25 @@ export const Katex = () => (
22382238) ;
22392239export const KatexLargeFont = ( ) => < MessageLargeFont { ...katex } /> ;
22402240
2241+ const katexArray = {
2242+ msg : '\\begin{array}{|c|c|c|c|c|c|} \\hline \\text{...} & \\text{...} \\\\ \\hline \\end{array}' ,
2243+ md : [
2244+ {
2245+ type : 'KATEX' ,
2246+ value :
2247+ ' \\begin{array}{|c|c|c|c|c|c|} \\hline \\text{testing} & \\text{testingII} & \\text{testing III} & \\text{testing IV} & \\text{testV} & \\text{testVI} \\\\ \\hline \\text{TEST} & \\text{TEST} & \\text{TEST} & \\text{TEST} & \\text{TEST} & \\text{TEST} \\\\ \\hline\\text{TEST} & \\text{✅} & \\text{test} & \\text{test} & \\text{test} & \\text{✅} \\\\ \\hline \\end{array} '
2248+ }
2249+ ]
2250+ } ;
2251+
2252+ export const KatexArray = ( ) => (
2253+ < >
2254+ < Message { ...katexArray } />
2255+ </ >
2256+ ) ;
2257+
2258+ export const KatexArrayLargeFont = ( ) => < MessageLargeFont { ...katexArray } /> ;
2259+
22412260const inlineKatex = {
22422261 msg : '\\(xˆ2 + yˆ2 - zˆ2\\)' ,
22432262 md : [
You can’t perform that action at this time.
0 commit comments