Skip to content

Commit 5d7cfb5

Browse files
Gareth Aneurin TribelloGareth Aneurin Tribello
authored andcommitted
Added fix to ensure that we treat numbered keywords correctly when searching for examples on markdown pages
1 parent 0a3b458 commit 5d7cfb5

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55

66
[project]
77
name = "PlumedToHTML"
8-
version = "0.118"
8+
version = "0.119"
99
description = "A package for creating prettified HTML for PLUMED files"
1010
authors = [{ name = "Gareth Tribello", email = "gareth.tribello@gmail.com" }]
1111
maintainers = [{ name = "Daniele Rapetti", email = "iximiel@gmail.com" }]

src/PlumedToHTML/PlumedFormatter.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ def format(self, tokensource, outfile):
4040
if len(action)>0 and (ttype==String or ttype==Keyword or ttype==Comment.Preproc) :
4141
if action==self.checkaction :
4242
for key in keywords :
43-
self.checkaction_keywords.add( key )
43+
if key in self.keyword_dict[action]["syntax"] :
44+
self.checkaction_keywords.add( key )
45+
else :
46+
# This makes sure we find numbered keywords
47+
for kkkk in self.keyword_dict[action]["syntax"] :
48+
if kkkk=="output" or self.keyword_dict[action]["syntax"][kkkk]["multiple"]==0 : continue
49+
if kkkk in key : self.checkaction_keywords.add( kkkk )
4450
if notooltips :
4551
# Reset everything for the new action
4652
action, label, keywords, notooltips = "", "", [], False

tests/test_keyword_list.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,15 @@ def testReadKeywords(self) :
2222
with open("check_keywords_file", "w") as ofile :
2323
PlumedToHTML.processMarkdownString( inpt, "check_keyword", ("plumed",), ("master",), actions, ofile, checkaction="PRINT", checkactionkeywords=keyset )
2424
self.assertTrue( len(keyset)==0 )
25+
26+
inpt = """
27+
```plumed
28+
d1: DISTANCE ATOMS1=1,2 ATOMS2=3,4
29+
PRINT ARG=d1 FILE=colvar
30+
```
31+
"""
32+
actions = set({})
33+
keyset = set({"ATOMS","COMPONENTS"})
34+
with open("check_keywords_file", "w") as ofile :
35+
PlumedToHTML.processMarkdownString( inpt, "check_keyword", ("plumed",), ("master",), actions, ofile, checkaction="DISTANCE", checkactionkeywords=keyset )
36+
self.assertTrue( keyset==set({"COMPONENTS"}) )

0 commit comments

Comments
 (0)