Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax for linking to another tool's page #784

Open
oxguy3 opened this issue Feb 22, 2016 · 13 comments
Open

Syntax for linking to another tool's page #784

oxguy3 opened this issue Feb 22, 2016 · 13 comments
Labels
decision A (possibly breaking) decision regarding tldr-pages content, structure, infrastructure, etc. mass changes Changes that affect multiple pages. syntax Issues related to the content and markup of the pages.

Comments

@oxguy3
Copy link
Contributor

oxguy3 commented Feb 22, 2016

Very often, it is necessary to refer to one tool from another tool's tldr page. For example, the csvcut.md page has a reference to unix's cut tool (Like Unix's cut command, but for tabular data.). I've just proposed that tldr pages could have a 'see also' section (in issue #785); if that is implemented, it would result in a lot more references to other tools.

Currently, the de facto standard for mentioning the name of another tool has been surrounding the name with graves. This works, but it'd be really great if there were a way to unambiguously refer to the name of another tool, so that TLDR clients could provide some easy way to jump to that other page (i.e. web clients could easily insert hyperlinks).

Here's what I have in mind: If you want to talk about a command called "foo", you write [foo]. TLDR clients will automatically determine which OS version of "foo" should be linked. (minor note: TLDR clients would also need to take into consideration that there might not be a tldr page for "foo" -- it's conceivable that you'd want to mention "foo" even if there's not a page for "foo" yet)

If you want to talk about a specific version of "foo", you write [linux/bar] or [common/bar] or whatever. This is very useful if there's a platform-specific tool AND a cross-platform tool of the same name. For example, in PR #764, we couldn't really come up with an easy way for the OS X page for base64 to reference the existence of the GNU coreutils cross-platform base64 tool. Having links like this would allow a mention of that other tool, and solve the issue of confusion there.


The one big issue with the syntax I've described is that it's incompatible with Markdown. Perhaps a better syntax would be <tldr://foo> for referencing any version, or <tldr://foo/linux> or <tldr://foo/common> or whatever for referencing specific versions. This is a valid link destination in Markdown syntax. (I don't think link title syntax -- i.e. [foo](tldr://bar) -- is a good idea, because there's no easy way for CLI clients to display both the link title and the URL)

@waldyrious waldyrious added the syntax Issues related to the content and markup of the pages. label Feb 23, 2016
@mflint
Copy link
Contributor

mflint commented Feb 26, 2017

I'm also wary about making changes to the agreed format which may not be friendly to clients which display the raw markdown as plain text.

Alternatively, we could supply an extra file for metadata. So foo.md remains unchanged, but a new file foo.meta.yaml contains some metadata:

--- 
related: 
  - {platform: "common", command: "bar"} 
  - {platform: "linux", command: "baz"} 

Another benefit is that clients can choose to ignore this extra file, and wouldn't need to change their markdown parsers.

@agnivade
Copy link
Member

I guess the point here is the "direct" linking of pages which only makes sense in web clients. For command line clients like the node-client, there is already a see-also section.

@mflint
Copy link
Contributor

mflint commented Apr 16, 2017

For command line clients like the node-client, there is already a see-also section

For any causal readers: node-client looks for command-names in code blocks. So the csvcut markdown contains `cut`, which is identified as the name of another command.

I like this! Copying the idea for my iOS client.

@waldyrious
Copy link
Member

waldyrious commented May 1, 2017

I'm also wary about making changes to the agreed format which may not be friendly to clients which display the raw markdown as plain text.

I think we can come up with a format that displays well in raw markdown, both because that way the simple clients (and directly reading the pages as plain text) would also benefit from the additional info.

Of course, that would require adaptation from the clients that do parse the markdown. A process similar to #958 would be required to make sure none of the actively maintained clients are broken. Edit: on second thought, if the syntax does not overload any existing syntax (or standard markdown syntax used for something else), I'd expect clients to merely ignore the extra markup and simply render it as plain text, so that shouldn't be a problem. 🎉

@jeeftor
Copy link
Collaborator

jeeftor commented May 1, 2017 via email

@waldyrious
Copy link
Member

Adding a reference to #2621 where I proposed the [[...]] syntax, which has precedence as internal links in similar lightweight markup languages, such as mediawiki.

Given the edit I made to my previous comment, I'd say we could actually move forward with this one without having too coordinate with the clients. Anyone up for doing the changes? :D

@sbrl
Copy link
Member

sbrl commented Dec 13, 2018

Great idea! I'm down for [[command]], as it appears to be a better alternative to graves.

I think a simple find and replaces should do the trick:

\b` -> [[
`\b -> ]]

Would that be sed -e 's/`\b/]]/g' -e 's/\b`/[[/g' with sed? I'm unsure as to whether sed supports the \b (word boundary) syntax.

@sbrl
Copy link
Member

sbrl commented Dec 13, 2018

Also, we really need a specification document. Is there a master list of everywhere we've discussed things that should go in the client spec?

It's the end of the University semester, so I might be able to draft something up.

@waldyrious
Copy link
Member

I'm afraid such a bulk replacement method might get us a lot of false positives, but sure, let's try and see. As for the tool to use, I would suggest trying perl instead. The tldr page for perl has an example for how to use it as a sed replacement (and of course its regex support is much more complete).

Regarding the page spec, IIRC the main discussions have happened in #958 and #1065, plus those linked from #1082, and generally those under the syntax label.

@sbrl
Copy link
Member

sbrl commented Dec 14, 2018

Ah, good thinking. We could use grep's PCRE-compatible mode to check for what would be replaced:

find . -type f -iname "*.md" | grep -iP '\b`[^`]+`\b

And thanks! I'll take a look at writing something up if I have time (or don't get distracted :P)

@sbrl
Copy link
Member

sbrl commented Nov 27, 2019

As an update to this long-standing issue, informally we've been adding an extra description line like this:

> See also: `command_a`, `command_b`.

@waldyrious
Copy link
Member

Thanks for the update and bump, @sbrl. I'll also add that we do have more detailed page formatting guidelines now, as well as a client spec, so we could simply adjust those two to support the proposed linking syntax (assuming there's no objection to it) and then start converting the pages!

@sbrl
Copy link
Member

sbrl commented Nov 28, 2019

Yeah, @waldyrious!

I think the client spec doesn't need updating though, because all it states is that clients must support CommonMark, and the syntax above is CommonMark-compliant.

@bl-ue bl-ue added the decision A (possibly breaking) decision regarding tldr-pages content, structure, infrastructure, etc. label Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
decision A (possibly breaking) decision regarding tldr-pages content, structure, infrastructure, etc. mass changes Changes that affect multiple pages. syntax Issues related to the content and markup of the pages.
Projects
None yet
Development

No branches or pull requests

7 participants