Closed matt-dray closed 10 months ago
At least in the first instance, hyperlinks to the web and email (i.e. mailto:
) should be supported on the cover page (made easier by #102). It may make sense to support hyperlinks in pre-table metadata when linking to a web-based source, or if there's some arbitrary pre-table metadata that requires it (#74), whatever that may be. Internal hyperlinks could also be used in the case of linking to each tab from the contents tab (i.e. the 'Sheet name' column).
My expectation is that we should automatically add hyperlinks for users to the contents page, which would amount to either (a) inserting some markup that gets converted later to a hyperlink in generate_workbook()
, or (b) just handled entirely by generate_workbook()
(regardless of approach, there would probably need to be a logical argument or option to turn this on and off).
There's some slight awkwardness with this, though.
Let's say the user provides this to the tables
of create_a11ytable()
for the contents page:
contents_df <- tibble::tribble(
~"Sheet name", ~"Sheet title",
"Notes", "Notes",
"Table_1", "Example sheet title"
)
Which generates:
Sheet name | Sheet title |
---|---|
Notes | Notes |
Table_1 | Example sheet title |
If we want to auto-internal-hyperlink each sheet name in this table to the relevant sheet, then we can. But that assumes that the string in the 'Sheet name' column actually matches the name of the relevant column according to the a11ytables object, but the user could have supplied something slight different names.
Could handle this by warning the user if there's a mismatch? Or maybe just generate the contents page for the user automatically (#75) and handle all this on behalf of the user. Or the user has to specify a markdown link, which maybe looks like:
contents_df <- tibble::tribble(
~"Sheet name", ~"Sheet title",
"[Notes](Notes!A1)", "Notes",
"[Table_1](Table_1!A1)", "Example sheet title"
)
This is because the cell will ultimately be converted to =HYPERLINK(#Notes!A1)
. But then we'd need to expect users to know this esoteric sheet-name-bang-cell-reference hyperlink format. Could just ask them to supply only the appropriate sheet or tab name in the parentheses, but we may well need that cell reference later if we end up allowing multiple tables per sheet; it won't always be cell A1 that the hyperlink should link to.
The guidance says that hyperlinks should be:
{a11ytables} doesn't (currently) support (1), since subsections on the cover come in pairs: one subheading, one body. You currently would have to have a separate subheader/body to put in a hyperlink cell.
Re (2), {openxlsx} can insert formulas to the output spreadsheet with a string provided by the user.