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

Allow conditional or alternative images in markdown #1398

Closed
gaborcsardi opened this issue Jul 11, 2022 · 1 comment · Fixed by #1399
Closed

Allow conditional or alternative images in markdown #1398

gaborcsardi opened this issue Jul 11, 2022 · 1 comment · Fixed by #1399
Labels
feature a feature request or enhancement

Comments

@gaborcsardi
Copy link
Member

gaborcsardi commented Jul 11, 2022

WRE suggests SVG + PDF for nice images in HTML and PDF:

\if{html}{\figure{Rlogo.svg}{options: width=100 alt="R logo"}}
\if{latex}{\figure{Rlogo.pdf}{options: width=0.5in}}

https://cran.r-project.org/doc/manuals/R-exts.html#Figures

As a first step we could support conditional images. My use case is adding SVG images to the HTML manual, and I don't mind if they are omitted from the PDF manual.

Ideally we would also support images created by code blocks, in addition to the ones put in "manually" with the markdown image syntax.

@gaborcsardi gaborcsardi added the feature a feature request or enhancement label Jul 11, 2022
@gaborcsardi
Copy link
Member Author

We could also select the output format automatically. E.g. If it is an SVG, it should be HTML only. If it is a PDF, it should be PDF only. GIF, JPEG, PNG are good for both. WRE says that these are the only types that are handled by default:

Files with extensions .jpg, .jpeg, .pdf, .png and .svg from that directory will be copied to the help/figures directory at install time.

gaborcsardi added a commit that referenced this issue Jul 11, 2022
This is currently opt in. If you set `restrict_image_formats`
to `TRUE`, then SVG images are HTML-only and PDF images are
PDF-only. Other file types are not restricted.

We could try to make it opt out, because SVGs do not work in
LaTeX and PDFs most of the time do not work in HTML.

If it is opt in, then we don't necessarily need a NEWS item
to try this out, but if it ends up being opt out, then we
do and we also need to document it,

Closes #1398.
gaborcsardi added a commit that referenced this issue Jul 11, 2022
This is currently opt in. If you set `restrict_image_formats`
to `TRUE`, then SVG images are HTML-only and PDF images are
PDF-only. Other file types are not restricted.

We could try to make it opt out, because SVGs do not work in
LaTeX and PDFs most of the time do not work in HTML.

If it is opt in, then we don't necessarily need a NEWS item
to try this out, but if it ends up being opt out, then we
do and we also need to document it,

Closes #1398.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant