ktxt2 fountain to hollywoo conversions

This commit is contained in:
2023-03-19 12:19:08 -06:00
parent 7403212ecb
commit 996bc3ee2f
3 changed files with 8 additions and 6 deletions

View File

@@ -9,6 +9,9 @@
"homepage": "",
"categories": [],
"extensionPack": [],
"dependencies": {
"monaco-editor": "^0.36.1"
},
"publisher": "NQNStudios",
"contributes": {
"keybindings": [
@@ -45,8 +48,5 @@
},
"version": "0.0.0",
"activationEvents": [],
"displayName": "",
"dependencies": {
"monaco-editor": "^0.36.1"
}
}
"displayName": ""
}

View File

@@ -10,7 +10,9 @@
(printThroughInfoMessage)
(context.subscriptions.push
(KTxt2EditorProvider.register context))
(KTxt2EditorProvider.register context))
(load "conversions/FountainToHollywoo.kiss")
// Add your extension's commands here with (defCommand <...>):
(load "Commands.kiss")

View File

@@ -0,0 +1,55 @@
// 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"))