import re


def _parse_bonds_from_svg(bond_elements, mol):
    """Extract bonding information from SVG elements

    Args:
        bond_elements (list[xml.etree.ElementTree.Element]):
            List of SVG path elements.
        mol (rdkit.Chem.rdchem.Mol): RDKit mol object]

    Returns:
        list[dict]: JSON-style formated bond informations
    """
    result = []
    re_bond_regex = r"bond-\d+"
    for bond_svg in bond_elements:
        try:
            if not re.search(re_bond_regex, bond_svg.attrib["class"]):
                continue

            atoms = re.findall(r"atom-\d+", bond_svg.attrib["class"])
            atom_id_a = int(atoms[0][5:])  # to get int part of "atom-0"
            atom_id_b = int(atoms[1][5:])

            temp = {
                "bgn": mol.GetAtomWithIdx(atom_id_a).GetProp("name"),
                "end": mol.GetAtomWithIdx(atom_id_b).GetProp("name"),
                "coords": bond_svg.attrib["d"],
                "style": bond_svg.attrib["style"],
            }

            result.append(temp)
        except (RuntimeError, KeyError):
            pass  # we do not care about bonded Hydrogens
    return result