Skip to content

Lossless --embed-resources (Respect html5 download attr) #10693

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

Open
avidseeker opened this issue Mar 16, 2025 · 1 comment
Open

Lossless --embed-resources (Respect html5 download attr) #10693

avidseeker opened this issue Mar 16, 2025 · 1 comment

Comments

@avidseeker
Copy link

avidseeker commented Mar 16, 2025

example.html (converted from markdown using --embed-resources)

<img
	 src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADIBAMAAABIVCNkAAAAD1BMVEX//wD///8AAAD/AADOzgCL
PDnLAAAC+klEQVR4Xu3cwY3jMAyF4YfXQVgBSU8FVgeB+69pkb0sBhPFoihZO0H+qw8fBM0kMEIJ
t9mtET7CR/BHNknwR3jECpMSxB3fo/tIwRVPchsliON59CGCuKKae15wxcvckoLjLFpKcCBNIAjE
CQSBOIEgECcQBOIEYkCdCAuCWIwKogjmQUERzkKCIx4tIAh6YkBQdGXNgqAvNguKzqxRcPRGaxIE
/bFJUCSyBkGQieeCKFLZuYBcPBUUyexEEGTjiaBIZy8FQT4uFhQDsheCYER8ISiGZFVBMCZWBcWg
bJkgGBUrgmJYtkgQjItPBcXAbIkgGBmXCIqh2QJBMDYuEBSDs8sFwejYLLgruh7ad0GrwHHcvQLw
8VCTgh+PKv7XcTyIJkEqAI+/3eMPAQaEyiK+RghfR30RPH7ydUEnCLAGgUdVeOh1Pi4c+t8LghkC
I8IdaSH1t9Qg6BQBVhPi/9N54V7hmwUBMP6zFWBViH8/xIX61xgrD6NCPcdJaWHTHkHRHEtAgHUJ
+2Rhu0AoOlVguULYpwrbJULRiQLLNcIeFgStbUGBnULRaQLLVcI+TdguE4pOEliuE/ZJwnahUHSK
wNIt3DQs7FM++bZLhaITBJZrhX2CsF0sFB0usFwt7MOFLSVIh1B08BsKy3TBfxQTsq0Xboop2XsJ
Mmkb3ku46e8U7N0EmbIN7yTM2gi7WpBfKHD9L69hUc8EwfcYJDz+Czg1A4ANcwIMAOybRPB2QFsE
AdC729o7EcJGwtEk3LSX8MxkDjUO1AVBjYgDDMxg0fEq+oApr1cEFRFBUCHCAKPzfK4VWodNDPKZ
4Q5EBQGaDXdUY99sKP0fcvKeaN3zrWx7DeX8Gd03mGReMO89eBFcPXefXwRXn3/IL4Krz6HkF8H5
54EWn2nKbzZXny3LL4Krz/jlN9sWn7XMbwUXn3nNE7S1Z4/zBG39GfB6jb8nJQRxnEVfep9A/k4E
+ux7HWzt3RT5+zWW3BGy/p6TfB/hI+T7CB/hDzGSaEUAJj/hAAAAAElFTkSuQmCC">

Running

$ pandoc -f html --extract-media img example.html

results in img/[SHA1].png which is expected.

However, html5 offers download attribute which offers a way to mitigate against filename loss when embedding resources. E.g: <img download="smile.png" src="..."> should be converted to ![](img/smile.png) instead of ![](img/[SHA1].png).

@silby
Copy link
Contributor

silby commented Mar 31, 2025

I can't find any indication that the download attribute is standardized for use with <img>, only <a> (and <area>). If Pandoc grows the ability to round-trip the filenames of images through embedding and extracting, it probably would use a custom attribute (e.g. data-original-filename in the HTML output) rather than download.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants