git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 21, 2015, 19:33 UTC
Message-ID
<xmqqk2ttuwyy.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1437484966-664-1-git-send-email-zoe@bytenoise.co.uk>
Zoë Blade <zoe@bytenoise.co.uk> writes:

Hmmmm, the pattern has too many question marks to make a simple panda brain spin.

> "^((\\.|((int|est|ext)?\\.?|i(nt)?\\.?/e(xt)?\\.?) ).+)$"

it can start with a dot, or match "something" at the beginning, followed by a SP (is a tab allowed there instead of SP, I have to wonder).

One problem I noticed immediately: this allows a line that begins with "...", which I learned in http://fountain.io/syntax when I wrote $gmane/274127 is explicitly excluded. A line that begin with a dot followed by a non-dot is a forced scene heading.

Now disecting that "something" (i.e. not a forced scene heading), which is this part ...

> ((int|est|ext)?\\.?|i(nt)?\\.?/e(xt)?\\.?)
... that gives us largely two choices:
 - It can begin with zero or one int/est/ext and can optionally be
   followed by a dot, or
 - It can be one of (i, int), optionally followed by a dot, followed
   by slash, followed by one of (e, ext), optionally followed by a
   dot.

Second problem. Doesn't the early part of this "something" pattern allow an empty string to match by having zero "int" and zero "."?

With this edit to the test vector (add either one of these two, removing the other, before you run this test twice), you can see that these over-eager matches in action. ----------------------------------------------------------------

 t/t4018/fountain-scene | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/t/t4018/fountain-scene b/t/t4018/fountain-scene
index 6b3257d..94f0513 100644
--- a/t/t4018/fountain-scene
+++ b/t/t4018/fountain-scene
@@ -1,4 +1,7 @@
 EXT. STREET RIGHT OUTSIDE - DAY
 
+ An indented line is WRONG.
+...we do not want ellipses.
+
 CHARACTER
 You didn't say the magic phrase, "ChangeMe".

----------------------------------------------------------------

Perhaps the pattern is trying to be too clever for its own good.
I'd prefer to see us doing simple, stupid and obviously correct.

That "syntax" page says:

    You can "force" a Scene Heading by starting the line with a
    single period. ... Note that only a single leading period
    followed by an alphanumeric character will force a Scene
    Heading. This allows the writer to begin Action and Dialogue
    elements with ellipses ...

which would give us the first part, i.e. the line may start with a
dot and then an alnum

\\.[a-z0-9]

And then

    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

which translates to

(int|ext|est|int\\.?/ext|i/e)[. ]

So taking these all together, something like this?

^((\\.[a-z0-9]|(int|ext|est|int\\.?/ext|i/e)[. ]).*)$

I personally prefer to make it slightly lenient to exclude dot
instead of forcing US-ASCII view of alnum, i.e.

^((\\.[^.]|(int|ext|est|int\\.?/ext|i/e)[. ]).*)$

I'll queue a SQUASH??? on top while waiting for a response.

Thanks.
Previous: Zoë BladeNext: Zoë Blade
Message 2 of 4 in “userdiff: add support for Fountain documents”
  1. userdiff: add support for Fountain documentsZoë Blade, Jul 21, 2015
  2. Junio C HamanoJul 21, 2015
  3. Zoë BladeJul 22, 2015
  4. Zoë BladeJul 29, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.