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

调用 HTML2Markdown 转换多级嵌套列表丢失内容 #72

Closed
degbug opened this issue Jun 21, 2020 · 3 comments
Closed

调用 HTML2Markdown 转换多级嵌套列表丢失内容 #72

degbug opened this issue Jun 21, 2020 · 3 comments
Assignees

Comments

@degbug
Copy link

degbug commented Jun 21, 2020

请先看《提问的智慧》,并尝试到黑客派搜寻资料解决问题。


描述问题

如下代码的多级列表无法正常解析

package main

import (
	"fmt"

	"github.com/88250/lute"
)

func main() {
	luteEngine := lute.New() // GFM support and Chinese context optimization have been enabled by default
	md, _ := luteEngine.HTML2Markdown(`
<ul>
  <li>咖啡</li>
  <li>茶
    <ul>
    <li>红茶</li>
    <li>绿茶</li>
    </ul>
  </li>
  <li>牛奶</li>
</ul>
	`)
	fmt.Println(md)
	// <p><strong>Lute</strong> - A structured Markdown engine.</p>
}

出来的结果如下:
image

我把ul标签从li中提取出来是可以的:

<ul>
  <li>咖啡</li>
  <li>茶</li>
  <ul>
    <li>红茶</li>
    <li>绿茶</li>
    </ul>
  <li>牛奶</li>
</ul>

结果:

* 咖啡
* 茶
  * 红茶
  * 绿茶
* 牛奶

但是这种方式如果有多个嵌套的话,就不行了,如:

<ul>
  <li>咖啡</li>
  <li>茶</li>
  <ul>
    <li>红茶</li>
    <li>绿茶</li>
    </ul>
  <li>牛奶</li>
  <li>茶1</li>
  <ul>
    <li>红茶1</li>
    <li>绿茶1</li>
  </ul>
  <li>牛奶1</li>
</ul>

出来的结果是:
image

第二个嵌套的列表就不正确了。

语法上来讲,嵌套的列表应该就是第一段代码那样的吧,在li中嵌入ul标签?

期待的结果

正确解析多级嵌套列表

截屏或录像

如果可能,请尽量附加截图或录像来描述你遇到的问题。

其他信息

请提供其他附加信息帮助我们诊断问题。

@88250 88250 self-assigned this Jun 21, 2020
@88250
Copy link
Owner

88250 commented Jun 21, 2020

li 中 ul 是正确的。稍后进行修复,感谢。

@88250
Copy link
Owner

88250 commented Jun 21, 2020

已经修复,请升级到 v1.4.9

@degbug
Copy link
Author

degbug commented Jun 22, 2020

可以了!👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants