git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GSoC][PATCH 1/2] userdiff: add built-in patterns for CSS
@ 2015-03-08 11:03 Hiroyuki Sano
  2015-03-08 11:03 ` [GSoC][PATCH 2/2] attrs: add "css" to the list of userdiff bulit-in patterns Hiroyuki Sano
  2015-03-08 23:08 ` [GSoC][PATCH 1/2] userdiff: add built-in patterns for CSS Eric Sunshine
  0 siblings, 2 replies; 4+ messages in thread
From: Hiroyuki Sano @ 2015-03-08 11:03 UTC (permalink / raw)
  To: git; +Cc: Hiroyuki Sano

Add regex patterns for CSS. The word regex maches selectors, properties,
and values. On the other hand, the funcname regex matches lines contains
the curly brace character.

Signed-off-by: Hiroyuki Sano <sh19910711@gmail.com>
---
 t/t4018-diff-funcname.sh |  1 +
 t/t4034-diff-words.sh    |  1 +
 t/t4034/css/expect       | 35 +++++++++++++++++++++++++++++++++++
 t/t4034/css/post         | 32 ++++++++++++++++++++++++++++++++
 t/t4034/css/pre          | 32 ++++++++++++++++++++++++++++++++
 userdiff.c               |  3 +++
 6 files changed, 104 insertions(+)
 create mode 100644 t/t4034/css/expect
 create mode 100644 t/t4034/css/post
 create mode 100644 t/t4034/css/pre

diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 1dbaa38..29fe220 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -30,6 +30,7 @@ diffpatterns="
 	bibtex
 	cpp
 	csharp
+	css
 	fortran
 	html
 	java
diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index f2f55fc..912df91 100755
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
@@ -302,6 +302,7 @@ test_language_driver ada
 test_language_driver bibtex
 test_language_driver cpp
 test_language_driver csharp
+test_language_driver css
 test_language_driver fortran
 test_language_driver html
 test_language_driver java
diff --git a/t/t4034/css/expect b/t/t4034/css/expect
new file mode 100644
index 0000000..8bc6dfd
--- /dev/null
+++ b/t/t4034/css/expect
@@ -0,0 +1,35 @@
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index c53f20b..7e64463 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
+<CYAN>@@ -2,7 +2,7 @@<RESET> <RESET><MAGENTA>elm1, elm2 {<RESET>
+prop: first-value;<RESET>
+prop: value;<RESET>
+prop: value;<RESET>
+prop: <RED>value<RESET><GREEN>NEW-VALUE<RESET>;
+prop: last-value;<RESET>
+}<RESET>
+
+<CYAN>@@ -10,7 +10,7 @@<RESET> <RESET><MAGENTA>elm3, elm4 {<RESET>
+prop: first-value;<RESET>
+prop: value;<RESET>
+prop: value;<RESET>
+<RED>prop<RESET><GREEN>NEW-PROP<RESET>: value;
+prop: last-value;<RESET>
+}<RESET>
+
+<CYAN>@@ -19,7 +19,7 @@<RESET> <RESET><MAGENTA>elm6 {<RESET>
+prop: first-value;<RESET>
+prop: value;<RESET>
+prop: value;<RESET>
+<RED>prop<RESET><GREEN>NEW-PROP<RESET>: <RED>value<RESET><GREEN>NEW-VALUE<RESET>;
+prop: last-value;<RESET>
+}<RESET>
+
+<CYAN>@@ -27,6 +27,6 @@<RESET> <RESET><MAGENTA>.class, elm:hover, elm:first-child, elm:lang(en), #id, elm#id, .num123{<RESET>
+prop: first-value;<RESET>
+prop: value;<RESET>
+prop: value;<RESET>
+<RED>prop<RESET><GREEN>NUM-PROP<RESET>: <RED>value<RESET><GREEN>999<RESET>;
+prop: last-value;<RESET>
+}<RESET>
diff --git a/t/t4034/css/post b/t/t4034/css/post
new file mode 100644
index 0000000..7e64463
--- /dev/null
+++ b/t/t4034/css/post
@@ -0,0 +1,32 @@
+elm1, elm2 {
+prop: first-value;
+prop: value;
+prop: value;
+prop: NEW-VALUE;
+prop: last-value;
+}
+
+elm3, elm4 {
+prop: first-value;
+prop: value;
+prop: value;
+NEW-PROP: value;
+prop: last-value;
+}
+
+elm5,
+elm6 {
+prop: first-value;
+prop: value;
+prop: value;
+NEW-PROP: NEW-VALUE;
+prop: last-value;
+}
+
+.class, elm:hover, elm:first-child, elm:lang(en), #id, elm#id, .num123{
+prop: first-value;
+prop: value;
+prop: value;
+NUM-PROP: 999;
+prop: last-value;
+}
diff --git a/t/t4034/css/pre b/t/t4034/css/pre
new file mode 100644
index 0000000..c53f20b
--- /dev/null
+++ b/t/t4034/css/pre
@@ -0,0 +1,32 @@
+elm1, elm2 {
+prop: first-value;
+prop: value;
+prop: value;
+prop: value;
+prop: last-value;
+}
+
+elm3, elm4 {
+prop: first-value;
+prop: value;
+prop: value;
+prop: value;
+prop: last-value;
+}
+
+elm5,
+elm6 {
+prop: first-value;
+prop: value;
+prop: value;
+prop: value;
+prop: last-value;
+}
+
+.class, elm:hover, elm:first-child, elm:lang(en), #id, elm#id, .num123{
+prop: first-value;
+prop: value;
+prop: value;
+prop: value;
+prop: last-value;
+}
diff --git a/userdiff.c b/userdiff.c
index 2ccbee5..8374a2a 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -37,6 +37,9 @@ IPATTERN("fortran",
 	 "|//|\\*\\*|::|[/<>=]="),
 PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$",
 	 "[^<>= \t]+"),
+PATTERNS("css",
+	 "^.*[{].*$",
+	 "[-_\\.,#a-zA-Z0-9]+"),
 PATTERNS("java",
 	 "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
 	 "^[ \t]*(([A-Za-z_][A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$",
-- 
2.3.1

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

* [GSoC][PATCH 2/2] attrs: add "css" to the list of userdiff bulit-in patterns
  2015-03-08 11:03 [GSoC][PATCH 1/2] userdiff: add built-in patterns for CSS Hiroyuki Sano
@ 2015-03-08 11:03 ` Hiroyuki Sano
  2015-03-08 23:02   ` Eric Sunshine
  2015-03-08 23:08 ` [GSoC][PATCH 1/2] userdiff: add built-in patterns for CSS Eric Sunshine
  1 sibling, 1 reply; 4+ messages in thread
From: Hiroyuki Sano @ 2015-03-08 11:03 UTC (permalink / raw)
  To: git; +Cc: Hiroyuki Sano

Signed-off-by: Hiroyuki Sano <sh19910711@gmail.com>
---
 Documentation/gitattributes.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index c892ffa..8904a2a 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -525,6 +525,8 @@ patterns are available:
 
 - `csharp` suitable for source code in the C# language.
 
+- `css` suitable for source code in the CSS documents.
+
 - `fortran` suitable for source code in the Fortran language.
 
 - `html` suitable for HTML/XHTML documents.
-- 
2.3.1

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

* Re: [GSoC][PATCH 2/2] attrs: add "css" to the list of userdiff bulit-in patterns
  2015-03-08 11:03 ` [GSoC][PATCH 2/2] attrs: add "css" to the list of userdiff bulit-in patterns Hiroyuki Sano
@ 2015-03-08 23:02   ` Eric Sunshine
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Sunshine @ 2015-03-08 23:02 UTC (permalink / raw)
  To: Hiroyuki Sano; +Cc: Git List

On Sun, Mar 8, 2015 at 7:03 AM, Hiroyuki Sano <sh19910711@gmail.com> wrote:
> attrs: add "css" to the list of userdiff bulit-in patterns

s/bulit/built/

> Signed-off-by: Hiroyuki Sano <sh19910711@gmail.com>
> ---
> diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
> index c892ffa..8904a2a 100644
> --- a/Documentation/gitattributes.txt
> +++ b/Documentation/gitattributes.txt
> @@ -525,6 +525,8 @@ patterns are available:
>
>  - `csharp` suitable for source code in the C# language.
>
> +- `css` suitable for source code in the CSS documents.

Taking a hint from the 'html' case, it might make more sense to say:

    `css` suitable for CSS documents.

Considering how directly related this change is to those in patch 1,
it's not clear why this change needs a separate patch, so folding them
into a single patch might be sensible.

> +
>  - `fortran` suitable for source code in the Fortran language.
>
>  - `html` suitable for HTML/XHTML documents.
> --
> 2.3.1

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

* Re: [GSoC][PATCH 1/2] userdiff: add built-in patterns for CSS
  2015-03-08 11:03 [GSoC][PATCH 1/2] userdiff: add built-in patterns for CSS Hiroyuki Sano
  2015-03-08 11:03 ` [GSoC][PATCH 2/2] attrs: add "css" to the list of userdiff bulit-in patterns Hiroyuki Sano
@ 2015-03-08 23:08 ` Eric Sunshine
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Sunshine @ 2015-03-08 23:08 UTC (permalink / raw)
  To: Hiroyuki Sano; +Cc: Git List

On Sun, Mar 8, 2015 at 7:03 AM, Hiroyuki Sano <sh19910711@gmail.com> wrote:
> Add regex patterns for CSS. The word regex maches selectors, properties,
> and values. On the other hand, the funcname regex matches lines contains
> the curly brace character.
>
> Signed-off-by: Hiroyuki Sano <sh19910711@gmail.com>
> ---
> diff --git a/t/t4034/css/post b/t/t4034/css/post
> new file mode 100644
> index 0000000..7e64463
> --- /dev/null
> +++ b/t/t4034/css/post
> @@ -0,0 +1,32 @@
> [...]
> +.class, elm:hover, elm:first-child, elm:lang(en), #id, elm#id, .num123{

Mental note: colon and parentheses are present

> diff --git a/userdiff.c b/userdiff.c
> index 2ccbee5..8374a2a 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -37,6 +37,9 @@ IPATTERN("fortran",
>          "|//|\\*\\*|::|[/<>=]="),
>  PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$",
>          "[^<>= \t]+"),
> +PATTERNS("css",
> +        "^.*[{].*$",
> +        "[-_\\.,#a-zA-Z0-9]+"),

Is the intention that this should match "elm:lang(en)" as an atom, or
separately match "elm", "lang", and "en"?

>  PATTERNS("java",
>          "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
>          "^[ \t]*(([A-Za-z_][A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$",
> --

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

end of thread, other threads:[~2015-03-08 23:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-08 11:03 [GSoC][PATCH 1/2] userdiff: add built-in patterns for CSS Hiroyuki Sano
2015-03-08 11:03 ` [GSoC][PATCH 2/2] attrs: add "css" to the list of userdiff bulit-in patterns Hiroyuki Sano
2015-03-08 23:02   ` Eric Sunshine
2015-03-08 23:08 ` [GSoC][PATCH 1/2] userdiff: add built-in patterns for CSS Eric Sunshine

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 NNTP newsgroup(s).