0

I have become a fan of single-file web applications. Now I try to make it installable via an embedded manifest. Ideally I would like

  • to have the manifest directly editable (i.e. not base 64 - when using base64 here, the lines can be arbitrarily short)
  • not have very long lines as the icon data URI src attributes
<link rel="manifest" href='data:text/javascript,{"name":"my app name",
"short_name":"appshort",
"start_url":"https://some.url/this.html",
"icons":[{"src":"data:image/png;base64,iVBORw0KGg...(a lot more)"
...

The problem that I have is that I can not find a way to break the data:image/png;base64... lines.

Inserting a linebreak inbetween gives a Syntax error at the end of the line (all errors as shown in the DevTools under Application/Manifest).

Putting a \ before a linebreak gives Invalid escape sequence .

Putting \\ before a linebreak gives a Syntax error at the end of the line.

Using a single backtick ` to start and end the data:image/png... (which is a kind of javascript way to say ignore newlines in the string) gives a Syntax error at the start of the string.

I can put \n anywhere inside the long string but of course it will not make the line shorter.

Impossible? Suggestions? Thanks!

6
  • Sounds like an X/Y problem. Why do you not want long lines? My editors do not care. If you must, save the icons as images on a CDN and load them from there Commented Aug 6, 2024 at 14:10
  • I tested it with a normal image and it seems that HTML is ignoring all whitespace inside the base64 string. That means I can add as many spaces, new lines and tabs as I want inside of it. Have you tried this? So just a linebreak, no escaping, of course. See DEMO, but make the HTML window wide enough to see it properly. This might also work within the JSON inside your link tag..... or not. I think it will. Commented Aug 6, 2024 at 14:53
  • @mplungjan you are right, jedit gets slow with long lines, that is one of the reasons I do not like them. Commented Aug 6, 2024 at 15:47
  • @KIKOSoftware I tried that too, but somehow because it is nested it seems it does not work, see edit Commented Aug 6, 2024 at 15:47
  • 1
    @mplungjan this works outside of the nexted data-uri context, but not inside... :-( Commented Aug 7, 2024 at 7:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.