Skip to content

Commit

Permalink
fix: processing two-character elements (#1067)
Browse files Browse the repository at this point in the history
  • Loading branch information
njzjz committed Mar 25, 2021
1 parent f142499 commit 752bfbf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions reacnetgenerator/_reachtml.py
Expand Up @@ -58,9 +58,11 @@ def _re(self, smi):
[C]
>>> self._re('[CH]')
[CH]
>>> self._re('Na')
[Na]
"""
elements = "".join([an.upper() + an.lower() for an in self.atomname if an != 'H'])
smi = re.sub(r'(?<!\[)([' + elements + r'])(?!H)', r'[\1]', smi)
elements = "|".join([((an.upper() + "|" + an.lower()) if len(an)==1 else an) for an in self.atomname if an != 'H'])
smi = re.sub(r'(?<!\[)(' + elements + r')(?!H)', r'[\1]', smi)
return smi.replace("[HH]", "[H]")

def _handlereaction(self, line):
Expand Down

1 comment on commit 752bfbf

@vercel
Copy link

@vercel vercel bot commented on 752bfbf Mar 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.