Skip to content

Commit

Permalink
Fix to ensure that we don't get duplicate labels for file modals when…
Browse files Browse the repository at this point in the history
… we have shortcuts
  • Loading branch information
Gareth Aneurin Tribello authored and Gareth Aneurin Tribello committed Oct 27, 2024
1 parent 627a986 commit 01ccfba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions PlumedToHTML/PlumedFormatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, **options) :
}

def format(self, tokensource, outfile):
action, label, all_labels, keywords, shortcut_state, shortcut_depth, default_state, notooltips, expansion_label, hidden_state, hidenum = "", "", set(), [], 0, 0, 0, False, "", 0, 0
action, label, all_labels, keywords, shortcut_state, shortcut_depth, default_state, notooltips, expansion_label, hidden_state, hidenum, nfiles = "", "", set(), [], 0, 0, 0, False, "", 0, 0, 0
outfile.write('<pre style="width=97%;">\n')
for ttype, value in tokensource :
# This checks if we are at the start of a new action. If we are we should be reading a value or an action and the label and action for the previous one should be set
Expand Down Expand Up @@ -141,6 +141,7 @@ def format(self, tokensource, outfile):
iff = open( inp, 'r' )
fcontent = iff.read()
iff.close()
nfiles = nfiles + 1
if len(self.auxinputlines)>0 :
shortversion, allines = "", fcontent.splitlines()
for n, l in enumerate(self.auxinputlines) :
Expand All @@ -149,11 +150,11 @@ def format(self, tokensource, outfile):
if n>0 : shortversion += "...\n"
for kk in range(start,end+1) : shortversion += allines[kk-1] + "\n"
fcontent = shortversion
outfile.write('<div class="tooltip">' + inp + '<div class="right"> Click <a onclick=\'openModal("' + self.egname + inp + '")\'>here</a> to see an extract from this file.<i></i></div></div>')
outfile.write('<div id="' + self.egname + inp + '" class="modal">')
outfile.write('<div class="tooltip">' + inp + '<div class="right"> Click <a onclick=\'openModal("' + self.egname + inp + str(nfiles) + '")\'>here</a> to see an extract from this file.<i></i></div></div>')
outfile.write('<div id="' + self.egname + inp + str(nfiles) + '" class="modal">')
outfile.write(' <div class="modal-content">')
outfile.write('<div class="modal-header">')
outfile.write(' <span class="close" onclick=\'closeModal("' + self.egname + inp + '")\'>&times;</span>')
outfile.write(' <span class="close" onclick=\'closeModal("' + self.egname + inp + str(nfiles) + '")\'>&times;</span>')
outfile.write(' <h2>FILE: ' + inp + '</h2>')
outfile.write('</div>')
outfile.write('<div class="modal-body">')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name='PlumedToHTML',
version='0.90',
version='0.91',
author="Gareth Tribello",
author_email="[email protected]",
description="A package for creating pretified HTML for PLUMED files",
Expand Down

0 comments on commit 01ccfba

Please sign in to comment.