def convert_page_references_to_links(text):
# Define the patterns to search for
patterns = [r'\(p\.(\d+)\)', r'\(p\. (\d+)\)']
# Replace each pattern with a link
for pattern in patterns:
text = re.sub(
pattern,
r'<button style="background-color: transparent; outline: none; border: none; text-align: center; text-decoration: none; display: inline-block; cursor: pointer; border-bottom: 1px solid #46acfa; color: #46acfa;" onclick="")">p.\1</button>',
text,
)
return text
I have a code like this which replaces substrings which replaces patterns like (p.XX) and (p. XX) into HTML buttons. and I would like to run a python function when one of the buttons is clicked is there a way to implement this? or does anyone know any workarounds?
please feel free to suggest any ideas. the goal is to open a page in a pdf which is the source