diff options
author | Tal Einat <taleinat+github@gmail.com> | 2019-09-03 23:52:58 +0300 |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2019-09-03 16:52:58 -0400 |
commit | 580bdb0ece681537eadb360f0c796123ead7a559 (patch) | |
tree | a172256a3d4933baafa4dc1dbe0adf0ff2861993 /Lib/idlelib/help.py | |
parent | 993ac92418839427d4068d6ae8e618b06b5d9294 (diff) | |
download | cpython-git-580bdb0ece681537eadb360f0c796123ead7a559.tar.gz |
bpo-38022: IDLE: upgrade help.html to sphinx 2.x HTML5 output (GH-15664)
The HTML5 output from Sphinx 2.x adds '<p>' tags within list elements. Using a new prevtag attribute, ignore these instead of emitting unwanted '\n\n'.
Also stop looking for 'first' classes on tags (no longer present) and fix the bug of double-spacing instead of single spacing after <pre> blocks.
Diffstat (limited to 'Lib/idlelib/help.py')
-rw-r--r-- | Lib/idlelib/help.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/idlelib/help.py b/Lib/idlelib/help.py index e19d361501..ba2c6ec554 100644 --- a/Lib/idlelib/help.py +++ b/Lib/idlelib/help.py @@ -62,6 +62,7 @@ class HelpParser(HTMLParser): self.simplelist = False # simple list (no double spacing) self.toc = [] # pair headers with text indexes for toc self.header = '' # text within header tags for toc + self.prevtag = None # info about previous tag (was opener, tag) def indent(self, amt=1): self.level += amt @@ -78,8 +79,11 @@ class HelpParser(HTMLParser): self.show = True # start of main content elif tag == 'div' and class_ == 'sphinxsidebar': self.show = False # end of main content - elif tag == 'p' and class_ != 'first': - s = '\n\n' + elif tag == 'p' and self.prevtag and not self.prevtag[0]: + # begin a new block for <p> tags after a closed tag + # avoid extra lines, e.g. after <pre> tags + lastline = self.text.get('end-1c linestart', 'end-1c') + s = '\n\n' if lastline and not lastline.isspace() else '\n' elif tag == 'span' and class_ == 'pre': self.chartags = 'pre' elif tag == 'span' and class_ == 'versionmodified': @@ -120,6 +124,7 @@ class HelpParser(HTMLParser): self.tags = tag if self.show: self.text.insert('end', s, (self.tags, self.chartags)) + self.prevtag = (True, tag) def handle_endtag(self, tag): "Handle endtags in help.html." @@ -139,6 +144,7 @@ class HelpParser(HTMLParser): self.tags = '' elif tag in ['ul', 'dd', 'ol']: self.indent(amt=-1) + self.prevtag = (False, tag) def handle_data(self, data): "Handle date segments in help.html." |