Couscous icon indicating copy to clipboard operation
Couscous copied to clipboard

Auto-link to GitHub issue in Markdown

Open mnapoli opened this issue 11 years ago • 7 comments

GitHub will automatically create a link to an issue in Markdown with text like this:

Implemented in #123.

Couscous could support the same behavior and turn #123 into [#123](https://github.com/CouscousPHP/Couscous/issues/123).

It would only work if the GitHub project is configured in couscous.yml, e.g.:

github:
    user: symfony
    repo: console

(same options that what's used in the default template)

mnapoli avatar Dec 12 '14 02:12 mnapoli

Is this necessary to only works if github integration is enabled? What if we allow to define a new configuration value:

(I use Phabricator link structure in this example)

issueLink: http://management.company.com/T#ISSUE_ID#

In your example the link for ths issue will be the following: http://management.company.com/T123 Of curse this may be a better solution because not break compatibility in the feature, and, if the user migrates from one issue tracking system to an other the links is easily replaceable.

Zolli avatar Jan 14 '16 13:01 Zolli

+1 @Zolli's idea. I'm currently trying to implement Couscous into a new release documentation system, but we don't use GitHub at my organization. Having customizable issue links when deploying to something other than GitHub would be fantastic. If I find time, I might be able to submit the pull request to do both GitHub and custom integration, as it's important to me.

cyberbit avatar Jan 14 '16 15:01 cyberbit

Sounds fair, and doable I guess. There has been a new release hours ago of the commonmark parser, and with the new AST and extension system it seems way easier than before to implement that. For example there is a "twitter auto-linker" plugin: https://github.com/thephpleague/commonmark-extras/blob/master/src/TwitterHandleAutolink/TwitterHandleParser.php

We still need Markdown Extra support however before being able to switch to this Markdown parser :/ (see #134).

mnapoli avatar Jan 14 '16 18:01 mnapoli

Currently, i try to create a Step that replaces issue numbers but i run into a problem with this :)

  • is already occupied by header definition in markdown

There is 2 possible soluton:

  1. Use a custom prefix ISSUE-#NUMBER_HERE be nice.
  2. Provide user a way to customize issue matching regex. So, we provide a default scheme (like in previous example), and if the user provides a custom one the matcher use this.

This raises some inconsistency across projects, so I do not recommend this.

Zolli avatar Jan 15 '16 16:01 Zolli

@Zolli I haven't looked into the details of the parser but isn't that possible to register # only when it's not the first character of the line?

mnapoli avatar Jan 15 '16 17:01 mnapoli

@mnapoli i think of that, but what if the user want to place the issue number to the beginning of the line? That is a big limitation.

Example:

...
### Limitations

#1212 is the main limitation...
#2121 also...

Zolli avatar Jan 15 '16 17:01 Zolli

Actually I just realized that #123 is not interpreted as a title so it's perfectly valid to turn it into an issue link. Try it out at http://spec.commonmark.org/dingus/

mnapoli avatar Jan 15 '16 17:01 mnapoli