Skip to content

xls: add configurable hyperlink hook (HandleHyperlink)#25

Open
ShivangNagta wants to merge 1 commit into
pbnjay:mainfrom
ShivangNagta:fix/xls-hyperlink-preserve-display-text
Open

xls: add configurable hyperlink hook (HandleHyperlink)#25
ShivangNagta wants to merge 1 commit into
pbnjay:mainfrom
ShivangNagta:fix/xls-hyperlink-preserve-display-text

Conversation

@ShivangNagta

Copy link
Copy Markdown

Background

When parsing .xls, the HLINK handler overwrites the anchor cell's value with
displayText + " <" + linkText + ">". This discards the cell's display text
(already read from the shared-string table) in favor of the HLINK record's own
display field, which is frequently empty or garbled - and callers had no way to
change it.

Change

  • Add HyperlinkFunc and the package-level HandleHyperlink hook
  • When HandleHyperlink is nil (default), behavior is unchanged (backward
    compatible).
  • Add PreserveDisplayText, a ready-made hook that keeps the cell's display
    text as the value and exposes the target via Cell.URL().

The HLINK handler hardcoded the anchor cell's value to
, overwriting the display text read
from the shared-string table with the HLINK record's own (often empty or
garbled) display field, and offered no way for callers to change this.

Add a HyperlinkFunc hook (HandleHyperlink) that lets callers decide how
hyperlink cells are rendered. When nil (the default) the historical
behavior is unchanged, so this is backward compatible. A ready-made
PreserveDisplayText hook keeps the cell's display text as the value and
exposes the target via Cell.URL()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant