Do not include excluded headlines when calculating headline index
This commit is contained in:
parent
d4f684b248
commit
7bc6100fc7
3 changed files with 20 additions and 21 deletions
|
@ -260,7 +260,9 @@ func (d *Document) parseMany(i int, stop stopFn) (int, []Node) {
|
||||||
func (d *Document) addHeadline(headline *Headline) int {
|
func (d *Document) addHeadline(headline *Headline) int {
|
||||||
current := &Section{Headline: headline}
|
current := &Section{Headline: headline}
|
||||||
d.Outline.last.add(current)
|
d.Outline.last.add(current)
|
||||||
|
if !headline.IsExcluded(d) {
|
||||||
d.Outline.count++
|
d.Outline.count++
|
||||||
|
}
|
||||||
d.Outline.last = current
|
d.Outline.last = current
|
||||||
return d.Outline.count
|
return d.Outline.count
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,9 +43,6 @@ func lexHeadline(line string) (token, bool) {
|
||||||
func (d *Document) parseHeadline(i int, parentStop stopFn) (int, Node) {
|
func (d *Document) parseHeadline(i int, parentStop stopFn) (int, Node) {
|
||||||
t, headline := d.tokens[i], Headline{}
|
t, headline := d.tokens[i], Headline{}
|
||||||
headline.Lvl = len(t.matches[1])
|
headline.Lvl = len(t.matches[1])
|
||||||
|
|
||||||
headline.Index = d.addHeadline(&headline)
|
|
||||||
|
|
||||||
text := t.content
|
text := t.content
|
||||||
todoKeywords := trimFastTags(
|
todoKeywords := trimFastTags(
|
||||||
strings.FieldsFunc(d.Get("TODO"), func(r rune) bool { return unicode.IsSpace(r) || r == '|' }),
|
strings.FieldsFunc(d.Get("TODO"), func(r rune) bool { return unicode.IsSpace(r) || r == '|' }),
|
||||||
|
@ -67,7 +64,7 @@ func (d *Document) parseHeadline(i int, parentStop stopFn) (int, Node) {
|
||||||
text = m[1]
|
text = m[1]
|
||||||
headline.Tags = strings.FieldsFunc(m[2], func(r rune) bool { return r == ':' })
|
headline.Tags = strings.FieldsFunc(m[2], func(r rune) bool { return r == ':' })
|
||||||
}
|
}
|
||||||
|
headline.Index = d.addHeadline(&headline)
|
||||||
headline.Title = d.parseInline(text)
|
headline.Title = d.parseInline(text)
|
||||||
|
|
||||||
stop := func(d *Document, i int) bool {
|
stop := func(d *Document, i int) bool {
|
||||||
|
|
32
org/testdata/headlines.html
vendored
32
org/testdata/headlines.html
vendored
|
@ -10,9 +10,9 @@
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#headline-5">headline with custom status</a>
|
<li><a href="#headline-5">headline with custom status</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#headline-7">malformed property drawer</a>
|
<li><a href="#headline-6">malformed property drawer</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#headline-8">level limit for headlines to be included in the table of contents</a>
|
<li><a href="#headline-7">level limit for headlines to be included in the table of contents</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -75,40 +75,40 @@ headline with custom status
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="outline-container-headline-7" class="outline-2">
|
<div id="outline-container-headline-6" class="outline-2">
|
||||||
<h2 id="headline-7">
|
<h2 id="headline-6">
|
||||||
malformed property drawer
|
malformed property drawer
|
||||||
</h2>
|
</h2>
|
||||||
<div id="outline-text-headline-7" class="outline-text-2">
|
<div id="outline-text-headline-6" class="outline-text-2">
|
||||||
<p>:PROPERTIES:
|
<p>:PROPERTIES:
|
||||||
not a property</p>
|
not a property</p>
|
||||||
<p>:END:</p>
|
<p>:END:</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="outline-container-headline-8" class="outline-2">
|
<div id="outline-container-headline-7" class="outline-2">
|
||||||
<h2 id="headline-8">
|
<h2 id="headline-7">
|
||||||
level limit for headlines to be included in the table of contents
|
level limit for headlines to be included in the table of contents
|
||||||
</h2>
|
</h2>
|
||||||
<div id="outline-text-headline-8" class="outline-text-2">
|
<div id="outline-text-headline-7" class="outline-text-2">
|
||||||
<p>The toc option allows setting a <a href="https://orgmode.org/manual/Export-settings.html">level limit</a>. For this file we set it to 1 - which means that the following headlines
|
<p>The toc option allows setting a <a href="https://orgmode.org/manual/Export-settings.html">level limit</a>. For this file we set it to 1 - which means that the following headlines
|
||||||
won't be included in the table of contents.</p>
|
won't be included in the table of contents.</p>
|
||||||
<div id="outline-container-headline-9" class="outline-3">
|
<div id="outline-container-headline-8" class="outline-3">
|
||||||
<h3 id="headline-9">
|
<h3 id="headline-8">
|
||||||
headline 2 not in toc
|
headline 2 not in toc
|
||||||
</h3>
|
</h3>
|
||||||
<div id="outline-text-headline-9" class="outline-text-3">
|
<div id="outline-text-headline-8" class="outline-text-3">
|
||||||
<div id="outline-container-headline-10" class="outline-4">
|
<div id="outline-container-headline-9" class="outline-4">
|
||||||
<h4 id="headline-10">
|
<h4 id="headline-9">
|
||||||
headline 3 not in toc
|
headline 3 not in toc
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="outline-container-headline-11" class="outline-3">
|
<div id="outline-container-headline-10" class="outline-3">
|
||||||
<h3 id="headline-11">
|
<h3 id="headline-10">
|
||||||
anoter headline 2 not in toc
|
anoter headline 2 not in toc
|
||||||
</h3>
|
</h3>
|
||||||
<div id="outline-text-headline-11" class="outline-text-3">
|
<div id="outline-text-headline-10" class="outline-text-3">
|
||||||
<p>you get the gist…</p>
|
<p>you get the gist…</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue