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

Preserve image graphic in fragment when not found #885

Merged

Conversation

@dginev
Copy link
Collaborator

dginev commented Nov 15, 2017

So, one more interesting use case for me today, with an interesting issue.

I needed to run through some latex through latexml that was "detached" from its auxiliary files (crucially: images), but I wanted to eventually reconnect the HTML result to the original images. I am happy to do some post-processing after latexml, in essence all I needed was to have the includegraphics file argument preserved in the final src attribute of the HTML img tag.

That's really easy to do! And in fact should be better practice than the current master behavior, which is to leave an empty src="" attribute, which is technically invalid / discouraged HTML.

I also caught a tiny bug with one conditional (for activate latexmlc post-processing) and disabled a somewhat useless guard that stops you from using --graphicimages in certain modes. I think there are legitimate use cases now to allow that.

Maybe not the ideal fix - open to feedback. The true core of this PR is the line:

+    $node->setAttribute('imagesrc', $node->getAttribute('graphic'));

which is what I truly need.

P.S. I ended up laughing to myself after finally seeing (or yet again remembering?) the double entendre of the --graphicimages and --nographicimages options. To the careless observer this may look like we are running our own content safety filters!

@brucemiller brucemiller merged commit 4d39f5b into brucemiller:master Nov 16, 2017
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@brucemiller

This comment has been minimized.

Copy link
Owner

brucemiller commented Nov 16, 2017

Looks reasonable; Thanks!

@dginev dginev deleted the dginev:dographics-img-src-in-fragment branch Feb 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.