all repos — grayfriday @ 55cde00c8ab66a2037b219eb4ae96d8e30e272fe

blackfriday fork with a few changes

camel case
Russ Ross russ@russross.com
Tue, 28 Jun 2011 16:02:12 -0600
commit

55cde00c8ab66a2037b219eb4ae96d8e30e272fe

parent

c969dff782e8f7f5ce3b64d8c48715a4cae47b5d

5 files changed, 211 insertions(+), 211 deletions(-)

jump to
M block.goblock.go

@@ -234,7 +234,7 @@

return 0 } -func blockHtml(out *bytes.Buffer, rndr *render, data []byte, do_render bool) int { +func blockHtml(out *bytes.Buffer, rndr *render, data []byte, doRender bool) int { var i, j int // identify the opening tag

@@ -261,7 +261,7 @@ }

if j > 0 { size := i + j - if do_render && rndr.mk.BlockHtml != nil { + if doRender && rndr.mk.BlockHtml != nil { rndr.mk.BlockHtml(out, data[:size], rndr.mk.Opaque) } return size

@@ -283,7 +283,7 @@ i++

j = isEmpty(data[i:]) if j > 0 { size := i + j - if do_render && rndr.mk.BlockHtml != nil { + if doRender && rndr.mk.BlockHtml != nil { rndr.mk.BlockHtml(out, data[:size], rndr.mk.Opaque) } return size

@@ -329,7 +329,7 @@ return 0

} // the end of the block has been found - if do_render && rndr.mk.BlockHtml != nil { + if doRender && rndr.mk.BlockHtml != nil { rndr.mk.BlockHtml(out, data[:i], rndr.mk.Opaque) }

@@ -345,7 +345,7 @@ if i >= len(data) {

return "", false } key := string(data[:i]) - if block_tags[key] { + if blockTags[key] { return key, true } return "", false

@@ -478,11 +478,11 @@ for i < len(data) && (data[i] == ' ' || data[i] == '\t') {

i++ } - syntax_start := i + syntaxStart := i if i < len(data) && data[i] == '{' { i++ - syntax_start++ + syntaxStart++ for i < len(data) && data[i] != '}' && data[i] != '\n' { syn++

@@ -495,12 +495,12 @@ }

// strip all whitespace at the beginning and the end // of the {} block - for syn > 0 && isspace(data[syntax_start]) { - syntax_start++ + for syn > 0 && isspace(data[syntaxStart]) { + syntaxStart++ syn-- } - for syn > 0 && isspace(data[syntax_start+syn-1]) { + for syn > 0 && isspace(data[syntaxStart+syn-1]) { syn-- }

@@ -512,7 +512,7 @@ i++

} } - language := string(data[syntax_start : syntax_start+syn]) + language := string(data[syntaxStart : syntaxStart+syn]) *syntax = &language }

@@ -536,9 +536,9 @@

var work bytes.Buffer for beg < len(data) { - fence_end, _ := isFencedCode(data[beg:], nil, marker) - if fence_end != 0 { - beg += fence_end + fenceEnd, _ := isFencedCode(data[beg:], nil, marker) + if fenceEnd != 0 { + beg += fenceEnd break }

@@ -579,16 +579,16 @@ return beg

} func blockTable(out *bytes.Buffer, rndr *render, data []byte) int { - var header_work bytes.Buffer - i, columns, col_data := blockTableHeader(&header_work, rndr, data) + var headerWork bytes.Buffer + i, columns, colData := blockTableHeader(&headerWork, rndr, data) if i == 0 { return 0 } - var body_work bytes.Buffer + var bodyWork bytes.Buffer for i < len(data) { - pipes, row_start := 0, i + pipes, rowStart := 0, i for ; i < len(data) && data[i] != '\n'; i++ { if data[i] == '|' { pipes++

@@ -596,24 +596,24 @@ }

} if pipes == 0 || i == len(data) { - i = row_start + i = rowStart break } - blockTableRow(&body_work, rndr, data[row_start:i], columns, col_data) + blockTableRow(&bodyWork, rndr, data[rowStart:i], columns, colData) i++ } if rndr.mk.Table != nil { - rndr.mk.Table(out, header_work.Bytes(), body_work.Bytes(), col_data, rndr.mk.Opaque) + rndr.mk.Table(out, headerWork.Bytes(), bodyWork.Bytes(), colData, rndr.mk.Opaque) } return i } -func blockTableHeader(out *bytes.Buffer, rndr *render, data []byte) (size int, columns int, column_data []int) { +func blockTableHeader(out *bytes.Buffer, rndr *render, data []byte) (size int, columns int, columnData []int) { i, pipes := 0, 0 - column_data = []int{} + columnData = []int{} for i = 0; i < len(data) && data[i] != '\n'; i++ { if data[i] == '|' { pipes++

@@ -621,10 +621,10 @@ }

} if i == len(data) || pipes == 0 { - return 0, 0, column_data + return 0, 0, columnData } - header_end := i + headerEnd := i if data[0] == '|' { pipes--

@@ -635,7 +635,7 @@ pipes--

} columns = pipes + 1 - column_data = make([]int, columns) + columnData = make([]int, columns) // parse the header underline i++

@@ -643,41 +643,41 @@ if i < len(data) && data[i] == '|' {

i++ } - under_end := i - for under_end < len(data) && data[under_end] != '\n' { - under_end++ + underEnd := i + for underEnd < len(data) && data[underEnd] != '\n' { + underEnd++ } col := 0 - for ; col < columns && i < under_end; col++ { + for ; col < columns && i < underEnd; col++ { dashes := 0 - for i < under_end && (data[i] == ' ' || data[i] == '\t') { + for i < underEnd && (data[i] == ' ' || data[i] == '\t') { i++ } if data[i] == ':' { i++ - column_data[col] |= TABLE_ALIGNMENT_LEFT + columnData[col] |= TABLE_ALIGNMENT_LEFT dashes++ } - for i < under_end && data[i] == '-' { + for i < underEnd && data[i] == '-' { i++ dashes++ } - if i < under_end && data[i] == ':' { + if i < underEnd && data[i] == ':' { i++ - column_data[col] |= TABLE_ALIGNMENT_RIGHT + columnData[col] |= TABLE_ALIGNMENT_RIGHT dashes++ } - for i < under_end && (data[i] == ' ' || data[i] == '\t') { + for i < underEnd && (data[i] == ' ' || data[i] == '\t') { i++ } - if i < under_end && data[i] != '|' { + if i < underEnd && data[i] != '|' { break }

@@ -689,17 +689,17 @@ i++

} if col < columns { - return 0, 0, column_data + return 0, 0, columnData } - blockTableRow(out, rndr, data[:header_end], columns, column_data) - size = under_end + 1 + blockTableRow(out, rndr, data[:headerEnd], columns, columnData) + size = underEnd + 1 return } -func blockTableRow(out *bytes.Buffer, rndr *render, data []byte, columns int, col_data []int) { +func blockTableRow(out *bytes.Buffer, rndr *render, data []byte, columns int, colData []int) { i, col := 0, 0 - var row_work bytes.Buffer + var rowWork bytes.Buffer if i < len(data) && data[i] == '|' { i++

@@ -710,45 +710,45 @@ for i < len(data) && isspace(data[i]) {

i++ } - cell_start := i + cellStart := i for i < len(data) && data[i] != '|' { i++ } - cell_end := i - 1 + cellEnd := i - 1 - for cell_end > cell_start && isspace(data[cell_end]) { - cell_end-- + for cellEnd > cellStart && isspace(data[cellEnd]) { + cellEnd-- } - var cell_work bytes.Buffer - parseInline(&cell_work, rndr, data[cell_start:cell_end+1]) + var cellWork bytes.Buffer + parseInline(&cellWork, rndr, data[cellStart:cellEnd+1]) if rndr.mk.TableCell != nil { cdata := 0 - if col < len(col_data) { - cdata = col_data[col] + if col < len(colData) { + cdata = colData[col] } - rndr.mk.TableCell(&row_work, cell_work.Bytes(), cdata, rndr.mk.Opaque) + rndr.mk.TableCell(&rowWork, cellWork.Bytes(), cdata, rndr.mk.Opaque) } i++ } for ; col < columns; col++ { - empty_cell := []byte{} + emptyCell := []byte{} if rndr.mk.TableCell != nil { cdata := 0 - if col < len(col_data) { - cdata = col_data[col] + if col < len(colData) { + cdata = colData[col] } - rndr.mk.TableCell(&row_work, empty_cell, cdata, rndr.mk.Opaque) + rndr.mk.TableCell(&rowWork, emptyCell, cdata, rndr.mk.Opaque) } } if rndr.mk.TableRow != nil { - rndr.mk.TableRow(out, row_work.Bytes(), rndr.mk.Opaque) + rndr.mk.TableRow(out, rowWork.Bytes(), rndr.mk.Opaque) } }

@@ -957,7 +957,7 @@ work.Write(data[beg:end])

beg = end // process the following lines - contains_blank_line, contains_block := false, false + containsBlankLine, containsBlock := false, false for beg < len(data) { end++

@@ -967,7 +967,7 @@ }

// process an empty line if isEmpty(data[beg:end]) > 0 { - contains_blank_line = true + containsBlankLine = true beg = end continue }

@@ -991,8 +991,8 @@ chunk := data[beg+i : end]

// check for a nested list item if (blockUliPrefix(chunk) > 0 && !isHRule(chunk)) || blockOliPrefix(chunk) > 0 { - if contains_blank_line { - contains_block = true + if containsBlankLine { + containsBlock = true } // the following item must have the same indentation

@@ -1007,26 +1007,26 @@ } else {

// how about a nested prefix header? if isPrefixHeader(rndr, chunk) { // only nest headers that are indented - if contains_blank_line && i < 4 && data[beg] != '\t' { + if containsBlankLine && i < 4 && data[beg] != '\t' { *flags |= LIST_ITEM_END_OF_LIST break } - contains_block = true + containsBlock = true } else { // only join stuff after empty lines when indented - if contains_blank_line && i < 4 && data[beg] != '\t' { + if containsBlankLine && i < 4 && data[beg] != '\t' { *flags |= LIST_ITEM_END_OF_LIST break } else { - if contains_blank_line { + if containsBlankLine { work.WriteByte('\n') - contains_block = true + containsBlock = true } } } } - contains_blank_line = false + containsBlankLine = false // add the line into the working buffer without prefix work.Write(data[beg+i : end])

@@ -1034,7 +1034,7 @@ beg = end

} // render li contents - if contains_block { + if containsBlock { *flags |= LIST_ITEM_CONTAINS_BLOCK }
M html.gohtml.go

@@ -615,13 +615,13 @@ for i < len(tag) && isspace(tag[i]) {

i++ } - tag_i := i - for ; i < len(tag); i, tag_i = i+1, tag_i+1 { - if tag_i >= len(tagname) { + j := i + for ; i < len(tag); i, j = i+1, j+1 { + if j >= len(tagname) { break } - if tag[i] != tagname[tag_i] { + if tag[i] != tagname[j] { return false } }
M inline.goinline.go

@@ -132,21 +132,21 @@ return 0

} // trim outside whitespace - f_begin := nb - for f_begin < end && (data[f_begin] == ' ' || data[f_begin] == '\t') { - f_begin++ + fBegin := nb + for fBegin < end && (data[fBegin] == ' ' || data[fBegin] == '\t') { + fBegin++ } - f_end := end - nb - for f_end > f_begin && (data[f_end-1] == ' ' || data[f_end-1] == '\t') { - f_end-- + fEnd := end - nb + for fEnd > fBegin && (data[fEnd-1] == ' ' || data[fEnd-1] == '\t') { + fEnd-- } // render the code span if rndr.mk.CodeSpan == nil { return 0 } - if rndr.mk.CodeSpan(out, data[f_begin:f_end], rndr.mk.Opaque) == 0 { + if rndr.mk.CodeSpan(out, data[fBegin:fEnd], rndr.mk.Opaque) == 0 { end = 0 }

@@ -196,7 +196,7 @@ data = data[offset:]

i := 1 var title, link []byte - text_has_nl := false + textHasNl := false // check whether the correct renderer exists if (isImg && rndr.mk.Image == nil) || (!isImg && rndr.mk.Link == nil) {

@@ -207,7 +207,7 @@ // look for the matching closing bracket

for level := 1; level > 0 && i < len(data); i++ { switch { case data[i] == '\n': - text_has_nl = true + textHasNl = true case data[i-1] == '\\': continue

@@ -227,7 +227,7 @@ if i >= len(data) {

return 0 } - txt_e := i + txtE := i i++ // skip any amount of whitespace or newline

@@ -246,7 +246,7 @@ for i < len(data) && isspace(data[i]) {

i++ } - link_b := i + linkB := i // look for link end: ' " ) for i < len(data) {

@@ -263,13 +263,13 @@

if i >= len(data) { return 0 } - link_e := i + linkE := i // look for title end if present - title_b, title_e := 0, 0 + titleB, titleE := 0, 0 if data[i] == '\'' || data[i] == '"' { i++ - title_b = i + titleB = i for i < len(data) { if data[i] == '\\' {

@@ -287,38 +287,38 @@ return 0

} // skip whitespace after title - title_e = i - 1 - for title_e > title_b && isspace(data[title_e]) { - title_e-- + titleE = i - 1 + for titleE > titleB && isspace(data[titleE]) { + titleE-- } // check for closing quote presence - if data[title_e] != '\'' && data[title_e] != '"' { - title_b, title_e = 0, 0 - link_e = i + if data[titleE] != '\'' && data[titleE] != '"' { + titleB, titleE = 0, 0 + linkE = i } } // remove whitespace at the end of the link - for link_e > link_b && isspace(data[link_e-1]) { - link_e-- + for linkE > linkB && isspace(data[linkE-1]) { + linkE-- } // remove optional angle brackets around the link - if data[link_b] == '<' { - link_b++ + if data[linkB] == '<' { + linkB++ } - if data[link_e-1] == '>' { - link_e-- + if data[linkE-1] == '>' { + linkE-- } // build escaped link and title - if link_e > link_b { - link = data[link_b:link_e] + if linkE > linkB { + link = data[linkB:linkE] } - if title_e > title_b { - title = data[title_b:title_e] + if titleE > titleB { + title = data[titleB:titleE] } i++

@@ -329,21 +329,21 @@ var id []byte

// look for the id i++ - link_b := i + linkB := i for i < len(data) && data[i] != ']' { i++ } if i >= len(data) { return 0 } - link_e := i + linkE := i // find the reference - if link_b == link_e { - if text_has_nl { + if linkB == linkE { + if textHasNl { var b bytes.Buffer - for j := 1; j < txt_e; j++ { + for j := 1; j < txtE; j++ { switch { case data[j] != '\n': b.WriteByte(data[j])

@@ -354,10 +354,10 @@ }

id = b.Bytes() } else { - id = data[1:txt_e] + id = data[1:txtE] } } else { - id = data[link_b:link_e] + id = data[linkB:linkE] } // find the reference with matching id (ids are case-insensitive)

@@ -377,10 +377,10 @@ default:

var id []byte // craft the id - if text_has_nl { + if textHasNl { var b bytes.Buffer - for j := 1; j < txt_e; j++ { + for j := 1; j < txtE; j++ { switch { case data[j] != '\n': b.WriteByte(data[j])

@@ -391,7 +391,7 @@ }

id = b.Bytes() } else { - id = data[1:txt_e] + id = data[1:txtE] } // find the reference with matching id

@@ -406,28 +406,28 @@ link = lr.link

title = lr.title // rewind the whitespace - i = txt_e + 1 + i = txtE + 1 } // build content: img alt is escaped, link content is parsed var content bytes.Buffer - if txt_e > 1 { + if txtE > 1 { if isImg { - content.Write(data[1:txt_e]) + content.Write(data[1:txtE]) } else { // links cannot contain other links, so turn off link parsing temporarily insideLink := rndr.insideLink rndr.insideLink = true - parseInline(&content, rndr, data[1:txt_e]) + parseInline(&content, rndr, data[1:txtE]) rndr.insideLink = insideLink } } - var u_link []byte + var uLink []byte if len(link) > 0 { - var u_link_buf bytes.Buffer - unescapeText(&u_link_buf, link) - u_link = u_link_buf.Bytes() + var uLinkBuf bytes.Buffer + unescapeText(&uLinkBuf, link) + uLink = uLinkBuf.Bytes() } // call the relevant rendering function

@@ -439,9 +439,9 @@ if outSize > 0 && outBytes[outSize-1] == '!' {

out.Truncate(outSize - 1) } - ret = rndr.mk.Image(out, u_link, title, content.Bytes(), rndr.mk.Opaque) + ret = rndr.mk.Image(out, uLink, title, content.Bytes(), rndr.mk.Opaque) } else { - ret = rndr.mk.Link(out, u_link, title, content.Bytes(), rndr.mk.Opaque) + ret = rndr.mk.Link(out, uLink, title, content.Bytes(), rndr.mk.Opaque) } if ret > 0 {

@@ -460,9 +460,9 @@

if end > 2 { switch { case rndr.mk.AutoLink != nil && altype != LINK_TYPE_NOT_AUTOLINK: - var u_link bytes.Buffer - unescapeText(&u_link, data[1:end+1-2]) - ret = rndr.mk.AutoLink(out, u_link.Bytes(), altype, rndr.mk.Opaque) + var uLink bytes.Buffer + unescapeText(&uLink, data[1:end+1-2]) + ret = rndr.mk.AutoLink(out, uLink.Bytes(), altype, rndr.mk.Opaque) case rndr.mk.RawHtmlTag != nil: ret = rndr.mk.RawHtmlTag(out, data[:end], rndr.mk.Opaque) }

@@ -561,26 +561,26 @@ if rewind > 6 { // longest supported protocol is "mailto" which has 6 letters

return 0 } - orig_data := data + origData := data data = data[offset-rewind:] if !isSafeLink(data) { return 0 } - link_end := 0 - for link_end < len(data) && !isspace(data[link_end]) { - link_end++ + linkEnd := 0 + for linkEnd < len(data) && !isspace(data[linkEnd]) { + linkEnd++ } // Skip punctuation at the end of the link - if (data[link_end-1] == '.' || data[link_end-1] == ',' || data[link_end-1] == ';') && data[link_end-2] != '\\' { - link_end-- + if (data[linkEnd-1] == '.' || data[linkEnd-1] == ',' || data[linkEnd-1] == ';') && data[linkEnd-2] != '\\' { + linkEnd-- } // See if the link finishes with a punctuation sign that can be closed. var copen byte - switch data[link_end-1] { + switch data[linkEnd-1] { case '"': copen = '"' case '\'':

@@ -596,9 +596,9 @@ copen = 0

} if copen != 0 { - buf_end := offset - rewind + link_end - 2 + bufEnd := offset - rewind + linkEnd - 2 - open_delim := 1 + openDelim := 1 /* Try to close the final punctuation sign in this same line; * if we managed to close it outside of the URL, that means that it's

@@ -620,20 +620,20 @@ * (foo http://www.pokemon.com/Pikachu_(Electric)) bar

* => foo http://www.pokemon.com/Pikachu_(Electric) */ - for buf_end >= 0 && orig_data[buf_end] != '\n' && open_delim != 0 { - if orig_data[buf_end] == data[link_end-1] { - open_delim++ + for bufEnd >= 0 && origData[bufEnd] != '\n' && openDelim != 0 { + if origData[bufEnd] == data[linkEnd-1] { + openDelim++ } - if orig_data[buf_end] == copen { - open_delim-- + if origData[bufEnd] == copen { + openDelim-- } - buf_end-- + bufEnd-- } - if open_delim == 0 { - link_end-- + if openDelim == 0 { + linkEnd-- } }

@@ -643,13 +643,13 @@ out.Truncate(len(out.Bytes()) - rewind)

} if rndr.mk.AutoLink != nil { - var u_link bytes.Buffer - unescapeText(&u_link, data[:link_end]) + var uLink bytes.Buffer + unescapeText(&uLink, data[:linkEnd]) - rndr.mk.AutoLink(out, u_link.Bytes(), LINK_TYPE_NORMAL, rndr.mk.Opaque) + rndr.mk.AutoLink(out, uLink.Bytes(), LINK_TYPE_NORMAL, rndr.mk.Opaque) } - return link_end - rewind + return linkEnd - rewind } var validUris = [][]byte{[]byte("http://"), []byte("https://"), []byte("ftp://"), []byte("mailto://")}

@@ -805,26 +805,26 @@ }

if data[i] == '`' { // skip a code span - tmp_i := 0 + tmpI := 0 i++ for i < len(data) && data[i] != '`' { - if tmp_i == 0 && data[i] == c { - tmp_i = i + if tmpI == 0 && data[i] == c { + tmpI = i } i++ } if i >= len(data) { - return tmp_i + return tmpI } i++ } else { if data[i] == '[' { // skip a link - tmp_i := 0 + tmpI := 0 i++ for i < len(data) && data[i] != ']' { - if tmp_i == 0 && data[i] == c { - tmp_i = i + if tmpI == 0 && data[i] == c { + tmpI = i } i++ }

@@ -833,11 +833,11 @@ for i < len(data) && (data[i] == ' ' || data[i] == '\t' || data[i] == '\n') {

i++ } if i >= len(data) { - return tmp_i + return tmpI } if data[i] != '[' && data[i] != '(' { // not a link - if tmp_i > 0 { - return tmp_i + if tmpI > 0 { + return tmpI } else { continue }

@@ -845,13 +845,13 @@ }

cc := data[i] i++ for i < len(data) && data[i] != cc { - if tmp_i == 0 && data[i] == c { - tmp_i = i + if tmpI == 0 && data[i] == c { + tmpI = i } i++ } if i >= len(data) { - return tmp_i + return tmpI } i++ }

@@ -910,12 +910,12 @@ return 0

} func inlineHelperEmph2(out *bytes.Buffer, rndr *render, data []byte, c byte) int { - render_method := rndr.mk.DoubleEmphasis + renderMethod := rndr.mk.DoubleEmphasis if c == '~' { - render_method = rndr.mk.StrikeThrough + renderMethod = rndr.mk.StrikeThrough } - if render_method == nil { + if renderMethod == nil { return 0 }

@@ -931,7 +931,7 @@

if i+1 < len(data) && data[i] == c && data[i+1] == c && i > 0 && !isspace(data[i-1]) { var work bytes.Buffer parseInline(&work, rndr, data[:i]) - r := render_method(out, work.Bytes(), rndr.mk.Opaque) + r := renderMethod(out, work.Bytes(), rndr.mk.Opaque) if r > 0 { return i + 2 } else {

@@ -945,7 +945,7 @@ }

func inlineHelperEmph3(out *bytes.Buffer, rndr *render, data []byte, offset int, c byte) int { i := 0 - orig_data := data + origData := data data = data[offset:] for i < len(data) {

@@ -974,7 +974,7 @@ return 0

} case (i+1 < len(data) && data[i+1] == c): // double symbol found, hand over to emph1 - length = inlineHelperEmph1(out, rndr, orig_data[offset-2:], c) + length = inlineHelperEmph1(out, rndr, origData[offset-2:], c) if length == 0 { return 0 } else {

@@ -982,7 +982,7 @@ return length - 2

} default: // single symbol found, hand over to emph2 - length = inlineHelperEmph2(out, rndr, orig_data[offset-1:], c) + length = inlineHelperEmph2(out, rndr, origData[offset-1:], c) if length == 0 { return 0 } else {
M markdown.gomarkdown.go

@@ -72,7 +72,7 @@ )

// These are the tags that are recognized as HTML block tags. // Any of these can be included in markdown text without special escaping. -var block_tags = map[string]bool{ +var blockTags = map[string]bool{ "p": true, "dl": true, "h1": true,

@@ -251,9 +251,9 @@ // - normalize newlines

// - copy everything else func firstPass(rndr *render, input []byte) []byte { var out bytes.Buffer - tab_size := TAB_SIZE_DEFAULT + tabSize := TAB_SIZE_DEFAULT if rndr.flags&EXTENSION_TAB_SIZE_EIGHT != 0 { - tab_size = TAB_SIZE_EIGHT + tabSize = TAB_SIZE_EIGHT } beg, end := 0, 0 for beg < len(input) { // iterate over lines

@@ -268,7 +268,7 @@

// add the line body if present if end > beg { if rndr.flags&EXTENSION_NO_EXPAND_TABS == 0 { - expandTabs(&out, input[beg:end], tab_size) + expandTabs(&out, input[beg:end], tabSize) } else { out.Write(input[beg:end]) }

@@ -350,14 +350,14 @@ if data[i] != '[' {

return 0 } i++ - id_offset := i + idOffset := i for i < len(data) && data[i] != '\n' && data[i] != '\r' && data[i] != ']' { i++ } if i >= len(data) || data[i] != ']' { return 0 } - id_end := i + idEnd := i // spacer: colon (space | tab)* newline? (space | tab)* i++

@@ -385,14 +385,14 @@ // link: whitespace-free sequence, optionally between angle brackets

if data[i] == '<' { i++ } - link_offset := i + linkOffset := i for i < len(data) && data[i] != ' ' && data[i] != '\t' && data[i] != '\n' && data[i] != '\r' { i++ } - link_end := i - if data[link_offset] == '<' && data[link_end-1] == '>' { - link_offset++ - link_end-- + linkEnd := i + if data[linkOffset] == '<' && data[linkEnd-1] == '>' { + linkOffset++ + linkEnd-- } // optional spacer: (space | tab)* (newline | '\'' | '"' | '(' )

@@ -404,65 +404,65 @@ return 0

} // compute end-of-line - line_end := 0 + lineEnd := 0 if i >= len(data) || data[i] == '\r' || data[i] == '\n' { - line_end = i + lineEnd = i } if i+1 < len(data) && data[i] == '\r' && data[i+1] == '\n' { - line_end++ + lineEnd++ } // optional (space|tab)* spacer after a newline - if line_end > 0 { - i = line_end + 1 + if lineEnd > 0 { + i = lineEnd + 1 for i < len(data) && (data[i] == ' ' || data[i] == '\t') { i++ } } // optional title: any non-newline sequence enclosed in '"() alone on its line - title_offset, title_end := 0, 0 + titleOffset, titleEnd := 0, 0 if i+1 < len(data) && (data[i] == '\'' || data[i] == '"' || data[i] == '(') { i++ - title_offset = i + titleOffset = i // look for EOL for i < len(data) && data[i] != '\n' && data[i] != '\r' { i++ } if i+1 < len(data) && data[i] == '\n' && data[i+1] == '\r' { - title_end = i + 1 + titleEnd = i + 1 } else { - title_end = i + titleEnd = i } // step back i-- - for i > title_offset && (data[i] == ' ' || data[i] == '\t') { + for i > titleOffset && (data[i] == ' ' || data[i] == '\t') { i-- } - if i > title_offset && (data[i] == '\'' || data[i] == '"' || data[i] == ')') { - line_end = title_end - title_end = i + if i > titleOffset && (data[i] == '\'' || data[i] == '"' || data[i] == ')') { + lineEnd = titleEnd + titleEnd = i } } - if line_end == 0 { // garbage after the link + if lineEnd == 0 { // garbage after the link return 0 } // a valid ref has been found if rndr == nil { - return line_end + return lineEnd } // id matches are case-insensitive - id := string(bytes.ToLower(data[id_offset:id_end])) + id := string(bytes.ToLower(data[idOffset:idEnd])) rndr.refs[id] = &reference{ - link: data[link_offset:link_end], - title: data[title_offset:title_end], + link: data[linkOffset:linkEnd], + title: data[titleOffset:titleEnd], } - return line_end + return lineEnd }

@@ -497,7 +497,7 @@ }

// Replace tab characters with spaces, aligning to the next TAB_SIZE column. // always ends output with a newline -func expandTabs(out *bytes.Buffer, line []byte, tab_size int) { +func expandTabs(out *bytes.Buffer, line []byte, tabSize int) { // first, check for common cases: no tabs, or only tabs at beginning of line i, prefix := 0, 0 slowcase := false

@@ -514,7 +514,7 @@ }

// no need to decode runes if all tabs are at the beginning of the line if !slowcase { - for i = 0; i < prefix*tab_size; i++ { + for i = 0; i < prefix*tabSize; i++ { out.WriteByte(' ') } out.Write(line[prefix:])

@@ -544,7 +544,7 @@

for { out.WriteByte(' ') column++ - if column%tab_size == 0 { + if column%tabSize == 0 { break } }
M smartypants.gosmartypants.go

@@ -255,33 +255,33 @@

func smartNumberGeneric(ob *bytes.Buffer, smrt *smartypantsData, previousChar byte, text []byte) int { if wordBoundary(previousChar) && len(text) >= 3 { // is it of the form digits/digits(word boundary)?, i.e., \d+/\d+\b - num_end := 0 - for len(text) > num_end && isdigit(text[num_end]) { - num_end++ + numEnd := 0 + for len(text) > numEnd && isdigit(text[numEnd]) { + numEnd++ } - if num_end == 0 { + if numEnd == 0 { ob.WriteByte(text[0]) return 0 } - if len(text) < num_end+2 || text[num_end] != '/' { + if len(text) < numEnd+2 || text[numEnd] != '/' { ob.WriteByte(text[0]) return 0 } - den_end := num_end + 1 - for len(text) > den_end && isdigit(text[den_end]) { - den_end++ + denEnd := numEnd + 1 + for len(text) > denEnd && isdigit(text[denEnd]) { + denEnd++ } - if den_end == num_end+1 { + if denEnd == numEnd+1 { ob.WriteByte(text[0]) return 0 } - if len(text) == den_end || wordBoundary(text[den_end]) { + if len(text) == denEnd || wordBoundary(text[denEnd]) { ob.WriteString("<sup>") - ob.Write(text[:num_end]) + ob.Write(text[:numEnd]) ob.WriteString("</sup>&frasl;<sub>") - ob.Write(text[num_end+1 : den_end]) + ob.Write(text[numEnd+1 : denEnd]) ob.WriteString("</sub>") - return den_end - 1 + return denEnd - 1 } }