@@ -24,16 +24,16 @@ Then we can use :doc:`pandas:reference/api/pandas.DataFrame.to_csv` in
24
24
:language: python
25
25
26
26
Now add the following section to your global Git configuration
27
- :file: `~/.gitconfig `:
27
+ :file: `~/.config/git/config `:
28
28
29
29
.. code-block :: ini
30
30
31
31
[diff " excel" ]
32
32
textconv =python3 /PATH/TO/exceltocsv.py
33
33
binary =true
34
34
35
- Finally, in the global :file: `~/.gitattributes ` file, our ``excel `` converter is
36
- linked to :file: `*.xlsx ` files:
35
+ Finally, in the global :file: `~/.config/git/attributes ` file, our ``excel ``
36
+ converter is linked to :file: `*.xlsx ` files:
37
37
38
38
.. code-block :: ini
39
39
@@ -56,15 +56,16 @@ For this, ``pdftohtml`` is additionally required. It can be installed with
56
56
57
57
$ brew install pdftohtml
58
58
59
- Add the following section to the global Git configuration :file: `~/.gitconfig `:
59
+ Add the following section to the global Git configuration
60
+ :file: `~/.config/git/config `:
60
61
61
62
.. code-block :: ini
62
63
63
64
[diff " pdf" ]
64
65
textconv =pdftohtml -stdout
65
66
66
- Finally, in the global :file: `~/.gitattributes ` file, our ``pdf `` converter is
67
- linked to :file: `*.pdf ` files:
67
+ Finally, in the global :file: `~/.config/git/attributes ` file, our ``pdf ``
68
+ converter is linked to :file: `*.pdf ` files:
68
69
69
70
.. code-block :: ini
70
71
@@ -73,10 +74,12 @@ linked to :file:`*.pdf` files:
73
74
Now, when ``git diff `` is called, the PDF files are first converted and then a
74
75
diff is performed over the outputs of the converter.
75
76
76
- … for Word documents
77
- --------------------
77
+ .. _pandoc-to-markdown :
78
78
79
- Differences in Word documents can also be displayed. For this purpose `Pandoc
79
+ … for documents
80
+ ---------------
81
+
82
+ Differences in documents can also be displayed. For this purpose `Pandoc
80
83
<https://pandoc.org/> `_ can be used, which can be easily installed with
81
84
82
85
.. tab :: Debian/Ubuntu
@@ -97,24 +100,92 @@ Differences in Word documents can also be displayed. For this purpose `Pandoc
97
100
<https://github.com/jgm/pandoc/releases/> `_.
98
101
99
102
Then add the following section to your global Git configuration
100
- :file: `~/.gitconfig `:
103
+ :file: `~/.config/git/attributes `:
101
104
102
105
.. code-block :: ini
103
106
104
- [diff " word" ]
105
- textconv =pandoc --to =markdown
106
- binary =true
107
- prompt =false
107
+ [diff " pandoc-to-markdown" ]
108
+ textconv = pandoc --to markdown
109
+ cachetextconv = true
108
110
109
- Finally, in the global :file: `~/.gitattributes ` file, our ``word `` converter is
110
- linked to :file: `*.docx ` files:
111
+ Finally, in the global :file: `~/.config/git/attributes ` file, our
112
+ ``pandoc-to-markdown `` converter is linked to :file: `*.docx `, :file: `*.odt ` and
113
+ :file: `*.rtf ` files:
111
114
112
115
.. code-block :: ini
113
116
114
- *.docx diff =word
117
+ *.docx diff =pandoc-to-markdown
118
+ *.odt diff =pandoc-to-markdown
119
+ *.rtf diff =pandoc-to-markdown
120
+
121
+ .. tip ::
122
+ :doc: `Jupyter Notebooks <jupyter-tutorial:notebook/index >` write to a JSON
123
+ file :ref: `*.ipynb <jupyter-tutorial:whats-an-ipynb-file >`, which is quite
124
+ dense and difficult to read, especially with diffs. The Markdown
125
+ representation of Pandoc simplifies this:
126
+
127
+ .. code-block :: ini
128
+
129
+ *.ipynb diff =pandoc-to-markdown
115
130
116
131
The same procedure can be used to obtain useful diffs from other binaries, for
117
132
example ``*.zip ``, ``*.jar `` and other archives with ``unzip `` or for changes in
118
133
the meta information of images with ``exiv2 ``. There are also conversion tools
119
134
for converting ``*.odt ``, ``*.doc `` and other document formats into plain text.
120
135
For binary files for which there is no converter, strings are often sufficient.
136
+
137
+ .. _exiftool :
138
+
139
+ … for media files
140
+ -----------------
141
+
142
+ `ExifTool <https://exiftool.org >`_ can be used to convert the metadata of media
143
+ files to text.
144
+
145
+ .. tab :: Debian/Ubuntu
146
+
147
+ .. code-block :: console
148
+
149
+ $ sudo apt install libimage-exiftool-perl
150
+
151
+ .. tab :: macOS
152
+
153
+ .. code-block :: console
154
+
155
+ $ brew install exiftool
156
+
157
+ .. tab :: Windows
158
+
159
+ .. code-block :: ps1
160
+
161
+ > choco install exiftool
162
+
163
+ .. seealso ::
164
+ * `Installing ExifTool <https://exiftool.org/install.html >`_
165
+
166
+ You can then add the following section to the global Git configuration file
167
+ :file: `~/.config/git/config `:
168
+
169
+ .. code-block :: ini
170
+
171
+ [diff " exiftool" ]
172
+ textconv = exiftool --composite -x ' Exiftool:*'
173
+ cachetextconv = true
174
+ xfuncname = " ^-.*$"
175
+
176
+ Finally, in :file: `~/.config/git/attributes ` the ``exiftool `` converter is
177
+ linked to file endings of media files:
178
+
179
+ .. code-block :: ini
180
+
181
+ *.avif diff =exiftool
182
+ *.bmp diff =exiftool
183
+ *.gif diff =exiftool
184
+ *.jpeg diff =exiftool
185
+ *.jpg diff =exiftool
186
+ *.png diff =exiftool
187
+ *.webp diff =exiftool
188
+
189
+ .. seealso ::
190
+ ``exiftool `` can process many more media files. You can find a complete list
191
+ in `Supported File Types <https://exiftool.org/#supported >`_.
0 commit comments