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

Extension changes the DOM-location of JSON content in PRE tags #283

Open
broofa opened this issue Dec 11, 2024 · 0 comments
Open

Extension changes the DOM-location of JSON content in PRE tags #283

broofa opened this issue Dec 11, 2024 · 0 comments

Comments

@broofa
Copy link

broofa commented Dec 11, 2024

I have a very simple HTML document (minimal CSS styling) with a PRE-tag that contains some JSON. When JSON Formatter runs, it prettifies the JSON (which is useful... maybe... I guess? But definitely not expected), but unfortunately it moves the prettified content to the end of the document, which negates whatever value there might be in prettifying it.

Actual behavior

With JSON Formatter enabled:
CleanShot 2024-12-11 at 14 55 24

Expected behavior

This is what the document is supposed to look like:
CleanShot 2024-12-11 at 14 54 45

  • At a minimum, JSON Formatter should inject it's prettified-DOM version of the JSON into the DOM at the same location as the PRE tag it's replacing.
  • That said, I would really like to have way to disable this feature as an extension setting.
  • There should also be a way of disabling this setting at the DOM-element level. E.g. by setting a data-noformat attribute or something like that.

Here's the document markup in it's entirety, if that helps:

<html><head></head><body style="">

<style>
  body {
    padding: 1em;
    font-family: sans-serif;
    image-rendering: pixelated;
    color: whitesmoke;
    background: linear-gradient(#0a031c 0%, #3f55a6 44%, #b355ac 80%, #ebf8e1 80%, #f69d3c 100%);
  }
  .image_grid {
    box-sizing: border-box;
    max-width: 100%;
    display:grid;
    gap: 1em;
    justify-items: center;
    grid-template-columns: 1fr 1fr;
  }
  .image_grid img {
    box-sizing: border-box;
    max-width: 100%;
    padding: 2px;
    background: linear-gradient(315deg, rgba(255, 255, 255, .5), rgba(0, 0, 0, .5));
    border-radius: 0.5rem;
  }
  h3 {
    margin: 0;
  }
  code {
    color: #8afc95;
    font-weight: bold;
  }
</style>

<h1>poMMVJJ Screenshots</h1>

<h2>Render result</h2>
<pre>{
  "time": 1733957509,
  "tries": 14,
  "error": {
    "message": "Network connection lost."
  }
}</pre>

<h2>KV Entry</h2>
<div style="display: grid; gap: 0.5em 1em; grid-template-columns: minmax(100px, max-content) 1fr">
  
      <code style="text-align: right">poMMVJJ — </code>
      <code>{"time":1733957509,"tries":14,"error":{"message":"Network connection lost."}}</code>
    
</div>

  <h2>Images</h2>
  Screenshot not available. 😵‍💫
</body></html>
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

1 participant