syntax-tree / hast-util-raw

utility to reparse a hast tree
https://unifiedjs.com
MIT License
11 stars 4 forks source link

Tag name cases for SVG in HTML #18

Closed wooorm closed 1 year ago

wooorm commented 1 year ago

Initial checklist

Affected packages and versions

latest

Link to runnable example

No response

Steps to reproduce

import assert from 'node:assert/strict'
import {toHtml} from 'hast-util-to-html'
import {toHast} from 'mdast-util-to-hast'
import {raw} from './index.js'

/** @type {import('mdast').Root} */
const mdast = {
  type: 'root',
  children: [
    {
      type: 'paragraph',
      children: [],
      data: {
        hChildren: [
          // The root element here doesn’t affect the output.
          // {
          //   type: 'root',
          //   children: [
          {
            type: 'element',
            tagName: 'svg',
            children: [
              {
                type: 'element',
                tagName: 'foreignObject',
                properties: {},
                children: [
                  {
                    type: 'element',
                    tagName: 'div',
                    children: []
                  }
                ]
              }
            ]
          }
          //   ],
          // },
        ]
      }
    }
  ]
}

const hast = toHast(mdast)
assert(hast)
console.dir(hast, {depth: null})
const hast2 = raw(hast)
console.dir(hast2, {depth: null})

const doc = toHtml(hast2)
console.log(doc)

See also: https://github.com/remcohaszing/remark-mermaidjs/issues/12#issuecomment-1339584921.

Expected behavior

foreignObject should be cased

Actual behavior

lowercased

Affected runtime and version

latest

Affected package manager and version

No response

Affected OS and version

No response

Build and bundle tools

No response

github-actions[bot] commented 1 year ago

Hi! This was marked as ready to be worked on! Note that while this is ready to be worked on, nothing is said about priority: it may take a while for this to be solved.

Is this something you can and want to work on?

Team: please use the area/* (to describe the scope of the change), platform/* (if this is related to a specific one), and semver/* and type/* labels to annotate this. If this is first-timers friendly, add good first issue and if this could use help, add help wanted.