ktxt2 fountain to hollywoo conversions

This commit is contained in:
2023-03-19 12:19:08 -06:00
parent 348134a55a
commit a2aea26108

View File

@@ -1,55 +0,0 @@
// KTxt2 Conversions for Fountain files
(function isUpperCase [s]
(= s (s.toUpperCase)))
(var :Array<String> specialSpeechTags [])
(function specialSpeech [name parenTag hmethod]
(specialSpeechTags.push parenTag)
(registerConversion
(new ktxt2.StreamConversion name "fountain" "hollywoo"
->stream
?(whenLet [(Some name) (stream.takeUntilAndDrop " (${parenTag}")]
(and (isUpperCase name) {(stream.dropWhitespace) !(stream.isEmpty)}))
->stream
(let [name (whenLet [(Some name) (stream.takeUntilAndDrop " (${parenTag}")] name)
&mut output ""]
(stream.takeLine)
(loop
(let [wryly (ifLet [(Some w) (stream.takeBetween "(" ")\n")] w "")
line (ifLet [(Some l) (stream.takeLine)] (l.trim) (break))]
(when line
(+= output "$hmethod \"${name}\" \"${wryly}\" ##\"${line}\"##\n"))))
output))))
(specialSpeech "On Phone Speech" "O.P." "ONPHONESPEECH")
(specialSpeech "VoiceOver Speech" "V.O." "VOICEOVER")
(specialSpeech "Off-Screen Speech" "O.S." "OFFSCREENSPEECH")
(registerConversion
(new ktxt2.StreamConversion "Normal Speech" "fountain" "hollywoo"
->stream ?(whenLet [(Some name) (stream.takeLine)]
(doFor tag specialSpeechTags
(whenLet [(Some _) (indexOf name "(${tag}")] (return false)))
(and (isUpperCase name) {(stream.dropWhitespace) !(stream.isEmpty)}))
->stream
(let [name (whenLet [(Some name) (stream.takeLine)] (.trim (name.replace "(CONT'D)" "")))
&mut output ""]
(loop
(let [wryly (ifLet [(Some w) (stream.takeBetween "(" ")\n")] w "")
line (ifLet [(Some l) (stream.takeLine)] (l.trim) (break))]
(when line
(+= output "NORMALSPEECH \"${name}\" \"${wryly}\" ##\"${line}\"##\n"))))
output)))
(registerConversion
(new ktxt2.StreamConversion "Label" "fountain" "hollywoo"
->stream ?{(stream.dropWhitespace) (stream.startsWith "/*")}
->stream
"LABEL $(.trim
(.replace
(.replace
(.replace stream.content "/*" "")
"*/" "")
"*" ""))\n"))