<p></p>
<p><b>@pablobm</b> commented on this pull request.</p>

<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/6518#discussion_r2518035749">lib/rich_text.rb</a>:</p>
<pre style='color:#555'>>        end.html_safe
     end
 
     private
 
+    def unshorten_links(text)
+      Settings.linkify.paths.each do |path_rule|
</pre>
<p dir="auto">Probably worth providing for the case where this setting is not present. This appears to be done for <code class="notranslate">Settings.linkify_hosts</code>, as <code class="notranslate">shorten_host</code> does <code class="notranslate">hosts&.include(host)</code>.</p>
⬇️ Suggested change
<pre style="color: #555">-      Settings.linkify.paths.each do |path_rule|
+      linkify_paths = Array.wrap(Settings.linkify&.paths)
+      linkify_paths.each do |path_rule|
</pre>


<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/6518#discussion_r2518039717">lib/rich_text.rb</a>:</p>
<pre style='color:#555'>> +        path_rule.list.each do |expression|
+          text.gsub!(Regexp.new("(?<before>\\s|^|>)(?i)#{expression}(?<after>\\s|$|<)"), "\\k<before>#{Settings.server_protocol}://#{path_rule.host || Settings.server_url}/#{path_rule.replacement}\\k<after>") if path_rule.replacement
+        end
+      end
+      [[Settings.linkify_hosts, Settings.linkify_hosts_replacement], [Settings.linkify_wiki_hosts, Settings.linkify_wiki_hosts_replacement]].each do |hosts, replacement|
+        text.gsub!(/(\s)#{Regexp.escape(replacement)}/, "\\1#{Settings.server_protocol}://#{hosts[0]}") if replacement && hosts&.any?
+      end
+      text
+    end
+
+    def shorten_link(url)
+      url = shorten_host(url, Settings.linkify_hosts, Settings.linkify_hosts_replacement)
+      url = shorten_host(url, Settings.linkify_wiki_hosts, Settings.linkify_wiki_hosts_replacement) do |path|
+        path.sub(Regexp.new(Settings.linkify_wiki_optional_path_prefix || ""), "")
+      end
+      Settings.linkify.print.each do |print_rule|
</pre>
<p dir="auto">Similarly:</p>
⬇️ Suggested change
<pre style="color: #555">-      Settings.linkify.print.each do |print_rule|
+      linkify_print = Array.wrap(Settings.linkify&.print)
+      linkify_print.each do |print_rule|
</pre>


<hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/6518#discussion_r2518092558">config/settings.yml</a>:</p>
<pre style='color:#555'>> +      replacement: "way/\\k<id>"
+    - list: ["relation/(?<id>\\d+)", "relation (?<id>\\d{5,})", "r(?<id>\\d+)"]
+      replacement: "relation/\\k<id>"
+    - list: ["changeset/(?<id>\\d+)", "changeset (?<id>\\d{5,})", "cs ?(?<id>\\d{5,})"]
+      replacement: "changeset/\\k<id>"
+    - list: ["note/(?<id>\\d+)", "note (?<id>\\d{5,})"]
+      replacement: "note/\\k<id>"
+    - list: ["user/(?<username>[^\\s]+)", "@(?<username>[^\\s]+)"]
+      replacement: "user/\\k<username>"
+    - list: ["(?<key>[^\"?#<>/\\s]+)=\\*?"]
+      replacement: "wiki/Key:\\k<key>"
+      host: "wiki.openstreetmap.org"
+    - list: ["(?<key>[^\"?#<>/\\s]+)=(?<value>[^\"?#<>\\s]+)"]
+      replacement: "wiki/Tag:\\k<key>=\\k<value>"
+      host: "wiki.openstreetmap.org"
+  print:
</pre>
<p dir="auto">I was a bit confused about the word <code class="notranslate">print</code> here, but now that I've looked into this in a bit more detail, I'm very confused 😅 with all this <code class="notranslate">shorten</code>, <code class="notranslate">unshorten</code>, <code class="notranslate">print</code> and <code class="notranslate">paths</code>.</p>
<p dir="auto">Would you be able to explain the pipeline for me to understand? An example of how the transformations take place.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/6518#pullrequestreview-3453087583">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLOK6KAGS5HHXK27UXT34MQ43AVCNFSM6AAAAACLXBWDSCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTINJTGA4DONJYGM">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLJUBCDP5PLWCSBVW5T34MQ43A5CNFSM6AAAAACLXBWDSCWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTWN2HXV6.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/6518/review/3453087583</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/6518#pullrequestreview-3453087583",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/6518#pullrequestreview-3453087583",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>