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

使用HTMLDeserializer对codeblock进行反序列时,<br/>未正确转换为\n,导致代码未换行 #181

Open
paul-xiao opened this issue Oct 16, 2024 · 0 comments
Assignees

Comments

@paul-xiao
Copy link

Description
使用HTMLDeserializer对codeblock进行反序列时,<br/>未正确转换为\n,导致代码未换行,@big-camel 请确认一下呢。

Recording
示例代码如下:

  let domString = `<pre data-line-wrapping="false" data-syntax="plain" data-tab-size="2" data-theme="light" style="font-family:" source="" code="" pro",="" ui-monospace,="" sfmono-regular,="" menlo,="" monaco,="" consolas,="" "liberation="" mono",="" "courier="" new",="" monospace;font-size:14px;line-height:1.5;background-color:#fafafa;color:#232930;border-radius:4px;border:1px="" solid="" rgb(229="" 231="" 235="" 1);padding:4px="" 8px;"="">const count = 0<br><br>count++<br><br>console.log(count)</pre>`
  const document = new DOMParser().parseFromString(domString, 'text/html')
  const html = HTMLDeserializer.transformWithEditor(editor, document.body)
   console.log(html)

Actual Output
image

image

Expected Output
image

[
      {
        lineWrapping: false,
        theme: 'light',
        tabSize: 2,
        language: 'plain',
        code: 'const count = 0\ncount++\nconsole.log(count)',
        id: '1ovmmypwdbhc',
        type: 'codeblock',
        children: [
          {
            text: ''
          }
        ]
      }
    ]
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

2 participants