-
-
Notifications
You must be signed in to change notification settings - Fork 604
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
Scale images based on Pandoc classes #3608
base: develop
Are you sure you want to change the base?
Conversation
Scale images based on Pandoc classes
Thank you for opening your first PR! 🎉 We are very happy and would like to thank you very much for your contribution. If everything checks out, we'll make sure to review the PR as soon as possible and give feedback. In the meantime, to make the reviewing process as fast as possible, you can help us by checking the following things:
Furthermore, make sure that the linter does not complain, which will check your code on every new commit. If the linter task fails, make sure to run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general looks good, however a few questions:
- Unfortunately, GitHub displayed the file as if it had been removed and completely written from scratch. After turning off Whitespace change, it worked like a charm. Did you accidentally exchange, e.g., spaces with tabs, or LF with CRLF…?
- There are two critical issues we have to think about: (a) the metrics question I've already posed, and (b) how to handle the settings'
maxPreviewWidth
andmaxPreviewHeight
?
let heightAttribute = '' | ||
if (match[4] !== '') { | ||
// Use regex to parse pandoc attributes | ||
// like width="3.69in" height="1.93884in" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two questions: 1) are quotes required? If not one should account for that in below's regexp. 2) Regarding size attributes: Obviously, for preview-reasons we don't need to accurately represent inches etc., but what are the options for measures people have, and how should we maybe account for that? (50% width is easy to accomplish, but how much are 3.5 inches relative to the editor area?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try to use pandoc to import docx documents. The attribute generated by pandoc is in inches. Every available length unit in CSS images can be used here. For the absolute length units (cm mm in px), its size is fixed, does not change with the window, and corresponds to the same px (1in = 96px).
As for the maxPreviewWidth and maxPreviewHeight, if absolute length units are used, conversion is required. I don't know how to calculate it.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Description
This PR is for scale images in issue #1328. Documents imported with pandoc usually contain image size information, such as:
![](image1.png){width="3.69in" height="1.93884in"}
So just parse the information in braces and pass it to the corresponding attribute to control image size.
Changes
Additional information
Tested on: macOS 12.4 Monterey Apple Silicon