@@ -247,36 +247,46 @@ export const renderText = <
247247 } ;
248248
249249 const listLevels = {
250- 'top' : 'top ' ,
251- 'sub' : 'sub ' ,
252- }
250+ sub : 'sub ' ,
251+ top : 'top ' ,
252+ } ;
253253
254- const customListAtLevel = ( level : keyof typeof listLevels ) : ReactNodeOutput => ( node , output , { ...state } ) => {
255- var numberIndex = node . start ;
256- var items = node . items . map ( ( item : Array < SingleASTNode > , i : number ) => {
257- const withinList = item . length > 1 && item [ 1 ] . type === 'list' ;
258- var content = output ( item , { ...state , withinList } ) ;
254+ const customListAtLevel =
255+ ( level : keyof typeof listLevels ) : ReactNodeOutput =>
256+ ( node , output , { ...state } ) => {
257+ const items = node . items . map ( ( item : Array < SingleASTNode > , index : number ) => {
258+ const withinList = item . length > 1 && item [ 1 ] . type === 'list' ;
259+ const content = output ( item , { ...state , withinList } ) ;
259260
260- const isTopLevelText = [ 'text' , 'paragraph' , 'strong' ] . includes ( item [ 0 ] . type ) && withinList == false
261+ const isTopLevelText =
262+ [ 'text' , 'paragraph' , 'strong' ] . includes ( item [ 0 ] . type ) && withinList === false ;
261263
262- return (
263- < View key = { i } style = { styles . listRow } >
264- < Text style = { styles . listItemNumber } > { node . ordered ? `${ numberIndex ++ } . ` : `\u2022` } </ Text >
265- < Text style = { [ styles . listItemText , isTopLevelText && { marginBottom : 0 } ] } > { content } </ Text >
266- </ View >
267- ) ;
268- } ) ;
264+ return (
265+ < View key = { index } style = { styles . listRow } >
266+ < Text style = { styles . listItemNumber } >
267+ { node . ordered ? `${ node . start + index } . ` : `\u2022` }
268+ </ Text >
269+ < Text style = { [ styles . listItemText , isTopLevelText && { marginBottom : 0 } ] } >
270+ { content }
271+ </ Text >
272+ </ View >
273+ ) ;
274+ } ) ;
269275
270- const isSublist = level === 'sub' ;
271- return ( < View key = { state . key } style = { [ isSublist ? styles . list : styles . sublist ] } > { items } </ View > ) ;
272- }
276+ const isSublist = level === 'sub' ;
277+ return (
278+ < View key = { state . key } style = { [ isSublist ? styles . list : styles . sublist ] } >
279+ { items }
280+ </ View >
281+ ) ;
282+ } ;
273283
274284 const customRules = {
275285 link : { react } ,
276286 list : { react : customListAtLevel ( 'top' ) } ,
277- sublist : { react : customListAtLevel ( 'sub' ) } ,
278287 // we have no react rendering support for reflinks
279288 reflink : { match : ( ) => null } ,
289+ sublist : { react : customListAtLevel ( 'sub' ) } ,
280290 ...( mentionedUsers
281291 ? {
282292 mentions : {
0 commit comments