| 137 | } |
| 138 | |
| 139 | func docsWriteMarkdownDocument(markdown preparedMarkdown) *docs.Document { |
| 140 | cleaned := markdown.cleaned |
| 141 | for _, image := range markdown.images { |
| 142 | cleaned = strings.ReplaceAll(cleaned, image.placeholder(), "") |
| 143 | } |
| 144 | |
| 145 | doc := &docs.Document{Body: &docs.Body{}} |
| 146 | index := int64(1) |
| 147 | elements := docsmarkdown.ParseMarkdown(cleaned) |
| 148 | docsmarkdown.StripElementHeadingAnchors(elements) |
| 149 | for _, element := range elements { |
| 150 | if element.Type == docsmarkdown.MDTable { |
| 151 | table, next := docsWriteMarkdownTable(element.TableCells, index) |
| 152 | if table != nil { |
| 153 | doc.Body.Content = append(doc.Body.Content, table) |
| 154 | index = next |
| 155 | } |
| 156 | continue |
| 157 | } |
| 158 | _, text, _ := docsmarkdown.MarkdownToDocsRequests([]docsmarkdown.MarkdownElement{element}, index, "") |
| 159 | if text == "" { |
| 160 | continue |
| 161 | } |
| 162 | doc.Body.Content = append(doc.Body.Content, docsWriteMarkdownParagraph(index, text)) |
| 163 | index += utf16Len(text) |
| 164 | } |
| 165 | return doc |
| 166 | } |
| 167 | |
| 168 | func docsWriteMarkdownTable(cells [][]string, index int64) (*docs.StructuralElement, int64) { |
| 169 | if len(cells) == 0 { |