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
|
def anchor
|
||||||
if parent.instance_of?(self.class) && @level > 2
|
if parent.instance_of?(self.class) && @level > 2
|
||||||
"#{parent.anchor}-#@slug"
|
"#{parent.anchor}-#@slug"
|
||||||
elsif (anchor_prefix =
|
elsif anchor_prefix.empty?
|
||||||
String(config[:chapter_anchor_prefix]).strip).empty?
|
|
||||||
@slug
|
@slug
|
||||||
else
|
else
|
||||||
"#{anchor_prefix}-#@slug"
|
"#{anchor_prefix}-#@slug"
|
||||||
|
@ -133,12 +132,17 @@ module Repubmark
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_title_html
|
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
|
end
|
||||||
|
|
||||||
def build_title_gemtext
|
def build_title_gemtext
|
||||||
"\n#{'#' * @level} #@title\n\n" if @level != 1
|
"\n#{'#' * @level} #@title\n\n" if @level != 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def anchor_prefix
|
||||||
|
@anchor_prefix ||= String(config[:chapter_anchor_prefix]).strip.freeze
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue