mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Fixes #31
This commit is contained in:
parent
c8c3b41fe0
commit
9dec7e9e8b
2 changed files with 17 additions and 2 deletions
|
|
@ -28,3 +28,12 @@
|
|||
<h2 id="id_7" attr7="value "7">Title7</h2>
|
||||
<h2 id="id" class="className class1 class2" attrName="attrValue">Title8</h2>
|
||||
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||
|
||||
2
|
||||
//- - - - - - - - -//
|
||||
#
|
||||
# FOO
|
||||
//- - - - - - - - -//
|
||||
<h1 id="heading"></h1>
|
||||
<h1 id="foo">FOO</h1>
|
||||
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||
|
|
|
|||
|
|
@ -186,15 +186,21 @@ func (b *atxHeadingParser) CanAcceptIndentedLine() bool {
|
|||
var attrAutoHeadingIDPrefix = []byte("heading")
|
||||
|
||||
func generateAutoHeadingID(node *ast.Heading, reader text.Reader, pc Context) {
|
||||
var line []byte
|
||||
lastIndex := node.Lines().Len() - 1
|
||||
lastLine := node.Lines().At(lastIndex)
|
||||
line := lastLine.Value(reader.Source())
|
||||
if lastIndex > -1 {
|
||||
lastLine := node.Lines().At(lastIndex)
|
||||
line = lastLine.Value(reader.Source())
|
||||
}
|
||||
headingID := pc.IDs().Generate(line, attrAutoHeadingIDPrefix)
|
||||
node.SetAttribute(attrNameID, headingID)
|
||||
}
|
||||
|
||||
func parseLastLineAttributes(node ast.Node, reader text.Reader, pc Context) {
|
||||
lastIndex := node.Lines().Len() - 1
|
||||
if lastIndex < 0 { // empty headings
|
||||
return
|
||||
}
|
||||
lastLine := node.Lines().At(lastIndex)
|
||||
line := lastLine.Value(reader.Source())
|
||||
lr := text.NewReader(line)
|
||||
|
|
|
|||
Loading…
Reference in a new issue