derickc / Fountainhead

Contextual Sublime Text screenwriting environment using the Fountain screenplay syntax.
http://classicblunders.com/fountainhead/
Other
72 stars 13 forks source link

: at end of Transition causes it not to be recognized as a Transition #9

Open derickc opened 9 years ago

derickc commented 9 years ago

The transition that doesn't work is ">CUT VERS:". The weird thing is that it is recognized as a transition if i remove the ":".

davemx commented 9 years ago

Hi Derick,

I ran into this same problem with transitions like > DISSOLVE TO:. So I checked out the source and modified the language file to use some new regular expressions.

I broke them up into three types of transitions:

I wrote a transition test file and ran it against my fix plus five Fountain apps (Highland, Slugline, Logline, Screenplain and Afterwriting). They all implement transitions differently in corner cases. Even Highland doesn't strictly follow the spec.

Here is the source test file and PDF exports: http://davemx.com/get/fh-test.zip

Now my proposed fix. In Fountainhead.tmLanguage, replace the existing Transitions section (lines 453-460) with the following.

<!-- Transitions -->
<!-- Includes spec, forced and convenience. -->
<key>transitions</key>
<dict>
    <key>patterns</key>
    <array>
        <dict>
            <key>include</key>
            <string>#transitions_spec</string>
        </dict>
        <dict>
            <key>include</key>
            <string>#transitions_forced</string>
        </dict>
        <dict>
            <key>include</key>
            <string>#transitions_convenience</string>
        </dict>
    </array>
</dict>

<!-- Transitions - Spec -->
<key>transitions_spec</key>
<dict>
    <key>name</key>
    <string>entity.name.tag</string>
    <key>match</key>
    <string>(?i)^\s*(\w+ TO:)$</string>
</dict>

<!-- Transitions - Forced -->
<key>transitions_forced</key>
<dict>
    <key>name</key>
    <string>entity.name.tag</string>
    <key>match</key>
    <string>(?i)^\s*([>|&gt;][A-Za-z0-9 ]+[:\.]?)$</string>
</dict>

<!-- Transitions - Convenience -->
<key>transitions_convenience</key>
<dict>
    <key>name</key>
    <string>entity.name.tag</string>
    <key>match</key>
    <string>(?i)^\s*((FADE IN:)|(FADE OUT\.)|(FADE TO BLACK\.)|(CUT TO BLACK\.))$</string>
</dict>

So there you go. It works for me except where noted (transitions on adjacent lines).

Hope it helps, Dave

derickc commented 9 years ago

Thanks for this! I will update Fountainhead this weekend. Sorry, I haven't done so earlier. I'll look into the adjacent line transitions, though I doubt it would be something that most people would have to worry about.

davemx commented 9 years ago

No problem! And if you want to be forgiving of spaces after the transition, like CUT TO:, you can just add \s* before the $ endings. I think pretty much all the apps don't follow the "no appended spaces" spec.