threads / patch / 38754

patch, 2 partsattrs: add "css" to the list of userdiff bulit-in patterns

Subject: [GSoC][PATCH 2/2] attrs: add "css" to the list of userdiff bulit-in patterns

## tl;dr

4 messages between Mar 8, 2015 and Mar 8, 2015. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Hiroyuki Sano· Mar 8, 2015, 11:03 UTC · lore

[GSoC][PATCH 1/2] userdiff: add built-in patterns for CSS

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
Show changes to 6 files +104 −0

t/t4018-diff-funcname.sh, t/t4034-diff-words.sh, t/t4034/css/expect, t/t4034/css/post, t/t4034/css/pre, userdiff.c

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
Hiroyuki Sano· Mar 8, 2015, 11:03 UTC · re: Hiroyuki Sano · lore
Signed-off-by: Hiroyuki Sano <sh19910711@gmail.com>
---
 Documentation/gitattributes.txt | 2 ++
 1 file changed, 2 insertions(+)
Show changes to Documentation/gitattributes.txt +2 −0
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
Eric Sunshine· Mar 8, 2015, 23:02 UTC · re: Hiroyuki Sano · lore

Re: [GSoC][PATCH 2/2] attrs: add "css" to the list of userdiff bulit-in patterns

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/
Show 11 quoted lines
> 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.

Show 6 quoted lines
> +
>  - `fortran` suitable for source code in the Fortran language.
>
>  - `html` suitable for HTML/XHTML documents.
> --
> 2.3.1
Eric Sunshine· Mar 8, 2015, 23:08 UTC · re: Hiroyuki Sano · lore

Re: [GSoC][PATCH 1/2] userdiff: add built-in patterns for CSS

On Sun, Mar 8, 2015 at 7:03 AM, Hiroyuki Sano <sh19910711@gmail.com> wrote:
Show 14 quoted lines
> 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
Show 11 quoted lines
> 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]*\\([^;]*)$",
> --

← back to recent threads