plotly / orca

Command line application for generating static images of interactive plotly charts
MIT License
292 stars 40 forks source link

Ampersands don't render in annotations of .emf files if " " is used in other text elements #371

Open michaelbabyn opened 3 years ago

michaelbabyn commented 3 years ago

If I input a json that uses   in title text using the below command, the & doesn't appear in annotations in .emf files (all other image types seem to work)

docker run -it -d -p 9091:9091 quay.io/plotly/image-exporter:4.1.0b642
curl -d @minimal-no-ampersand.json -H "accept: image/emf" localhost:9091 -o minimal-no-ampersand.emf

where minimal-no-ampersand.json looks like this

{
    "layout": {
        "yaxis": {
            "title": {
                "font": {
                    "size": 11
                },
                "text": "%{meta[1]} "
            }
        },
        "meta": [
            "Stacked Bar Chart Title",
            "A&W Hamburgers",
            "Y-axis label",
            "X-axis label",
            "A&W Hamburgers"
        ],
        "annotations": [
            {
                "text": "%{meta[4]} ",
                "align": "left",
                "xanchor": "left",
                "xref": "paper",
                "yref": "paper"
            }
        ]
    }
}

Screenshot from 2021-05-17 12-21-07

but this works (I just removed the   from the yaxis title text):

{
    "layout": {
        "yaxis": {
            "title": {
                "font": {
                    "size": 11
                },
                "text": "%{meta[1]}"
            }
        },
        "meta": [
            "Stacked Bar Chart Title",
            "A&W Hamburgers",
            "Y-axis label",
            "X-axis label",
            "A&W Hamburgers"
        ],
        "annotations": [
            {
                "text": "%{meta[4]} ",
                "align": "left",
                "xanchor": "left",
                "xref": "paper",
                "yref": "paper"
            }
        ]
    }
}

cc @plotly/techops

nicolaskruchten commented 3 years ago

Looks like a bug to me. @wbrgss can you please assign someone to investigate?