I have some content I want to transfer from TWC over to TW5, so I am trying to program a button that will parse the old content into fields.
TWC content looks something like this:
{{section{
!Written By
*Writer 1
*Writer 2
*Writer 3
}}}
{{section{
!Directed By
*Director
}}}
{{section{
!Cast
!!Starring
*actor as role 1
*actor as role 2
*actor as role 3
}}}
The above content is what I am trying to parse into fields based on the heading. For example anything in the “Written By” section would need to be parsed into written-1
, written-2
, and written-3
.
I would like to create a list filter that parses that into fields, after pasting it into a textarea, which will transfer that text into a tiddler called $:/temp/TWC-parser
.
Something that I have been playing around with below:
<$button>
<$list filter="[{$:/temp/TWC-parser}splitregexp[\n]search-replace:g[{{section{],[]search-replace:g[}}}],[]]" variable="parser" counter="count">
<$list filter="[<parser>match[!Written By]" variable="writer" counter="writer-count">
<!-- Is it possible to start at zth[1] here? -->
<$action-setfield $tiddler=<<currentTiddler> $field={{{ [<writer-count>subtract[1]addprefix[written-] }}} $value=<<writer>>/>
<!-- Is it possible to stop when the next line has the prefix[!]? -->
</$list>
<!-- Then repeat the process for directors -->
<$list filter="[<parser>match[!Directed By]" variable="director" counter="director-count">
<$action-setfield $tiddler=<<currentTiddler> $field={{{ [<director-count>subtract[1]addprefix[director-] }}} $value=<<director>>/>
</$list>
<$action-setfield $tiddler="$:/temp/TWC-parser" $field="text" $value=""/>
</$list>
parse fields
</$button>
I was wondering if was possible to start at a specific header and stop just before the next header.
I have a lot of tiddlers to transfer from TWC to TW5, I’m just trying to make the process easier, so I just asking this out of curiosity. If not possible, I guess I just have to transfer the old fashion way.