Skip to content

Commit 8a2193f

Browse files
committed
🐛 Fix(quarto_reportview.py): Fix png size issue on quarto reports, now the images are resized keeping their ratio
1 parent cdd7f5c commit 8a2193f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,5 @@ docs/images/UML_diagrams/
128128
docs/images/Graphical_abstract/
129129
docs/images/Nfcore_module_figure
130130
docs/presentations/
131-
docs/example_data/Earth_microbiome_vuegen_demo_notebook_test/
132-
docs/vuegen_case_study_earth_microbiome_test.ipynb
133-
test.py
131+
./basic_example_vuegen_demo_notebook_config.yaml
132+
./earth_microbiome_vuegen_demo_notebook_config.yaml

src/vuegen/quarto_reportview.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ def _create_yaml_header(self) -> str:
365365
r.ReportType.PDF: """
366366
pdf:
367367
toc: false
368+
fig-align: center
368369
margin:
369370
- bottom=40mm
370371
include-in-header:
@@ -568,7 +569,7 @@ def _generate_plot_content(self, plot) -> List[str]:
568569
try:
569570
if plot.plot_type == r.PlotType.STATIC:
570571
plot_content.append(
571-
self._generate_image_content(plot.file_path, width=950)
572+
self._generate_image_content(plot.file_path, width="95%")
572573
)
573574
elif plot.plot_type == r.PlotType.PLOTLY:
574575
plot_content.append(self._generate_plot_code(plot))
@@ -901,7 +902,7 @@ def _generate_html_content(self, html) -> List[str]:
901902
return html_content
902903

903904
def _generate_image_content(
904-
self, image_path: str, alt_text: str = "", width: int = 650, height: int = 400
905+
self, image_path: str, alt_text: str = "", width: str = "95%"
905906
) -> str:
906907
"""
907908
Adds an image to the content list in an HTML format with a specified width and height.
@@ -927,7 +928,7 @@ def _generate_image_content(
927928
else:
928929
src = get_relative_file_path(image_path, base_path="..").as_posix()
929930

930-
return f"""![]({src}){{fig-alt={alt_text} width={width} height={height}}}\n"""
931+
return f"""![]({src}){{fig-alt={alt_text} width={width}}}\n"""
931932

932933
def _generate_component_imports(self, component: r.Component) -> List[str]:
933934
"""

0 commit comments

Comments
 (0)