<% @chapter = chapter if defined?(chapter) %>

<%= @chapter.chapter_title.html_safe %>

<% if (!@chapter.pseuds.blank? && (@chapter.pseuds != @work.pseuds) && (!@work.anonymous?)) %> <%# only display byline if different from the main byline %>

<%= t(".chapter_byline_html", byline_names_link: byline(@chapter, only_path: false)) %>

<% end %> <% unless @chapter.summary.blank? %>

<%= t(".chapter_summary") %>

<%= raw sanitize_field(@chapter, :summary) %>
<% end %> <% unless @chapter.notes.blank? && @chapter.endnotes.blank? %>

<%= t(".chapter_notes") %>

<% unless @chapter.notes.blank? %>
<%= raw sanitize_field(@chapter, :notes) %>
<% end %> <% unless @chapter.endnotes.blank? %> <% end %> <% end %>
<%= raw defined?(@content) ? @content : sanitize_field(@chapter, :content) %>
<% unless @chapter.endnotes.blank? %>

<%= t(".section_chapter_end_notes") %>

<%= raw sanitize_field(@chapter, :endnotes) %>
<% end %>