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

feat: Add support for embedded images #464

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MoritzWeber0
Copy link
Member

@MoritzWeber0 MoritzWeber0 commented Oct 22, 2024

Currently, embedded images are not handled properly. An embedded image link contains the name of the Capella project as first element of the path in the src attribute, but the path doesn't exist on the file system.

To resolve the issue, we remove the project name as prefix.

Open issues:

  • If the description is not modified but written back, there is an unintended diff. We have to make sure that the project name is added again in the _to_xml method. However, I don't have a stable solution how to identify embedded image links yet.
  • Tests should be added to cover embedded images.
  • It doesn't work if the image is referenced from another project.

Alternative solution could be to provide a description postprocessing helper function, which is used for the HTML rendering. This would solve the issue with broken image references in Jupyter.

Currently, embedded images are not handled properly.
An embedded image link contains the name of the Capella project as first
element of the path in the `src` attribute, but the path doesn't exist
on the file system.

To resolve the issue, we remove the project name as prefix.
@MoritzWeber0 MoritzWeber0 linked an issue Oct 22, 2024 that may be closed by this pull request
Copy link
Member

@Wuestengecko Wuestengecko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this!

An embedded image link contains the name of the Capella project as first element of the path in the src attribute

I think this first element here is the name of the "Eclipse-level" project, which is recorded in the .project file (and usually also used for the model itself, which is why model.info.title works - most of the time). This might be useful to figure out which resource to load from if there are multiple.

Comment on lines +106 to +108
def _from_xml(
self, value: str, model: capellambse.MelodyModel, /
) -> U: ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor thing: Please change the order to be self, model, value instead of self, value, model, for more consistency overall. (Almost) All functions that require a model expect it as first non-self argument.

It's an API break anyways, as old methods only expect a single argument.

Comment on lines +173 to +175
def _resolve_embedded_images(
self, value: str, model: capellambse.MelodyModel, /
) -> markupsafe.Markup:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, please use self, model, value.

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.

Handling of unembedded images
2 participants