Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supply google slide notes to fig.alt #119

Open
cansavvy opened this issue Sep 20, 2023 · 5 comments
Open

Supply google slide notes to fig.alt #119

cansavvy opened this issue Sep 20, 2023 · 5 comments
Assignees

Comments

@cansavvy
Copy link
Contributor

If no fig.alt is specified in the options, we want ottrpal to try to grab captions from the google slide notes and use that for the fig.alt option.

This will involve making some tweaks to the include_slide() function so that it checks for fig.alt spec and if none is given uses get_object_id_notes() function to get the notes and supply those as the fig.alt spec.

Happy to pair code on this where needed @howardbaek

@cansavvy
Copy link
Contributor Author

For example:

We need google slide notes to be captions and vice versa for accessibility and for loqui video making.

So when people set fig.alt this is what happens when you hover your mouse over the image.
Screenshot 2023-09-22 at 2 36 26 PM

But we want this to automatically happen without us specifying a fig.alt option like this:

{r, echo = FALSE, fig.alt= "Major point!! example image"}
ottrpal::include_slide("https://docs.google.com/presentation/d/1YmwKdIy9BeQ3EShgZhvtb3MgR8P6iDX4DfFD65W_gdQ/edit#slide=id.gcc4fbee202_0_141")

Instead, we want to grab from Google slide notes to make the fig.alt so we don't have to specifiy UNLESS we want to OVERRIDE that caption from Google slides.

{r, echo = FALSE}
ottrpal::include_slide("https://docs.google.com/presentation/d/1YmwKdIy9BeQ3EShgZhvtb3MgR8P6iDX4DfFD65W_gdQ/edit#slide=id.gcc4fbee202_0_141")

The flow will look like this:

  • Check if an image has a fig.alt spec. If not:
  • Check if an image has Google slide notes (use the thing you worked on get_object_id_notes()). If not:
  • Then put blank text.

This will involve edits to ottrpal::include_slide function and things it calls.

@howardbaek howardbaek changed the title make it so ottrpal automatically supplies the google slide notes as the fig.alt if none is specified. Supply google slide notes to fig.alt Sep 25, 2023
@howardbaek
Copy link
Member

Regarding the flow, if the image does NOT have Google Slide notes, should we put something like "Alt text is empty"?

@howardbaek
Copy link
Member

howardbaek commented Sep 27, 2023

@cansavvy and I tried setting the current code chunk inside include_slide() with

include_slide <- function(url, output_dir = knitr::opts_chunk$get("fig.path"), overwrite = TRUE, ...) {

 # If fig.alt is not set
  if (is.null(knitr::opts_current$get("fig.alt")) {
    # Insert code to grab the individual google slide notes
    gs_notes <- "individual slide notes"
   
   # Unlock opts_current before calling $set()
    knitr::opts_current$lock(FALSE)

    # Try to set the fig.alt option
    knitr::opts_current$set(fig.alt = gs_notes)

    # Other ways we tried to set fig.alt:
    # options$fig.alt <- gs_notes
    # knitr::include_graphics(outfile, fig.alt = gs_notes)
  }
  outfile <- gs_png_download(url, output_dir, overwrite = overwrite)
  knitr::include_graphics(outfile, ...)
}

and failed.

To ask for help, I left a comment on a knitr issue: yihui/knitr#1798 (comment) and asked on Posit community: https://community.rstudio.com/t/setting-fig-alt-using-knitr-knit-hooks/174159

@howardbaek howardbaek linked a pull request Oct 2, 2023 that will close this issue
@sckott
Copy link

sckott commented Nov 2, 2023

What about eval https://stackoverflow.com/a/47399915

@howardbaek
Copy link
Member

@sckott Could you elaborate more? I can't figure out how this relates to the fig.alt chunk option

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 a pull request may close this issue.

3 participants