threads / patch / 39872

patchuserdiff: add support for Fountain documents

Subject: [PATCH] userdiff: add support for Fountain documents

## tl;dr

4 messages between Jul 17, 2015 and Jul 19, 2015. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Zoë Blade· Jul 17, 2015, 14:21 UTC · lore

Add support for Fountain, a plain text screenplay format. Git facilitates not just programming specifically, but creative writing in general, so it makes sense to also support other plain text documents besides source code.

In the structure of a screenplay specifically, scenes are roughly analogous to functions, in the sense that it makes your job easier if you can see which ones were changed in a given range of patches.

More information about the Fountain format can be found on its official website, at http://fountain.io .

Signed-off-by: Zoë Blade <zoe@bytenoise.co.uk>
---
 Documentation/gitattributes.txt | 2 ++
 t/t4018-diff-funcname.sh        | 1 +
 t/t4018/fountain-scene          | 4 ++++
 userdiff.c                      | 2 ++
 4 files changed, 9 insertions(+)
 create mode 100644 t/t4018/fountain-scene
Show changes to 4 files +9 −0

Documentation/gitattributes.txt, t/t4018-diff-funcname.sh, t/t4018/fountain-scene, userdiff.c

diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 81fe586..e3b1de8 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -527,6 +527,8 @@ patterns are available:
 
 - `fortran` suitable for source code in the Fortran language.
 
+- `fountain` suitable for Fountain documents.
+
 - `html` suitable for HTML/XHTML documents.
 
 - `java` suitable for source code in the Java language.
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 1dbaa38..67373dc 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -31,6 +31,7 @@ diffpatterns="
 	cpp
 	csharp
 	fortran
+	fountain
 	html
 	java
 	matlab
diff --git a/t/t4018/fountain-scene b/t/t4018/fountain-scene
new file mode 100644
index 0000000..6b3257d
--- /dev/null
+++ b/t/t4018/fountain-scene
@@ -0,0 +1,4 @@
+EXT. STREET RIGHT OUTSIDE - DAY
+
+CHARACTER
+You didn't say the magic phrase, "ChangeMe".
diff --git a/userdiff.c b/userdiff.c
index 2ccbee5..5316b48 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -35,6 +35,8 @@ IPATTERN("fortran",
 	  * they would have been matched above as a variable anyway. */
 	 "|[-+]?[0-9.]+([AaIiDdEeFfLlTtXx][Ss]?[-+]?[0-9.]*)?(_[a-zA-Z0-9][a-zA-Z0-9_]*)?"
 	 "|//|\\*\\*|::|[/<>=]="),
+PATTERNS("fountain", "^((INT|EST|EXT)?\\.[A-Z0-9' -]+)$",
+	 "[^ \t-]+"),
 PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$",
 	 "[^<>= \t]+"),
 PATTERNS("java",
-- 
2.5.0.rc2.28.g6003e7f.dirty
Junio C Hamano· Jul 17, 2015, 17:12 UTC · re: Zoë Blade · lore

Re: [PATCH] userdiff: add support for Fountain documents

Zoë Blade <zoe@bytenoise.co.uk> writes:
Show 14 quoted lines
> Add support for Fountain, a plain text screenplay format.  Git
> facilitates not just programming specifically, but creative writing
> in general, so it makes sense to also support other plain text
> documents besides source code.
>
> In the structure of a screenplay specifically, scenes are roughly
> analogous to functions, in the sense that it makes your job easier
> if you can see which ones were changed in a given range of patches.
>
> More information about the Fountain format can be found on its
> official website, at http://fountain.io .
>
> Signed-off-by: Zoë Blade <zoe@bytenoise.co.uk>
> ---

The test looks a bit too brief (i.e. there is only one obvious candidate to be picked as the funcname header in the input, so it is very hard to break the expectation of the test even when the code or pattern is modified incorrectly), but it would do for now. Everything else looks trivially OK ;-)

Thanks, will queue.
Show 55 quoted lines
>  Documentation/gitattributes.txt | 2 ++
>  t/t4018-diff-funcname.sh        | 1 +
>  t/t4018/fountain-scene          | 4 ++++
>  userdiff.c                      | 2 ++
>  4 files changed, 9 insertions(+)
>  create mode 100644 t/t4018/fountain-scene
>
> diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
> index 81fe586..e3b1de8 100644
> --- a/Documentation/gitattributes.txt
> +++ b/Documentation/gitattributes.txt
> @@ -527,6 +527,8 @@ patterns are available:
>  
>  - `fortran` suitable for source code in the Fortran language.
>  
> +- `fountain` suitable for Fountain documents.
> +
>  - `html` suitable for HTML/XHTML documents.
>  
>  - `java` suitable for source code in the Java language.
> diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
> index 1dbaa38..67373dc 100755
> --- a/t/t4018-diff-funcname.sh
> +++ b/t/t4018-diff-funcname.sh
> @@ -31,6 +31,7 @@ diffpatterns="
>  	cpp
>  	csharp
>  	fortran
> +	fountain
>  	html
>  	java
>  	matlab
> diff --git a/t/t4018/fountain-scene b/t/t4018/fountain-scene
> new file mode 100644
> index 0000000..6b3257d
> --- /dev/null
> +++ b/t/t4018/fountain-scene
> @@ -0,0 +1,4 @@
> +EXT. STREET RIGHT OUTSIDE - DAY
> +
> +CHARACTER
> +You didn't say the magic phrase, "ChangeMe".
> diff --git a/userdiff.c b/userdiff.c
> index 2ccbee5..5316b48 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -35,6 +35,8 @@ IPATTERN("fortran",
>  	  * they would have been matched above as a variable anyway. */
>  	 "|[-+]?[0-9.]+([AaIiDdEeFfLlTtXx][Ss]?[-+]?[0-9.]*)?(_[a-zA-Z0-9][a-zA-Z0-9_]*)?"
>  	 "|//|\\*\\*|::|[/<>=]="),
> +PATTERNS("fountain", "^((INT|EST|EXT)?\\.[A-Z0-9' -]+)$",
> +	 "[^ \t-]+"),
>  PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$",
>  	 "[^<>= \t]+"),
>  PATTERNS("java",
Junio C Hamano· Jul 17, 2015, 22:43 UTC · re: Junio C Hamano · lore

Re: [PATCH] userdiff: add support for Fountain documents

Junio C Hamano <gitster@pobox.com> writes:
> Zoë Blade <zoe@bytenoise.co.uk> writes:
>
>> More information about the Fountain format can be found on its
>> official website, at http://fountain.io .
So I visited there.
>> +PATTERNS("fountain", "^((INT|EST|EXT)?\\.[A-Z0-9' -]+)$",
>> +	 "[^ \t-]+"),

After skimming http://fountain.io/syntax I am getting the impression that this might be a bit too limiting.

 * Although uppercase is recommended for Scene Headings to increase
   readability, it is not required.
 * A line beginning with any of the following, followed by either a
   dot or a space, is considered a Scene Heading (unless the line is
   preceded by an exclamation point !). Case insensitive.
      INT
      EXT
      EST
      INT./EXT
      INT/EXT
      I/E
 * You can "force" a Scene Heading by starting the line with a
   single period.
 * Scene Headings can optionally be appended with Scene
   Numbers. Scene numbers are any alphanumerics (plus dashes and
   periods), wrapped in #.

So, it appears wrong to insist on capital letters in the patterns. The pattern in the patch does not even accept punctuations on the line other than apostrophe. I won't judge if it is OK to limit to US-ASCII ;-)

IPATTERNS("fountain",
    "^([.][^.]|(INT|EXT|EST|INT./EXT|INT/EXT|I/E)[. ]",
    "[^ \t-]+"),
or something like this, perhaps?
Zoë Blade· Jul 19, 2015, 12:30 UTC · re: Junio C Hamano · lore

Re: [PATCH] userdiff: add support for Fountain documents

On 17 Jul 2015, at 23:43, Junio C Hamano <gitster@pobox.com> wrote:
Show 31 quoted lines
> * Although uppercase is recommended for Scene Headings to increase
>   readability, it is not required.
> 
> * A line beginning with any of the following, followed by either a
>   dot or a space, is considered a Scene Heading (unless the line is
>   preceded by an exclamation point !). Case insensitive.
> 
>      INT
>      EXT
>      EST
>      INT./EXT
>      INT/EXT
>      I/E
> 
> * You can "force" a Scene Heading by starting the line with a
>   single period.
> 
> * Scene Headings can optionally be appended with Scene
>   Numbers. Scene numbers are any alphanumerics (plus dashes and
>   periods), wrapped in #.
> 
> So, it appears wrong to insist on capital letters in the patterns.
> The pattern in the patch does not even accept punctuations on the
> line other than apostrophe.  I won't judge if it is OK to limit to
> US-ASCII ;-)
> 
> IPATTERNS("fountain",
>    "^([.][^.]|(INT|EXT|EST|INT./EXT|INT/EXT|I/E)[. ]",
>    "[^ \t-]+"),
> 
> or something like this, perhaps?
Good points, thanks!
This regex should be a bit sturdier:

$ cat scenes.txt int. yes - day INT. YES - DAY #1A# EXT. YES - DAY .YES TOO !EXT. NO INT/EXT YES - DAY INT./EXT YES - DAY I/E YES - DAY no NO NO. !.NO. int yes - day est yes - day !EXT. NO - DAY

$ grep -E "^((\.|(([Ii][Nn][Tt]|[Ee][Ss][Tt]|[Ee][Xx][Tt])?\\.?|[Ii]([Nn][Tt])?\.?/[Ee]([Xx][Tt])?\.?) ).+)$" scenes.txt int. yes - day INT. YES - DAY #1A# EXT. YES - DAY .YES TOO INT/EXT YES - DAY INT./EXT YES - DAY I/E YES - DAY int yes - day est yes - day

Revised version of patch incoming...

← back to recent threads