Skip to content

Commit

Permalink
simplify markdown by defining IOBuffer for SubString
Browse files Browse the repository at this point in the history
  • Loading branch information
hayd committed Jan 22, 2015
1 parent f70f685 commit 8cd5310
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 1 addition & 4 deletions base/markdown/GitHub/GitHub.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function github_table(stream::IO, md::MD, config::Config)
end

elseif n == 1 || length(rows[1]) == length(row)
push!(rows, Row(map(x -> parseinline(IOBuffer(_full(x)), config), row)))
push!(rows, Row(map(x -> parseinline(IOBuffer(x), config), row)))
elseif length(row) > 1
seek(stream, pos)
break
Expand All @@ -107,9 +107,6 @@ function github_table(stream::IO, md::MD, config::Config)
end
end

_full{T}(s::SubString{T}) = convert(T, s)
_full(s::AbstractString) = s

@flavor github [list, indentcode, blockquote, fencedcode, hashheader,
github_paragraph, github_table,
en_dash, inline_code, asterisk_bold, asterisk_italic, image, link]
2 changes: 2 additions & 0 deletions base/string.jl
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ write{T<:ByteString}(to::IOBuffer, s::SubString{T}) =
s.endof==0 ? 0 : write_sub(to, s.string.data, s.offset+1, next(s,s.endof)[2]-1)
print(io::IOBuffer, s::SubString) = write(io, s)

IOBuffer(s::SubString) = IOBuffer(s.string.data[s.offset:s.endof], true, false)

sizeof(s::SubString{ASCIIString}) = s.endof
sizeof(s::SubString{UTF8String}) = s.endof == 0 ? 0 : next(s,s.endof)[2]-1

Expand Down

0 comments on commit 8cd5310

Please sign in to comment.