<commit_before><% increment_tab_index %>

<%= @reference.ref_type.name %> by 
<%= link_to("#{@reference.author.name} (#{@reference.ref_author_role.name}) #{search_icon_on_tab}".html_safe, search_path(query_string: "id:#{@reference.author_id}",query_target: 'author'),title: 'Search for the author(s)/editor(s)...',class: 'author') %> 
<br>
<span title="Title"><%= @reference.title %></span>
<br>
<% if @reference.parent %>
  <%= render partial: "references/tabs/details/parent" %>
<% end %>
<br>
<% if @reference.published? %>
  <%= @reference.volume %>
  <%= ": #{@reference.pages}" if @reference.pages.present? %>
  <%  if @reference.publication_date.present? %>
    (<%= @reference.publication_date %>)
  <% else %>
    <% if @reference.parent && @reference.parent.year %>
      (<%= @reference.parent.year %>)   
    <% end %>
  <% end %>
	<%= "(#{@reference.language.name})" if @reference.language && @reference.language.determined? %>
	<%= " in #{@reference.published_location}" if @reference.published_location.present? %>
	<%= " published by #{@reference.publisher}" if @reference.publisher.present? %>
	<%= " Edn. #{@reference.edition}" if @reference.edition.present? %>
	<%= "<em>abbreviated to</em> #{@reference.abbrev_title}".html_safe if @reference.abbrev_title %>
	<%= "verbatim reference is #{@reference.verbatim_reference}" if @reference.verbatim_reference %>
	
<% else %>
  Unpublished.
<% end %>
<%= '<br>'.html_safe unless @reference.notes.blank? %>
<%= @reference.notes %>
<% if @reference.children && @reference.children.size != 0 %>
  <br>
  <% label_string = pluralize(@reference.children.size,'child') %>
  <%= link_to("#{label_string} #{search_icon_on_tab}".html_safe, 
              search_path(query_target: "reference", query_string: "parent-id:#{@reference.id}"),
              title: "Search for the #{label_string}", 
              tabindex: increment_tab_index) %>
<% end %>

<% if @reference.duplicate_of.present? %>
  <br>
  Duplicate of 
  <%= link_to("#{@reference.duplicate_of.citation} #{search_icon_on_tab}".html_safe,
              search_path(query_target: "reference", query_string: "id:#{@reference.duplicate_of_id}"),
              title: 'Search for the duplicate reference.') %>
<% end %>

<% duplicates = @reference.duplicates %>
<% if duplicates.size > 0 %>
  <br>
  <%= link_to(pluralize(duplicates.size,"Duplicate"),
                          search_path(query_target: "reference", 
                                      query_string: "master-id:#{@reference.id}"),
                          title: "Retrieve this reference with its #{pluralize(duplicates.size,'duplicate')}") %>
<% end %>

<% instances_size = @reference.instances.count %>
<% if instances_size > 0 %>
  <br>
  <% if instances_size == 1 %>
    <%= link_to("1 Instance #{search_icon_on_tab}".html_safe,
                          search_path(query_target: "references", query_string: "id: #{@reference.id} show-instances:"), 
                          tabindex: increment_tab_index, 
                          title: 'Search for the instance.') %>
  <% else %>
    <%= "#{instances_size} Instances" %>
    <br>
    <%= link_to("&mdash; sorted by name #{search_icon_on_tab}".html_safe,
                search_path(query_string:
                            "id: #{@reference.id} show-instances:",
                            query_target: 'references'),
                tabindex: increment_tab_index, 
                title: 'Search for the instances, sorted by name.',
                class: 'instance')
    %>
    <br>
    <%= link_to("&mdash; sorted by page #{search_icon_on_tab}".html_safe,
                search_path(query_string: "id:#{@reference.id.to_s} show-instances-by-page:",
                            query_target: "references"),
                tabindex: increment_tab_index, 
                title: 'Search for the instances, sorted by page.',
                class: 'instance')
    %>
   <% end %>
<% end %>
  <br>
<% novelties = @reference.novelties %>
<% if novelties.size > 0 %>
  <%= link_to("#{pluralize(novelties.size,"Novelty")} #{search_icon_on_tab}".html_safe,
                        search_path(query_target: "References with novelties", query_string: "id:#{@reference.id}"), 
                        tabindex: increment_tab_index, 
                        title: 'Taxon novelties in this reference.',
                        class: 'instance') %>
<% end %>


<% unless @reference.doi.blank? %>
  <%= link_to('DOI',@reference.doi) %>
<% end %>

<% unless @reference.isbn.blank? %>
  <br>
  <%= link_to('ISBN',@reference.isbn) %>
<% end %>

<% unless @reference.issn.blank? %>
  <br>
  <%= link_to('ISSN',@reference.issn) %>
<% end %>

<% unless @reference.bhl_url.blank? %>
  <br>
  <%= link_to('BHL',@reference.bhl_url) %>
<% end %>

<% unless @reference.tl2.blank? %>
  <br>
  <%= link_to('TL2',@reference.tl2) %>
<% end %>

<% if @reference.comments.size > 0  %>
  <%= divider %>
  <h5><%= pluralize(@reference.comments.size,'Comment') %></h5>
  <% @reference.comments.sort{|x,y| x.created_at <=> y.created_at}.each do |comment|  %>
    <%= render partial: 'comments/show', locals: {comment: comment} %>
    <%= divider %>
  <% end %>
<% else %>
  <%= divider %>
<% end %>



<h5>Reference #<%= @reference.id %></h5>
<br>
<br>
<%= created_by_whom_and_when(@reference).html_safe %>
<br>
<%= updated_by_whom_and_when(@reference).html_safe %>
<%= render partial: 'detail_line', locals: {label: 'System', info: "#{@reference.namespace.name}#{%Q(.#{@reference.source_system.downcase}.#{@reference.source_id}) if @reference.source_system}"} %><commit_msg>Add title and icon to BHL link; other trivial tidy ups.<commit_after><% increment_tab_index %>

<%= @reference.ref_type.name %> by 
<%= link_to("#{@reference.author.name} (#{@reference.ref_author_role.name}) #{search_icon_on_tab}".html_safe, search_path(query_string: "id:#{@reference.author_id}",query_target: 'author'),title: 'Search for the author(s)/editor(s)...',class: 'author') %> 
<br>
<span title="Title"><%= @reference.title %></span>
<br>
<% if @reference.parent %>
  <%= render partial: "references/tabs/details/parent" %>
<% end %>
<br>
<% if @reference.published? %>
  <%= @reference.volume %>
  <%= ": #{@reference.pages}" if @reference.pages.present? %>
  <%  if @reference.publication_date.present? %>
    (<%= @reference.publication_date %>)
  <% else %>
    <% if @reference.parent && @reference.parent.year %>
      (<%= @reference.parent.year %>)   
    <% end %>
  <% end %>
	<%= "(#{@reference.language.name})" if @reference.language && @reference.language.determined? %>
	<%= " in #{@reference.published_location}" if @reference.published_location.present? %>
	<%= " published by #{@reference.publisher}" if @reference.publisher.present? %>
	<%= " Edn. #{@reference.edition}" if @reference.edition.present? %>
	<%= "<em>abbreviated to</em> #{@reference.abbrev_title}".html_safe if @reference.abbrev_title %>
	<%= "verbatim reference is #{@reference.verbatim_reference}" if @reference.verbatim_reference %>
	
<% else %>
  Unpublished.
<% end %>
<%= '<br>'.html_safe unless @reference.notes.blank? %>
<%= @reference.notes %>
<% if @reference.children && @reference.children.size != 0 %>
  <br>
  <% label_string = pluralize(@reference.children.size,'child') %>
  <%= link_to("#{label_string} #{search_icon_on_tab}".html_safe, 
              search_path(query_target: "reference", query_string: "parent-id:#{@reference.id}"),
              title: "Search for the #{label_string}", 
              tabindex: increment_tab_index) %>
<% end %>

<% if @reference.duplicate_of.present? %>
  <br>
  Duplicate of 
  <%= link_to("#{@reference.duplicate_of.citation} #{search_icon_on_tab}".html_safe,
              search_path(query_target: "reference", query_string: "id:#{@reference.duplicate_of_id}"),
              title: 'Search for the duplicate reference.') %>
<% end %>

<% duplicates = @reference.duplicates %>
<% if duplicates.size > 0 %>
  <br>
  <%= link_to(pluralize(duplicates.size,"Duplicate"),
                          search_path(query_target: "reference", 
                                      query_string: "master-id:#{@reference.id}"),
                          title: "Retrieve this reference with its #{pluralize(duplicates.size,'duplicate')}") %>
<% end %>

<% instances_size = @reference.instances.count %>
<% if instances_size > 0 %>
  <br>
  <% if instances_size == 1 %>
    <%= link_to("1 Instance #{search_icon_on_tab}".html_safe,
                          search_path(query_target: "references", query_string: "id: #{@reference.id} show-instances:"), 
                          tabindex: increment_tab_index, 
                          title: 'Search for the instance.') %>
  <% else %>
    <%= "#{instances_size} Instances" %>
    <br>
    <%= link_to("&mdash; sorted by name #{search_icon_on_tab}".html_safe,
                search_path(query_string:
                            "id: #{@reference.id} show-instances:",
                            query_target: 'references'),
                tabindex: increment_tab_index, 
                title: 'Search for the instances, sorted by name.',
                class: 'instance')
    %>
    <br>
    <%= link_to("&mdash; sorted by page #{search_icon_on_tab}".html_safe,
                search_path(query_string: "id:#{@reference.id.to_s} show-instances-by-page:",
                            query_target: "references"),
                tabindex: increment_tab_index, 
                title: 'Search for the instances, sorted by page.',
                class: 'instance')
    %>
   <% end %>
<% end %>
  <br>
<% novelties = @reference.novelties %>
<% if novelties.size > 0 %>
  <%= link_to("#{pluralize(novelties.size,"Novelty")} #{search_icon_on_tab}".html_safe,
                        search_path(query_target: "References with novelties", query_string: "id:#{@reference.id}"), 
                        tabindex: increment_tab_index, 
                        title: 'Taxon novelties in this reference.',
                        class: 'instance') %>
<% end %>


<% unless @reference.doi.blank? %>
  <br/>
  <%= link_to('DOI',@reference.doi, title: "Link to the DOI entry.") %>
<% end %>

<% unless @reference.isbn.blank? %>
  <br/>
  <%= link_to('ISBN',@reference.isbn, title: "Link to the ISBN entry.") %>
<% end %>

<% unless @reference.issn.blank? %>
  <br/>
  <%= link_to('ISSN',@reference.issn, title: "Link to the ISSN entry.") %>
<% end %>

<% unless @reference.bhl_url.blank? %>
  <br/>
  <%= link_to("BHL #{icon('external-link')}".html_safe ,@reference.bhl_url, title: "Link to the BHL entry.") %>
<% end %>

<% unless @reference.tl2.blank? %>
  <br/>
  <%= link_to('TL2',@reference.tl2, title: "Link to the TL2 entry.") %>
<% end %>

<% if @reference.comments.size > 0  %>
  <%= divider %>
  <h5><%= pluralize(@reference.comments.size,'Comment') %></h5>
  <% @reference.comments.sort{|x,y| x.created_at <=> y.created_at}.each do |comment|  %>
    <%= render partial: 'comments/show', locals: {comment: comment} %>
    <%= divider %>
  <% end %>
<% else %>
  <%= divider %>
<% end %>



<h5>Reference #<%= @reference.id %></h5>
<br>
<br>
<%= created_by_whom_and_when(@reference).html_safe %>
<br>
<%= updated_by_whom_and_when(@reference).html_safe %>
<%= render partial: 'detail_line', locals: {label: 'System', info: "#{@reference.namespace.name}#{%Q(.#{@reference.source_system.downcase}.#{@reference.source_id}) if @reference.source_system}"} %>
{'fraction_non_alphanumeric': 0.19018083340613262, 'fraction_numerical': 0.0025334148685245044, 'mean_word_length': 3.207276736493936, 'pattern_counts': {'":': 2, '<': 220, '<?xml version=': 0, '>': 228, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3740074', 'n_tokens_mistral': 4107, 'n_tokens_neox': 3688, 'n_words': 651}