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

Mix of ' and " for xml string #991

Open
bettjoby opened this issue Aug 1, 2024 · 4 comments
Open

Mix of ' and " for xml string #991

bettjoby opened this issue Aug 1, 2024 · 4 comments

Comments

@bettjoby
Copy link

bettjoby commented Aug 1, 2024

Hi,

This is a really minor one, but would really help when debugging issue and comparing the generated xml. The code has a mix of single and double quotes for the xml string:

vs

for instance pptx/chart/xmlwriter.py it looks like PowerPoint uses/expects double quotes. When you open and save a generated PPTX in PowerPoint it converts all the single quotes to double.

@scanny
Copy link
Owner

scanny commented Aug 1, 2024

Can you be more specific? What minimal code demonstrates this behavior?

I happen to be in that neighborhood today so can fix it if it's easy.

@bettjoby
Copy link
Author

bettjoby commented Aug 1, 2024

Oh looks like the editor nuked my text in the orriginal is should have been:

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>

vs

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

Easy fix would be a global search and replace for the string with single quotes and replace with double

@scanny
Copy link
Owner

scanny commented Aug 1, 2024

What is the problem this causes for you? By default, lxml writes the XML declaration with single-quotes, so I'd be inclined to leave things as they are. However if you can find a place where we write double-quotes maybe that's the better fix.

And "by default" I also mean it's pretty hard to change because it doesn't let you choose.

@bettjoby
Copy link
Author

bettjoby commented Aug 1, 2024

I'm not really getting a problem with the module, I was trying to fix the transparent negative chart values I'm getting by comparing a pptx directly from python-pptx and the same pptx opened in PowerPoint fixed by hand and saved again. I got a huge amount of differences, but they were almost all just changing from single quotes to double quotes, so it seems PowerPoint uses double quotes.

I did a search on the code base and 83 files have the xml version line with single quotes (mostly under the doc dir) and 30 files have the line with double quotes, for instance:

image

As I said, it's not a big deal. Feel free just to close the issue.

BTW, this is how I fixed the negative chart values:

# Fix for negative values in a chart
for series in chart.series:
    for i in range(0, len(series.values)):
        series.points[i].invert_if_negative = False

    series.invert_if_negative = False

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

No branches or pull requests

2 participants