Skip to content

Commit

Permalink
feat: add support for relative width
Browse files Browse the repository at this point in the history
- Change: The `width` option can now accept an integer percentage as
  its value.
- Change: When `width` is relative, `height` is ignored and a warning
  is logged.
  • Loading branch information
AnonymouX47 committed Nov 6, 2024
1 parent 60ec268 commit 78d10e0
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions sphinxcontrib/video/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,30 @@ def run(self) -> List[video_node]:
env: BuildEnvironment = self.env

# check options that need to be specific values
height: str = self.options.get("height", "")
if height and not height.isdigit():
logger.warning(
f'The provided height ("{height}") is ignored as it\'s not an integer'
)
height = ""

width: str = self.options.get("width", "")
if width and not width.isdigit():
if width and not (width.isdigit() or width[-1] == "%" and width[:-1].isdigit()):
logger.warning(
f'The provided width ("{width}") is ignored as it\'s not an integer'
f'The provided width ("{width}") is ignored as it\'s not an integer '
"or integer percentage"
)
width = ""

height: str = self.options.get("height", "")
if height:
if width.endswith("%"):
logger.warning(
f'The provided height ("{height}") is ignored as the provided '
f'width ("{width}") is relative'
)
height = ""
elif not height.isdigit():
logger.warning(
f'The provided height ("{height}") is ignored as it\'s not an '
"integer"
)
height = ""

preload: str = self.options.get("preload", "auto")
valid_preload = ["auto", "metadata", "none"]
if preload not in valid_preload:
Expand Down

0 comments on commit 78d10e0

Please sign in to comment.