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
|
||||
format: html
|
||||
relative_urls: true
|
||||
chapter_anchor_prefix: 'chapter-'
|
||||
|
||||
rss:
|
||||
<<: *paths
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
[
|
||||
{
|
||||
"slug": "chapter-1",
|
||||
"slug": "1",
|
||||
"title": "Chapter 1",
|
||||
"chapters": [
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"slug": "chapter-2",
|
||||
"slug": "2",
|
||||
"title": "Chapter 2",
|
||||
"chapters": [
|
||||
|
||||
|
|
|
@ -63,13 +63,13 @@ The Rty
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h2>Chapter 1</h2>
|
||||
<h2 id="chapter-1">Chapter 1</h2>
|
||||
<p>
|
||||
<span>
|
||||
Chapter 1 paragraph text
|
||||
</span>
|
||||
</p>
|
||||
<h2>Chapter 2</h2>
|
||||
<h2 id="chapter-2">Chapter 2</h2>
|
||||
<p>
|
||||
<span>
|
||||
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|
|
||||
paragraph.text 'Chapter 1 paragraph text'
|
||||
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|
|
||||
paragraph.text 'Chapter 2 paragraph text'
|
||||
end
|
||||
|
|
|
@ -4,6 +4,7 @@ module Repubmark
|
|||
class Config
|
||||
OPTIONAL_KEYS = %i[
|
||||
base_url
|
||||
chapter_anchor_prefix
|
||||
css_class_annotation
|
||||
css_class_blockquote_figure
|
||||
css_class_blockquote_blockquote
|
||||
|
|
|
@ -118,7 +118,9 @@ module Repubmark
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
def build_title_gemtext
|
||||
|
|
Loading…
Reference in a new issue