syntax-tree/hast-util-raw

Tag name cases for SVG in HTML

wooorm opened this issue · 1 comments

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: remcohaszing/remark-mermaidjs#12 (comment).

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

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.