git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] userdiff: fix HTML hunk header regexp
@ 2017-09-23  7:53 Ilya Kantor
  2017-09-24  1:15 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Ilya Kantor @ 2017-09-23  7:53 UTC (permalink / raw)
  To: git

Current HTML header regexp doesn't match headers without attributes.

So it fails to match <h1>...</h1>, while <h1 class="smth">...</h1> matches.
The fix makes attributes optional.
The regexp is still far from perfect, but now it at least handles the
common case.

Signed-off-by: Ilya Kantor <iliakan@gmail.com>
---
 userdiff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/userdiff.c b/userdiff.c
index 6321103ce..dbfb4e13c 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -38,7 +38,7 @@ IPATTERN("fortran",
  "|//|\\*\\*|::|[/<>=]="),
 IPATTERN("fountain", "^((\\.[^.]|(int|ext|est|int\\.?/ext|i/e)[. ]).*)$",
  "[^ \t-]+"),
-PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$",
+PATTERNS("html", "^[ \t]*(<[Hh][1-6]([ \t].*)?>.*)$",
  "[^<>= \t]+"),
 PATTERNS("java",
  "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
--
2.14.1

---
Best Regards,
Ilya Kantor

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] userdiff: fix HTML hunk header regexp
  2017-09-23  7:53 [PATCH] userdiff: fix HTML hunk header regexp Ilya Kantor
@ 2017-09-24  1:15 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2017-09-24  1:15 UTC (permalink / raw)
  To: Ilya Kantor; +Cc: git

Ilya Kantor <iliakan@gmail.com> writes:

> Current HTML header regexp doesn't match headers without attributes.
>
> So it fails to match <h1>...</h1>, while <h1 class="smth">...</h1> matches.
> The fix makes attributes optional.
> The regexp is still far from perfect, but now it at least handles the
> common case.
>
> Signed-off-by: Ilya Kantor <iliakan@gmail.com>
> ---
>  userdiff.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/userdiff.c b/userdiff.c
> index 6321103ce..dbfb4e13c 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -38,7 +38,7 @@ IPATTERN("fortran",
>   "|//|\\*\\*|::|[/<>=]="),
>  IPATTERN("fountain", "^((\\.[^.]|(int|ext|est|int\\.?/ext|i/e)[. ]).*)$",
>   "[^ \t-]+"),
> -PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$",
> +PATTERNS("html", "^[ \t]*(<[Hh][1-6]([ \t].*)?>.*)$",
>   "[^<>= \t]+"),


What you sent seems to be whitespace damaged, but it was small
enough for me to tweak it to apply ;-)

Will queue.  Thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-24  1:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-23  7:53 [PATCH] userdiff: fix HTML hunk header regexp Ilya Kantor
2017-09-24  1:15 ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).