Skip to content

Commit a453fe7

Browse files
Fix Markdownlint: Long lines, text blocks, includes
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
1 parent 58f94ac commit a453fe7

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ repos:
9393
rev: v0.45.0
9494
hooks:
9595
- id: markdownlint
96+
exclude: docs/source/include-toplevel-*
9697

9798

9899
- repo: local

README-Unicode.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ for i in 2.7 3.{6,7};do echo "$i:";
9595
LC_ALL=C python$i -c 'open("/usr/share/hwdata/pci.ids").read()';done
9696
```
9797

98-
```
98+
```text
9999
2.7:
100100
3.6:
101101
Traceback (most recent call last):
@@ -106,20 +106,22 @@ UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 97850: ordi
106106
3.7:
107107
```
108108

109-
This error means that the `'ascii' codec` cannot handle input ord() >= 128, and as some Video cards use `²` to reference their power, the `ascii` codec chokes on them.
110-
111-
It means `xcp.pci.PCIIds()` cannot use `open("/usr/share/hwdata/pci.ids").read()`.
109+
The `'ascii'` codec fails on all bytes >128.
110+
For example, it fails the bytes of `²` (UTF-8: power of two) in the PCI IDs database.
111+
To read `/usr/share/hwdata/pci.ids`, we must use `encoding="utf-8"`.
112112

113113
While Python 3.7 and newer use UTF-8 mode by default, it does not set up an error handler for `UnicodeDecodeError`.
114114

115-
As it happens, some older tools output ISO-8859-1 characters hard-coded and these aren't valid UTF-8 sequences, and even newer Python versions need error handlers to not fail:
115+
Also, some older tools output ISO-8859-1 characters
116+
These aren't valid UTF-8 sequences.
117+
For all Python versions, we need to use error handlers to handle them:
116118

117119
```sh
118120
echo -e "\0262" # ISO-8859-1 for: "²"
119121
python3 -c 'open(".text").read()'
120122
```
121123

122-
```
124+
```text
123125
Traceback (most recent call last):
124126
File "<string>", line 1, in <module>
125127
File "<frozen codecs>", line 322, in decode

0 commit comments

Comments
 (0)