asciidoctor / asciidoctor.org

:globe_with_meridians: Asciidoctor project site. Composed in AsciiDoc. Baked with Awestruct.
https://asciidoctor.org
Other
322 stars 805 forks source link

Is there a syntax that allows no whitespace between some text and a link that comes right after it? #815

Closed behrangsa closed 5 years ago

behrangsa commented 5 years ago

AsciiDoctor renders this:

== ASN.1 https://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One[^↝^]

As

ASN.1

with a whitespace between "ASN.1" and the link.

Is there a syntax that allows no whitespace in situations like this?

mojavelinux commented 5 years ago

Yes. In this case you can strengthen the macro by adding the link: prefix.

== ASN.1link:https://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One[^↝^]

The link: prefix makes the macro "unconstrained" (which means it can be used anywhere).

behrangsa commented 5 years ago

Thanks. That worked. But the syntax is a bit weird/not nice. 🤔

I think Markdown’s syntax is better and makes more sense - it shows the boundary of tokens much better.

mojavelinux commented 5 years ago

How do you expect it to look? Like this?

== ASN.1https://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One[^↝^]

(And is that really much of an improvement?)

behrangsa commented 5 years ago

Hi @mojavelinux,

Like this:

== ASN.1[↝](https://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One)

which is rendered into:

ASN.1


Markdown does not supprt ^...^ for superscripts.

mojavelinux commented 5 years ago

We'll, that's Markdown not AsciiDoc. I'm asking you how you would make the AsciiDoc simpler.

behrangsa commented 5 years ago

Yes, I was saying the AsciiDoc syntax for links in general, IMHO, is not as elegant as Markdown.

I had a quick look at AsciiDoc.org and didn't find a simpler alternative.

One option is to define the link as an attribute and use it later. That way the delimiters and token boundaries become clearer:

:link-asn1: https://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One[^↝^]

== ASN.1{link-asn1}
elextr commented 5 years ago

Yes, I was saying the AsciiDoc syntax for links in general, IMHO, is not as elegant as Markdown.

Beauty is in the eye of the beholder, IMHO being able to simply show the URL with no markup and get a link is more elegant.

A terse inline separator is whats needed instead of link:, not changing Asciidoc into markdown. @mojavelinux maybe backslash space?

mojavelinux commented 5 years ago

I've argued before why I think the syntax for links is simpler in AsciiDoc than Markdown. I'm not going to rehash it here. But we're sticking with the syntax we have.

If you want to add support for the Markdown link syntax, you can write an inline macro with a custom match. See https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/lib/mentions-inline-macro.rb for an example. If you'd like to contribute such an extension to the lab, I'd gladly merge it.

A terse inline separator is whats needed instead of link:, not changing Asciidoc into markdown. @mojavelinux maybe backslash space?

I think it's fine the way it is.