зеркало из https://github.com/golang/tools.git
present: support markdown table
This commit is contained in:
Родитель
8e7acdbce8
Коммит
6cb8527425
|
@ -22,6 +22,7 @@ import (
|
|||
|
||||
"github.com/yuin/goldmark"
|
||||
"github.com/yuin/goldmark/ast"
|
||||
"github.com/yuin/goldmark/extension"
|
||||
"github.com/yuin/goldmark/renderer/html"
|
||||
"github.com/yuin/goldmark/text"
|
||||
)
|
||||
|
@ -698,7 +699,7 @@ func trimSpeakerNote(s string) string {
|
|||
}
|
||||
|
||||
func renderMarkdown(input []byte) (template.HTML, error) {
|
||||
md := goldmark.New(goldmark.WithRendererOptions(html.WithUnsafe()))
|
||||
md := goldmark.New(goldmark.WithRendererOptions(html.WithUnsafe()), goldmark.WithExtensions(extension.Table))
|
||||
reader := text.NewReader(input)
|
||||
doc := md.Parser().Parse(reader)
|
||||
fixupMarkdown(doc)
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
# Title
|
||||
Subtitle
|
||||
|
||||
Name
|
||||
|
||||
## table
|
||||
|
||||
| foo | bar |
|
||||
| --- | --- |
|
||||
| baz | bim |
|
||||
|
||||
---
|
||||
<h1>Title</h1>
|
||||
<h2>Subtitle</h2>
|
||||
<author>
|
||||
<p>Name</p>
|
||||
</author>
|
||||
<section>
|
||||
<h2 id="TOC_1.">table</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>foo</th>
|
||||
<th>bar</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>baz</td>
|
||||
<td>bim</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
Загрузка…
Ссылка в новой задаче