From 6f1245bd15c71b65c8c9f21ad91c5b251b5a94de Mon Sep 17 00:00:00 2001 From: Carsten Grohmann Date: Thu, 21 Nov 2019 08:14:12 +0100 Subject: [PATCH] Show h2 headline in TOC only if id attr is set There are two conditions to show a h2 headline in TOC: * the headline is visible * the id attribute is set Thereby the css style js-flag-hide-from-toc won't be used anymore. --- OOMAnalyser.html | 6 +----- OOMAnalyser.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/OOMAnalyser.html b/OOMAnalyser.html index f13aba8..5824afc 100644 --- a/OOMAnalyser.html +++ b/OOMAnalyser.html @@ -92,10 +92,6 @@ background-color: #f2f2f2; } - .js-flag-hide-from-toc { - /* empty just used to hide h2 headings from TOCS */ - } - .js-notify_box__msg--warning { color: #9F6000; background-color: #FEEFB3; @@ -148,7 +144,7 @@ function goBack() {

Analyse and visualise Linux OOM output

diff --git a/OOMAnalyser.py b/OOMAnalyser.py index 26ce2f9..5900e8b 100644 --- a/OOMAnalyser.py +++ b/OOMAnalyser.py @@ -846,13 +846,19 @@ Killed process 6576 (java) total-vm:33914892kB, anon-rss:20629004kB, file-rss:0k show_element('notify_box') def update_toc(self): - """Update the TOC to show current and visible headlines only""" + """ + Update the TOC to show current headlines only + + There are two conditions to show a h2 headline in TOC: + * the headline is visible + * the id attribute is set + """ new_toc = '' toc_content = document.querySelectorAll('nav > ul')[0] for element in document.querySelectorAll('h2'): - if not is_visible(element) or element.classList.contains('js-flag-hide-from-toc'): + if not (is_visible(element) and element.id): continue new_toc +='
  • {}
  • '.format(element.id, element.textContent)