MCPcopy
hub / github.com/russross/blackfriday / tableHeader

Method tableHeader

block.go:786–897  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

784}
785
786func (p *Markdown) tableHeader(data []byte) (size int, columns []CellAlignFlags) {
787 i := 0
788 colCount := 1
789 for i = 0; i < len(data) && data[i] != '\n'; i++ {
790 if data[i] == '|' && !isBackslashEscaped(data, i) {
791 colCount++
792 }
793 }
794
795 // doesn't look like a table header
796 if colCount == 1 {
797 return
798 }
799
800 // include the newline in the data sent to tableRow
801 j := i
802 if j < len(data) && data[j] == '\n' {
803 j++
804 }
805 header := data[:j]
806
807 // column count ignores pipes at beginning or end of line
808 if data[0] == '|' {
809 colCount--
810 }
811 if i > 2 && data[i-1] == '|' && !isBackslashEscaped(data, i-1) {
812 colCount--
813 }
814
815 columns = make([]CellAlignFlags, colCount)
816
817 // move on to the header underline
818 i++
819 if i >= len(data) {
820 return
821 }
822
823 if data[i] == '|' && !isBackslashEscaped(data, i) {
824 i++
825 }
826 i = skipChar(data, i, ' ')
827
828 // each column header is of form: / *:?-+:? *|/ with # dashes + # colons >= 3
829 // and trailing | optional on last column
830 col := 0
831 for i < len(data) && data[i] != '\n' {
832 dashes := 0
833
834 if data[i] == ':' {
835 i++
836 columns[col] |= TableAlignmentLeft
837 dashes++
838 }
839 for i < len(data) && data[i] == '-' {
840 i++
841 dashes++
842 }
843 if i < len(data) && data[i] == ':' {

Callers 1

tableMethod · 0.95

Calls 4

addBlockMethod · 0.95
tableRowMethod · 0.95
isBackslashEscapedFunction · 0.85
skipCharFunction · 0.85

Tested by

no test coverage detected