Skip to content

Commit e8ca360

Browse files
committed
FIX: Fixed an issue caused by pandoc squeezing tables
* Added two arguments to the pandoc call to set the page width at 1000 columns and to disable text wrapping. This fixes an issue where it would generate invalid RST. * Changed the `use_scm_version` argument in `setup` to point to an absolute directory for VERSION.txt. * Renamed `LazyReadmyConverter` to `LazyMarkdownConverter`. * Added an explicit setting for `long_description`'s encoding. * Changed how README.md is read so it's less cluttered.
1 parent 4e918f9 commit e8ca360

File tree

2 files changed

+42
-33
lines changed

2 files changed

+42
-33
lines changed

README.md

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -105,32 +105,28 @@ No standards are currently supported across all major browsers, though it's hope
105105

106106
| | Chrome | Edge | Firefox | Safari |
107107
| ----------------------------------: | :------------- | :------------------------ | :----------------------- | :------------- |
108-
| **Content Security Policy (CSP)** | Supported | Supported ² | Supported | Supported |
109-
| **HTTP Public Key Pinning (HPKP)** | Supported| Under Consideration| Not Supported | Not Supported |
110-
| **Out-of-Band Reporting API** | Planned | Not Supported | Not Supported | Not Supported |
111-
| **Network Error Logging (NEL)** | Planned ¹³ | Under Consideration ¹⁴ | Not Supported | Not Supported |
112-
| **Expect-CT** | Planned ¹⁷ | Planned ¹⁸ | ? | ? |
108+
| **Content Security Policy (CSP)** | Supported | [Supported][2] | Supported | [Supported][4] |
109+
| **HTTP Public Key Pinning (HPKP)** | [Supported][5] | [Under Consideration][6] | [Not Supported][7] | Not Supported |
110+
| **Out-of-Band Reporting API** | [Planned][9] | Not Supported | Not Supported | Not Supported |
111+
| **Network Error Logging (NEL)** | [Planned][13] | [Under Consideration][14] | Not Supported | Not Supported |
112+
| **Expect-CT** | [Planned][17] | [Planned][18] | ? | ? |
113113
| **Expect-Staple** | ? | ? | ? | ? |
114114

115115

116-
1. Source needed
117-
2. https://developer.microsoft.com/en-us/microsoft-edge/platform/status/contentsecuritypolicylevel2/
118-
3. Source needed
119-
4. https://webkit.org/status/#specification-content-security-policy-level-3
120-
5. https://www.chromestatus.com/feature/4669935557017600
121-
6. https://developer.microsoft.com/en-us/microsoft-edge/platform/status/publickeypinningextensionforhttp/
122-
7. https://bugzilla.mozilla.org/show_bug.cgi?id=1091176
123-
8. Source needed
124-
9. https://bugs.chromium.org/p/chromium/issues/detail?id=676016
125-
10. Source needed
126-
11. Source needed
127-
12. Source needed
128-
13. https://www.chromestatus.com/feature/5391249376804864
129-
14. https://developer.microsoft.com/en-us/microsoft-edge/platform/status/networkerrorlogging/
130-
15. Source needed
131-
16. Source needed
132-
17. https://bugs.chromium.org/p/chromium/issues/detail?id=679012
133-
18. https://lists.w3.org/Archives/Public/ietf-http-wg/2016OctDec/0767.html
116+
[2]: https://developer.microsoft.com/en-us/microsoft-edge/platform/status/contentsecuritypolicylevel2/ "Partial support for Level 3"
117+
[4]: https://webkit.org/status/#specification-content-security-policy-level-3 "Partial support for Level 3"
118+
119+
[5]: https://www.chromestatus.com/feature/4669935557017600
120+
[6]: https://developer.microsoft.com/en-us/microsoft-edge/platform/status/publickeypinningextensionforhttp/ "Under Consideration"
121+
[7]: https://bugzilla.mozilla.org/show_bug.cgi?id=1091176 "No report-uri or report-only support."
122+
123+
[9]: https://bugs.chromium.org/p/chromium/issues/detail?id=676016
124+
125+
[13]: https://www.chromestatus.com/feature/5391249376804864 "No recent progress"
126+
[14]: https://developer.microsoft.com/en-us/microsoft-edge/platform/status/networkerrorlogging/
127+
128+
[17]: https://bugs.chromium.org/p/chromium/issues/detail?id=679012
129+
[18]: https://lists.w3.org/Archives/Public/ietf-http-wg/2016OctDec/0767.html
134130

135131

136132
## Tools and Similar Projects

setup.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@
22
from setuptools import setup, find_packages
33

44

5+
# Root directory of the project
6+
project_dir = path.dirname(__file__)
57

6-
class LazyReadmeConverter:
7-
""" Uses pandoc to convert the README from Markdown to reStructuredText. """
8+
9+
# Dump the contents of README.md into a variable
10+
with open(path.join(path.abspath(project_dir), 'README.md'), encoding='utf-8') as f:
11+
long_description = f.read()
12+
13+
14+
15+
class LazyMarkdownConverter:
16+
""" Lazily converts README from Markdown to reStructuredText using pandoc. """
817

918
IN_FORMAT = 'markdown_github'
1019
OUT_FORMAT = 'rst'
11-
converted = False
1220

1321

14-
def __init__(self, file_path):
15-
# Read the entire file contents into a string
16-
with open(file_path, encoding='utf-8') as f:
17-
self.value = f.read()
22+
def __init__(self, value):
23+
self.value = value
24+
self.converted = False
1825

1926

2027
def __str__(self):
@@ -23,7 +30,12 @@ def __str__(self):
2330
if not self.converted:
2431
try:
2532
from pypandoc import convert_text
26-
self.value = convert_text(self.value, self.OUT_FORMAT, self.IN_FORMAT)
33+
self.value = convert_text(
34+
self.value,
35+
self.OUT_FORMAT,
36+
self.IN_FORMAT,
37+
extra_args=['--columns=1000', '--wrap=none']
38+
)
2739
except ImportError:
2840
print("pypandoc isn't installed")
2941
except OSError:
@@ -51,10 +63,11 @@ def __repr__(self):
5163
setup(
5264
name='Django-Lookout',
5365

54-
use_scm_version={'write_to': 'lookout/VERSION.txt'},
66+
use_scm_version={'write_to': path.join(project_dir, 'lookout', 'VERSION.txt')},
5567

5668
description='API endpoint for receiving incident reports from Content Security Policy (CSP), HTTP Public Key Pinning (HPKP), and the HTTP Reporting API.',
57-
long_description=LazyReadmeConverter(path.join(path.abspath(path.dirname(__file__)), 'README.md')),
69+
long_description=LazyMarkdownConverter(long_description),
70+
long_description_content_type='UTF-8',
5871

5972
url='https://github.com/rspeed/Django-Lookout',
6073

0 commit comments

Comments
 (0)