Allow to disable chapter anchors
This commit is contained in:
parent
71ec8dc7f6
commit
0f83fbc6de
1 changed files with 7 additions and 3 deletions
|
@ -67,8 +67,7 @@ module Repubmark
|
|||
def anchor
|
||||
if parent.instance_of?(self.class) && @level > 2
|
||||
"#{parent.anchor}-#@slug"
|
||||
elsif (anchor_prefix =
|
||||
String(config[:chapter_anchor_prefix]).strip).empty?
|
||||
elsif anchor_prefix.empty?
|
||||
@slug
|
||||
else
|
||||
"#{anchor_prefix}-#@slug"
|
||||
|
@ -133,12 +132,17 @@ module Repubmark
|
|||
end
|
||||
|
||||
def build_title_html
|
||||
%(<h#@level id="#{anchor}">#@title</h#@level>\n) if @level != 1
|
||||
id_attr = %( id="#{anchor}") unless anchor_prefix.empty?
|
||||
%(<h#@level#{id_attr}>#@title</h#@level>\n) if @level != 1
|
||||
end
|
||||
|
||||
def build_title_gemtext
|
||||
"\n#{'#' * @level} #@title\n\n" if @level != 1
|
||||
end
|
||||
|
||||
def anchor_prefix
|
||||
@anchor_prefix ||= String(config[:chapter_anchor_prefix]).strip.freeze
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue