Fixes #44, Fixes #45

This commit is contained in:
yuin 2019-12-02 03:10:06 +09:00
parent 9f9f8f0e5e
commit 2f292e5b74
9 changed files with 55 additions and 16 deletions

View file

@ -20,3 +20,22 @@ test<strong>test</strong><br />
<strong>test</strong>test<br /> <strong>test</strong>test<br />
test<strong>test</strong></p> test<strong>test</strong></p>
//= = = = = = = = = = = = = = = = = = = = = = = =// //= = = = = = = = = = = = = = = = = = = = = = = =//
3
//- - - - - - - - -//
>* >
> 1
> 2
>3
//- - - - - - - - -//
<blockquote>
<ul>
<li>
<blockquote>
</blockquote>
</li>
</ul>
<p>1
2
3</p>
</blockquote>
//= = = = = = = = = = = = = = = = = = = = = = = =//

View file

@ -18,5 +18,16 @@ That's some text with a footnote.[^1]
</section> </section>
//= = = = = = = = = = = = = = = = = = = = = = = =// //= = = = = = = = = = = = = = = = = = = = = = = =//
3
//- - - - - - - - -//
[^000]:0 [^]:
//- - - - - - - - -//
<section class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1" role="doc-endnote">
<p>0 [^]:<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#8617;</a></p>
</li>
</ol>
</section>
//= = = = = = = = = = = = = = = = = = = = = = = =//

View file

@ -112,3 +112,12 @@ a.b-c_d@a.b_
<p>a.b-c_d@a.b-</p> <p>a.b-c_d@a.b-</p>
<p>a.b-c_d@a.b_</p> <p>a.b-c_d@a.b_</p>
//= = = = = = = = = = = = = = = = = = = = = = = =// //= = = = = = = = = = = = = = = = = = = = = = = =//
11
//- - - - - - - - -//
Go to [http://www.example.com](www.example.com)
//- - - - - - - - -//
<p>Go to <a href="www.example.com">http://www.example.com</a></p>
//= = = = = = = = = = = = = = = = = = = = = = = =//

View file

@ -43,28 +43,28 @@ func (b *footnoteBlockParser) Open(parent gast.Node, reader text.Reader, pc pars
open := pos + 1 open := pos + 1
closes := 0 closes := 0
closure := util.FindClosure(line[pos+1:], '[', ']', false, false) closure := util.FindClosure(line[pos+1:], '[', ']', false, false)
closes = pos + 1 + closure
next := closes + 1
if closure > -1 { if closure > -1 {
closes = pos + 1 + closure
next := closes + 1
if next >= len(line) || line[next] != ':' { if next >= len(line) || line[next] != ':' {
return nil, parser.NoChildren return nil, parser.NoChildren
} }
} else { } else {
return nil, parser.NoChildren return nil, parser.NoChildren
} }
label := reader.Value(text.NewSegment(segment.Start+open, segment.Start+closes)) padding := segment.Padding
label := reader.Value(text.NewSegment(segment.Start+open-padding, segment.Start+closes-padding))
if util.IsBlank(label) { if util.IsBlank(label) {
return nil, parser.NoChildren return nil, parser.NoChildren
} }
item := ast.NewFootnote(label) item := ast.NewFootnote(label)
pos = pos + 2 + closes - open + 2 pos = next + 1 - padding
if pos >= len(line) { if pos >= len(line) {
reader.Advance(pos) reader.Advance(pos)
return item, parser.NoChildren return item, parser.NoChildren
} }
childpos, padding := util.IndentPosition(line[pos:], pos, 1) reader.AdvanceAndSetPadding(pos, padding)
reader.AdvanceAndSetPadding(pos+childpos, padding)
return item, parser.HasChildren return item, parser.HasChildren
} }

View file

@ -19,7 +19,7 @@ func NewBlockquoteParser() BlockParser {
func (b *blockquoteParser) process(reader text.Reader) bool { func (b *blockquoteParser) process(reader text.Reader) bool {
line, _ := reader.PeekLine() line, _ := reader.PeekLine()
w, pos := util.IndentWidth(line, 0) w, pos := util.IndentWidth(line, reader.LineOffset())
if w > 3 || pos >= len(line) || line[pos] != '>' { if w > 3 || pos >= len(line) || line[pos] != '>' {
return false return false
} }

View file

@ -71,7 +71,7 @@ func (b *fencedCodeBlockParser) Open(parent ast.Node, reader text.Reader, pc Con
func (b *fencedCodeBlockParser) Continue(node ast.Node, reader text.Reader, pc Context) State { func (b *fencedCodeBlockParser) Continue(node ast.Node, reader text.Reader, pc Context) State {
line, segment := reader.PeekLine() line, segment := reader.PeekLine()
fdata := pc.Get(fencedCodeBlockInfoKey).(*fenceData) fdata := pc.Get(fencedCodeBlockInfoKey).(*fenceData)
w, pos := util.IndentWidth(line, 0) w, pos := util.IndentWidth(line, reader.LineOffset())
if w < 4 { if w < 4 {
i := pos i := pos
for ; i < len(line) && line[i] == fdata.char; i++ { for ; i < len(line) && line[i] == fdata.char; i++ {

View file

@ -167,7 +167,7 @@ func (b *listParser) Continue(node ast.Node, reader text.Reader, pc Context) Sta
return Continue | HasChildren return Continue | HasChildren
} }
// Thematic Breaks take precedence over lists // Thematic Breaks take precedence over lists
if isThematicBreak(line) { if isThematicBreak(line, reader.LineOffset()) {
isHeading := false isHeading := false
last := pc.LastOpenedBlock().Node last := pc.LastOpenedBlock().Node
if ast.IsParagraph(last) { if ast.IsParagraph(last) {
@ -190,7 +190,7 @@ func (b *listParser) Continue(node ast.Node, reader text.Reader, pc Context) Sta
// - b <--- current line // - b <--- current line
// it maybe a new child of the list. // it maybe a new child of the list.
offset := lastOffset(node) offset := lastOffset(node)
indent, _ := util.IndentWidth(line, 0) indent, _ := util.IndentWidth(line, reader.LineOffset())
if indent < offset { if indent < offset {
if indent < 4 { if indent < 4 {

View file

@ -874,7 +874,7 @@ func (p *parser) openBlocks(parent ast.Node, blankLine bool, reader text.Reader,
retry: retry:
var bps []BlockParser var bps []BlockParser
line, _ := reader.PeekLine() line, _ := reader.PeekLine()
w, pos := util.IndentWidth(line, 0) w, pos := util.IndentWidth(line, reader.LineOffset())
if w >= len(line) { if w >= len(line) {
pc.SetBlockOffset(-1) pc.SetBlockOffset(-1)
pc.SetBlockIndent(-1) pc.SetBlockIndent(-1)

View file

@ -17,8 +17,8 @@ func NewThematicBreakParser() BlockParser {
return defaultThematicBreakPraser return defaultThematicBreakPraser
} }
func isThematicBreak(line []byte) bool { func isThematicBreak(line []byte, offset int) bool {
w, pos := util.IndentWidth(line, 0) w, pos := util.IndentWidth(line, offset)
if w > 3 { if w > 3 {
return false return false
} }
@ -51,7 +51,7 @@ func (b *thematicBreakPraser) Trigger() []byte {
func (b *thematicBreakPraser) Open(parent ast.Node, reader text.Reader, pc Context) (ast.Node, State) { func (b *thematicBreakPraser) Open(parent ast.Node, reader text.Reader, pc Context) (ast.Node, State) {
line, segment := reader.PeekLine() line, segment := reader.PeekLine()
if isThematicBreak(line) { if isThematicBreak(line, reader.LineOffset()) {
reader.Advance(segment.Len() - 1) reader.Advance(segment.Len() - 1)
return ast.NewThematicBreak(), NoChildren return ast.NewThematicBreak(), NoChildren
} }