zerodevx / zero-md

Ridiculously simple zero-config markdown displayer
https://zerodevx.github.io/zero-md/
ISC License
423 stars 48 forks source link

Inline markdown doesn't work #107

Closed timonson closed 5 months ago

timonson commented 5 months ago

The following example doesn't show the rendered HTML but the raw markdown inside a code element:

<!doctype html>
<html lang="en">
  <head>
    <title></title>
    <meta name="description" content="" />
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="icon" href="data:," />
    <script
      type="module"
      src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@2/dist/zero-md.min.js"></script>
  </head>
  <body>
    <section id="markdown">
      <div class="markdown-wrapper">
        <zero-md>
          <script type="text/markdown">
            # Preisliste

            ## Webseite

            | ID  | Name    | Age | Occupation   |
            | --- | ------- | --- | ------------ |
            | 1   | Alice   | 29  | Engineer     |
            | 2   | Bob     | 35  | Designer     |
            | 3   | Charlie | 42  | Photographer |
            | 4   | Dana    | 28  | Chef         |
            | 5   | Edward  | 50  | Writer       |

            ## Dienste

            ## Hosting

            ## Marketing

            dsfdsfdsfdsfdsfdsfsdf
          </script>
        </zero-md>
      </div>
    </section>
  </body>
</html>
juntuu commented 5 months ago

The script element content is indented by (more than) 4 spaces, which indicates a code block in markdown. Thus, the rendering would be expected.

Also see previous issues: #98, #102

Removing the leading spaces fixes the example on my testing:

          <script type="text/markdown">
# Preisliste

## Webseite

| ID  | Name    | Age | Occupation   |
| --- | ------- | --- | ------------ |
| 1   | Alice   | 29  | Engineer     |
| 2   | Bob     | 35  | Designer     |
| 3   | Charlie | 42  | Photographer |
| 4   | Dana    | 28  | Chef         |
| 5   | Edward  | 50  | Writer       |

## Dienste

## Hosting

## Marketing

dsfdsfdsfdsfdsfdsfsdf
          </script>
timonson commented 5 months ago

Thank you, my code formatter did it automatically.