diff options
Diffstat (limited to 'element.go')
| -rw-r--r-- | element.go | 94 |
1 files changed, 0 insertions, 94 deletions
@@ -301,100 +301,6 @@ func (el *element) parseBlockAudio(doc *Document, line []byte) bool { return true } -// parseBlockImage parse the image block or line. -// The line parameter must not have "image::" block or "image:" macro prefix. -func (el *element) parseBlockImage(doc *Document, line []byte) bool { - var ( - attrBegin = bytes.IndexByte(line, '[') - - attr string - key string - val string - kv []string - - attrs [][]byte - src []byte - battr []byte - alt []byte - - attrEnd int - dot int - x int - ) - - if attrBegin < 0 { - return false - } - attrEnd = bytes.IndexByte(line, ']') - if attrEnd < 0 { - return false - } - - src = bytes.TrimRight(line[:attrBegin], " \t") - - if el.Attrs == nil { - el.Attrs = make(map[string]string) - } - src = applySubstitutions(doc, src) - el.Attrs[attrNameSrc] = string(src) - - attrs = bytes.Split(line[attrBegin+1:attrEnd], []byte(`,`)) - if el.Attrs == nil { - el.Attrs = make(map[string]string) - } - var hasWidth bool - for x, battr = range attrs { - attr = string(battr) - if x == 0 { - alt = bytes.TrimSpace(attrs[0]) - if len(alt) == 0 { - dot = bytes.IndexByte(src, '.') - if dot > 0 { - alt = src[:dot] - } - } - el.Attrs[attrNameAlt] = string(alt) - continue - } - if x == 1 { - if ascii.IsDigits(attrs[1]) { - el.Attrs[attrNameWidth] = string(attrs[1]) - hasWidth = true - continue - } - } - if hasWidth && x == 2 { - if ascii.IsDigits(attrs[2]) { - el.Attrs[attrNameHeight] = string(attrs[2]) - } - } - kv = strings.SplitN(attr, `=`, 2) - if len(kv) != 2 { - continue - } - key = strings.TrimSpace(kv[0]) - val = strings.Trim(kv[1], `"`) - switch key { - case attrNameFloat, attrNameAlign, attrNameRole: - if val == `center` { - val = `text-center` - } - el.addRole(val) - default: - el.Attrs[key] = val - } - } - - for key, val = range el.Attrs { - if key == attrNameLink { - val = string(applySubstitutions(doc, []byte(val))) - el.Attrs[key] = val - } - } - - return true -} - func (el *element) parseInlineMarkup(doc *Document, kind int) { if len(el.raw) == 0 { return |
