MCPcopy Create free account
hub / github.com/openclaw/gogcli / docsWriteMarkdownDocument

Function docsWriteMarkdownDocument

internal/cmd/docs_write_orphans.go:139–166  ·  view source on GitHub ↗
(markdown preparedMarkdown)

Source from the content-addressed store, hash-verified

137}
138
139func 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
168func docsWriteMarkdownTable(cells [][]string, index int64) (*docs.StructuralElement, int64) {
169 if len(cells) == 0 {

Calls 7

ParseMarkdownFunction · 0.92
MarkdownToDocsRequestsFunction · 0.92
docsWriteMarkdownTableFunction · 0.85
placeholderMethod · 0.80
utf16LenFunction · 0.70