Sha256: 16d83b7cb5206041a19c27b7e413b8c22b35723210ceb1d968051e887dba42bd
Contents?: true
Size: 526 Bytes
Versions: 25
Compression:
Stored size: 526 Bytes
Contents
# Define a filter for hyphenating long IRIs Nanoc::Filter.define(:scholar_hyphenate_iri) do |content| content = content.dup # Replace in-text URLs content.gsub! %r{>https?://[^>]+?} do |match| hyphenate(match) end # Replace mandatory links content.gsub! %r{<a href="([^"]+)"[^>]*\s+class="mandatory"} do |match| %{#{match} data-link-text="#{hyphenate $1}"} end content end # Add zero-width space after slashes and hyphens to allow hyphenation def hyphenate text text.gsub %r{(?<=/|-)}, "\u200B" end
Version data entries
25 entries across 25 versions & 1 rubygems