Prevent hyperlink

How can I prevent a www.example.com URL from becoming a hyperlink, without (ab)using another formatting feature such as inline code formatting?

I notice I can quote: “www.example.com”, but I’d like to avoid that. Is it possible to somehow escape the auto-link change as I create/edit a post?

Backslashes?
www\.example\.com
www.example.com

I noticed this solution does not work any longer. It was the first thing I tried before googling and finding this post. I’ll keep looking for a solution. Surprisingly, even www.example.com is converted into a hyperlink if on the same line as a regular link.

Looks like I’ll be using www<span>.</span>example<span>.</span>com
www.example.com

Why in the world would you do any of that when you can simply use a proper code span with the ` key?

www.example.com

See commonmark.org/help

Because it’s not code?

Preformatted text has other meanings. I reject the premise in the first post, it reads like “how can I avoid hitting myself if I really like hitting myself?”

I just want to be able to type out a domain name as text (without formatting/styling) and have enough OCD not only go to length of using <span>.</span>, but also to spend time finding out why \. doesn’t work as expected and post about it.

Fortunately, not everyone is cursed with my level of OCD. :wink:

Zero width Unicode spacers would also work but anyone who copies and pastes that URL is in for a surprise… and not the good kind! Dunno if @sam has any other ideas but the request is really odd.

Yeah bypassing linkify is not easy:

https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js

and

We had a similar request with complaints about m.sc being autolinked.

I do wonder if we should side with @Vitaly here and disable linkify fuzzy out of the box. Cause https://cnn.com will continue to work even if linkify fuzzy is disabled. So all you do is lose out on www.cnn.com

I think we should probably amend the test here to have a simpler bypass for fuzzy, just not sure what it would be

Well, using ` does turn the text into a <code></code> section instead of <pre></pre> which is preformatted text.

@notriddle Technically speaking there is a difference, but there really is no reason why <code></code> can’t be acceptable – URL’s are a form of “code” afterall.

Well said. The few cases where it has come up for me are when I’m trying to point someone to one url instead of another – i.e., when I’m trying to de-emphasize a URL. For example:

A: Just use smile.amazon.com instead of amazon.com and select OpenMRS, Inc. as your charity.

B: Just use smile.amazon.com instead of amazon.com and select OpenMRS, Inc. as your charity.

B is certainly a reasonable workaround; personally I prefer A. But, this is such an embarrassingly small issue, I can’t justify anyone (including myself) spending time on it. I’ve got amazon<span>.</span>com as a workaround for the 1-2 times I’ll ever need this again, so I’m happy… clearly afflicted with too much focus on meaningless details… but happy.

The awesome folks working on Discourse have more important things to do. I recommend focusing on other ways to continue making Discourse the most awesome forum software in the world and let this thread fade away. I’m sure I’ll re-discover this thread in a few years when this comes up again, so won’t need to post about it ever again. :nerd_face:

(and I promise to not suggest a Discourse GSoC project to add support for www\.example\.com)

Основная цель нашего форума — обсуждение компании Alarm.com, поэтому пользователи постоянно пишут «Alarm.com» в сообщениях, вероятно, в 50 % тем. В результате мы невольно будем создавать ссылки на Alarm.com в огромном количестве случаев.

Я пробовал полностью отключить функцию linkify, но это создаёт более серьёзную проблему: пользователи не смогут размещать URL на отдельной строке для создания onebox.

Мы бы очень хотели иметь возможность отключить «fuzzy»-распознавание ссылок, чтобы избежать этой проблемы, но при этом сохранить возможность автоматического создания ссылок для полных URL. Возможно ли это?

Дополняю… Похоже, что если изменить defaultOptions в файле vendor/assets/javascripts/markdown-it.js, установив fuzzyLink в false, как предложил Сэм, это решит мою проблему. Но это создаёт большие неудобства, так как нам не хочется вручную вносить это изменение каждый раз при обновлении.

Затем я наткнулся на более простое решение. Настройка markdown linkify tlds представляет собой список доменных зон верхнего уровня, которые считаются URL-адресами при нечётком связывании. Если удалить все эти зоны и добавить лишь одну вымышленную зону, которая никогда не появится в посте, это фактически отключит fuzzyLink. В списке должна быть хотя бы одна зона, иначе, судя по всему, любой текст, заканчивающийся на ., будет обрабатываться как ссылка.

Таким образом, изменение кода не требуется: мы можем отключить fuzzyLink, удалив реальные доменные зоны из настройки и добавив вымышленную.

Ещё один способ отключить автопреобразование слов в ссылки.

Добавьте \u003cspan\u003e\u003c/span\u003e посередине текста.


Детали

На нашем сайте компонент темы Auto linkify words настроен на обработку слова SWI-Prolog.

Чтобы предотвратить преобразование SWI-Prolog в ссылку, например SWI-Prolog, а также чтобы оно не отображалось как фрагмент кода, например SWI-Prolog, можно вставить \u003cspan\u003e\u003c/span\u003e посередине слова, например SWI\u003cspan\u003e\u003c/span\u003e-Prolog. Это предотвращает распознавание слова компонентом Auto linkify words, а поскольку тег \u003cspan\u003e\u003c/span\u003e рендерится как невидимый элемент в браузере, решение работает именно так, как требуется в данном случае, то есть для SWI-Prolog.

Вы можете использовать <span></span>, чтобы обернуть домен, который стал ссылкой, вместо того чтобы вставлять его посередине. Это полезно при упоминании компаний и других собственных названий, содержащих точки, например, itch.io.

Например, если вы просто введёте itch.io в редакторе Markdown, он станет ссылкой: itch.io

Но вы также можете ввести <span>itch.io</span>, и тогда он не станет ссылкой: itch.io

Вам не обязательно вставлять <span></span> посередине домена, как в примере itch<span></span>.io, но это тоже работает: itch.io

(Было бы здорово, если бы @precessor или модератор изменил отметку «:white_check_mark: Решение» на этот ответ вместо текущего выбранного решения; старое решение работало в 2016 году, но сейчас больше не работает.)

Это единственное, что сработало у меня сегодня.

Itch.io


Itch`.`io

Предварительное форматирование находится на панели инструментов и используется быстрее :wink:

Разве что это меняет формат, так зачем вам это нужно вместо варианта, который формат не меняет?

Потому что формат не важен. Важно только то, что вы получаете. А цель здесь — предотвратить гиперссылки, и моё решение всё ещё самое простое. И самое быстрое :wink: