async def _handle_extract_metadata(self, input_file: str | PathLike[str]) -> Metadata:
        """Extract metadata from a file using Pandoc.

        Args:
            input_file: The file to extract metadata from

        Returns:
            The extracted metadata

        Raises:
            ParsingError: If metadata extraction fails
        """
        pandoc_type = self._get_pandoc_type_from_mime_type(self.mime_type)
        metadata_file, unlink = await create_temp_file(".json")
        try:
            command = [
                "pandoc",
                str(input_file),
                f"--from={pandoc_type}",
                "--to=json",
                "--standalone",
                "--quiet",
                "--output",
                str(metadata_file),
            ]

            result = await run_process(command)

            if result.returncode != 0:
                raise ParsingError(
                    "Failed to extract file data", context={"file": str(input_file), "error": result.stderr}
                )

            json_data = loads(await AsyncPath(metadata_file).read_text("utf-8"))
            return self._extract_metadata(json_data)
        except (RuntimeError, OSError, JSONDecodeError) as e:
            raise ParsingError("Failed to extract file data", context={"file": str(input_file)}) from e
        finally:
            await unlink()
Extract metadata from a file using Pandoc.

        Args:
            input_file: The file to extract metadata from

        Returns:
            The extracted metadata

        Raises:
            ParsingError: If metadata extraction fails
        
kreuzberg/_extractors/_pandoc.py