Yours is a precarious tip-toe across the mined and barb-wired landscape that is my sponge. Maybe not the safest place to travel.
(aside: your arrow emojis are semantically oh-so-much better; I only looked at your code after I finished mine.)
My snippet of code to explore:
<$let wikitextTable="""|Cell1 |Cell2 |Cell3 |Cell4 |
|Cell5 |Cell6 |Cell7 |<|
|Cell5 |~|Cell7 |Cell8 |
|>|>|Cell10 |Cell11 |
|>|>|Cell10 |<|
|>|>|<|Cell11 |""">
<$list variable="row" filter="[<wikitextTable>splitregexp[\n]]">
<hr style="border:1px solid red">
row: <<row>>
<hr style="border:1px solid red">
(
<$list variable="cell" filter="[<row>search-replace:g[>|],[🟦]search-replace:g[|<],[🟩]split[|]butfirst[]butlast[]]">
<$let range🟦={{{ [<cell>split[🟦]count[]subtract[1]compare:number:gt[0]] }}}
range🟩={{{ [<cell>split[🟩]count[]subtract[1]compare:number:gt[0]] }}}>
<$list filter="[range<range🟦>compare:number:gt[0]]">0 </$list>
<$text text={{{ [[1]add<range🟦>add<range🟩>] }}}/>
<$list filter="[range<range🟩>compare:number:gt[0]]">0 </$list>
</$let>
</$list>
)
</$list>
</$let>
The result:
For the full guacamole (the “here” to “there” thinking):
<$let wikitextTable="""|Cell1 |Cell2 |Cell3 |Cell4 |
|Cell5 |Cell6 |Cell7 |<|
|Cell5 |~|Cell7 |Cell8 |
|>|>|Cell10 |Cell11 |
|>|>|Cell10 |<|
|>|>|<|Cell11 |""">
! wikitextTable as-is
<<wikitextTable>>
<hr>
! wikitextTable, text-ified rows
<$list filter="[<wikitextTable>splitregexp[\n]]">
{{!!title}} <br>
</$list>
<hr>
! wikitextTable, text-ified rows, prepping content
<$list variable="row" filter="[<wikitextTable>splitregexp[\n]]">
<hr style="border:1px solid red">
row: <<row>>
<hr style="border:1px solid red">
<$list variable="cell" filter="[<row>search-replace:g[>|],[🟦]search-replace:g[|<],[🟩]split[|]butfirst[]butlast[]]">
<<cell>>
<hr>
</$list>
</$list>
<hr>
! wikitextTable, text-ified rows, setting up numbers
<$list variable="row" filter="[<wikitextTable>splitregexp[\n]]">
<hr style="border:1px solid red">
row: <<row>>
<hr style="border:1px solid red">
(
<$list variable="cell" filter="[<row>search-replace:g[>|],[🟦]search-replace:g[|<],[🟩]split[|]butfirst[]butlast[]]">
<$let range🟦={{{ [<cell>split[🟦]count[]subtract[1]compare:number:gt[0]] }}}
range🟩={{{ [<cell>split[🟩]count[]subtract[1]compare:number:gt[0]] }}}>
<$list filter="[range<range🟦>compare:number:gt[0]]">0 </$list>
<$text text={{{ [[1]add<range🟦>add<range🟩>] }}}/>
<$list filter="[range<range🟩>compare:number:gt[0]]">0 </$list>
</$let>
</$list>
)
</$list>
</$let>
All of that should have some validation added:
- check that the first cell in the row isn’t “|<|”, and handle that accordingly
- check that the last cell in the row ins’t “|>|”, and handle that accordingly