Add chapter title anchors
This commit is contained in:
parent
2e2dfe5fc0
commit
51f6355986
6 changed files with 11 additions and 7 deletions
|
@ -61,6 +61,7 @@ http:
|
||||||
<<: *css_classes
|
<<: *css_classes
|
||||||
format: html
|
format: html
|
||||||
relative_urls: true
|
relative_urls: true
|
||||||
|
chapter_anchor_prefix: 'chapter-'
|
||||||
|
|
||||||
rss:
|
rss:
|
||||||
<<: *paths
|
<<: *paths
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"slug": "chapter-1",
|
"slug": "1",
|
||||||
"title": "Chapter 1",
|
"title": "Chapter 1",
|
||||||
"chapters": [
|
"chapters": [
|
||||||
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"slug": "chapter-2",
|
"slug": "2",
|
||||||
"title": "Chapter 2",
|
"title": "Chapter 2",
|
||||||
"chapters": [
|
"chapters": [
|
||||||
|
|
||||||
|
|
|
@ -63,13 +63,13 @@ The Rty
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h2>Chapter 1</h2>
|
<h2 id="chapter-1">Chapter 1</h2>
|
||||||
<p>
|
<p>
|
||||||
<span>
|
<span>
|
||||||
Chapter 1 paragraph text
|
Chapter 1 paragraph text
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<h2>Chapter 2</h2>
|
<h2 id="chapter-2">Chapter 2</h2>
|
||||||
<p>
|
<p>
|
||||||
<span>
|
<span>
|
||||||
Chapter 2 paragraph text
|
Chapter 2 paragraph text
|
||||||
|
|
|
@ -33,7 +33,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
article.chapter 'chapter-1', 'Chapter 1' do |chapter|
|
article.chapter '1', 'Chapter 1' do |chapter|
|
||||||
chapter.paragraph do |paragraph|
|
chapter.paragraph do |paragraph|
|
||||||
paragraph.text 'Chapter 1 paragraph text'
|
paragraph.text 'Chapter 1 paragraph text'
|
||||||
end
|
end
|
||||||
|
@ -41,7 +41,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
article.chapter 'chapter-2', 'Chapter 2' do |chapter|
|
article.chapter '2', 'Chapter 2' do |chapter|
|
||||||
chapter.paragraph do |paragraph|
|
chapter.paragraph do |paragraph|
|
||||||
paragraph.text 'Chapter 2 paragraph text'
|
paragraph.text 'Chapter 2 paragraph text'
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,7 @@ module Repubmark
|
||||||
class Config
|
class Config
|
||||||
OPTIONAL_KEYS = %i[
|
OPTIONAL_KEYS = %i[
|
||||||
base_url
|
base_url
|
||||||
|
chapter_anchor_prefix
|
||||||
css_class_annotation
|
css_class_annotation
|
||||||
css_class_blockquote_figure
|
css_class_blockquote_figure
|
||||||
css_class_blockquote_blockquote
|
css_class_blockquote_blockquote
|
||||||
|
|
|
@ -118,7 +118,9 @@ module Repubmark
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_title_html
|
def build_title_html
|
||||||
"<h#@level>#@title</h#@level>\n" if @level != 1
|
anchor_prefix = String(config[:chapter_anchor_prefix]).strip
|
||||||
|
anchor = %( id="#{anchor_prefix}#@slug") unless anchor_prefix.empty?
|
||||||
|
"<h#@level#{anchor}>#@title</h#@level>\n" if @level != 1
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_title_gemtext
|
def build_title_gemtext
|
||||||
|
|
Loading…
Reference in a new issue