showdownjs/showdown

Insert listItem on rule

開放

#636 建立於 2019年1月3日

 (3 則留言) (0 個反應) (1 位負責人)JavaScript (1,640 個分叉)batch import
help wanted

倉庫指標

星標
 (13,700 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Hi!

Sorry for opening an issue for a question but couldnt find any issue related.

I'm trying to insert a listItem from a rule, the idea is that I'm creating a custom markdown rule that should insert a custom list (LI) element but seems like I cant insert a <li> element without a parent <ul> (which makes sense).

This is a sample of what im trying to achieve:

{
      type: 'lang',
      regex: /(^|\n)(listitem)\n/g,
      replace() {
        return `<li>List Item</li>\n`;
      },
}

Any idea of how can I achieve this?

貢獻者指南