remarkjs / remark-github Goto Github PK
View Code? Open in Web Editor NEWremark plugin to link references to commits, issues, pull-requests, and users, like on GitHub
Home Page: https://remark.js.org
License: MIT License
remark plugin to link references to commits, issues, pull-requests, and users, like on GitHub
Home Page: https://remark.js.org
License: MIT License
Firstly, thanks for the module! 👍
I wonder if it would be possible to provide an option to turn off the bold formatting for things like @mentions
? I think it's better to have this in CSS instead; just because GitHub make these bold it doesn't mean we have to! 😄
We want to keep references as text and transform links only.
When options.repository
== false, disable references transform.
No.
Error:
this.Parser.prototype is undefined
When using remark-github
, it will attempt to detect commit hashes and convert them to links as per this regex. The Regex basically states that any 7-40 character long hash-looking string on a new line is converted. This poses some problems for our users who paste lists of other numbers.
Consider the following markdown content:
Hey Steve. Can you please review these customer invoices?
1600100999
1600100960
At the moment, remark-github
will truncate and convert those numbers to hash links like this:
This is not desired behaviour as the numbers aren't actually commit hash links in GitHub in this context.
My idea was to make a small tweak to the Regex to require at least 1 alpha character to be in the string before considering it a hash (add [a-z]+
to the rule). This does mean that the library will sometimes have a false negative for cases where a hash actually only has numbers but I think it's much more likely that a typical Git hash will have at least 1 letter in it.
I recognize this is a messy/unsound solution, but I think the tradeoff between UX and soundness might be worth it here.
What do you think? Would you consider such a change?
The proper solution here would be to not rely on Regex alone, and instead do some kind of actual query to your GitHub repo to check the validity of hash strings before converting them to links, but that's well outside the scope of this library.
Previously, GitHub linked @mention and @mentions to their blog post introducing the feature (https://github.com/blog/821, now at https://github.blog/2011-03-23-mention-somebody-they-re-notified/).
This no longer happens.
Process @mention
.
Should remain unlinked @mention
.
Linked: [**@mention**](https://github.com/blog/821)
.
defaced
, acceded
, and effaced
are words that sometimes appears in actual text, and most likely don’t appear as a SHA. Deny them too:
remark-github/lib/tokenizer/hash.js
Line 28 in 3cf0e0b
Hello!
Is there a way to prevent autolinking for specific text, e.g. @name
?
Pending.
Pending.
I get the following error with the following package.json
"repository" field:
CHANGELOG.md
1:1 error Error: Missing `repository` field in `options`
at Function.github (/Users/user/Projects/color-convert/node_modules/remark-github/lib/index.js:76:11)
Repository value: https://github.com/Qix-/color-convert
I believe the trailing -
on the username is causing it to fail.
In our content, people often use @mentions
to mean Slack handles, not GitHub handles. Since the GitHub usernames are not verified by this plugin, it would result in a lot of false or invalid links. I would really like to use the plugin for the other functionality though.
Would love an option to disable @mention
highlighting.
None that I can think of.
remark-github
, [email protected]
No response
The following will show tests are broken:
git clone [email protected]:remarkjs/remark-github.git
cd remark-github
npm install
npm test
This will fix them:
npm install [email protected]
npm test
Tests work, just like they did before [email protected]
was released
Two fixture tests fail.
--- a/test/fixtures/reference-advanced/output.md
+++ b/test/fixtures/reference-advanced/output.md
@@ -1,4 +1,4 @@
-# User\@SHA
+# User\\@SHA
Multiple slashes: foo/bar/baz@[`0000000`](https://github.com/wooorm/remark/commit/0000000), foo/bar/baz#1, @foo/bar/baz.
@@ -6,8 +6,8 @@ Dashes around slashes: [foobar-/baz@`0000000`](https://github.com/foobar-/baz/co
Upper-case projects: [foobar/bAz@`0000000`](https://github.com/foobar/bAz/commit/0000000), [foobar/Baz#1](https://github.com/foobar/Baz/issues/1).
-[**@foo-/bar**](https://github.com/foo-/bar), @foo/-bar.
+@foo-/bar, @foo/-bar.
[f/b#1](https://github.com/f/b/issues/1). f/b#0. [f/b@`0000000`](https://github.com/f/b/commit/0000000).
-.[#1](https://github.com/wooorm/remark/issues/1). .[**@0000000**](https://github.com/0000000). foo#. bar\@.
+.[#1](https://github.com/wooorm/remark/issues/1). .[**@0000000**](https://github.com/0000000). foo#. bar\\@.
diff --git a/test/fixtures/sha-range/output.md b/test/fixtures/sha-range/output.md
--- a/test/fixtures/sha-range/output.md
+++ b/test/fixtures/sha-range/output.md
@@ -1,6 +1,6 @@
range comparison: [`e2acebc...2aa9311`](https://github.com/wooorm/remark/compare/e2acebc...2aa9311)
-actual unicode ellipsis: [`e2acebc`](https://github.com/wooorm/remark/commit/e2acebc)…2aa9311
+actual unicode ellipsis: e2acebc…2aa9311
punctuation before: -e2acebc...[`2aa9311`](https://github.com/wooorm/remark/commit/2aa9311)
@@ -8,7 +8,7 @@ punctuation before: -e2acebc...[`2aa9311`](https://github.com/wooorm/remark/comm
two: [`e2acebc`](https://github.com/wooorm/remark/commit/e2acebc)..[`2aa9311`](https://github.com/wooorm/remark/commit/2aa9311)
-one: [`e2acebc`](https://github.com/wooorm/remark/commit/e2acebc).2aa9311
+one: e2acebc.2aa9311
fork? [other@`e2acebc`](https://github.com/other/remark/commit/e2acebc)...[`2aa9311`](https://github.com/wooorm/remark/commit/2aa9311)
Node v16
npm 8
Linux
No response
latest
https://codesandbox.io/s/cool-swirles-vbp4nr?file=/src/index.js
as above in codesandbox
either the repository
field is optional, in which case it should not error, or the docs and code samples should show that it is required
No response
No response
No response
No response
It seems that remark-github ignores repositories including dots in their name such as wooorm/wooorm.github.io.
When input is (markdown):
https://github.com/wooorm/wooorm.github.io/commit/c01f
expected output is (html):
<a href="https://github.com/wooorm/wooorm.github.io/commit/c01f">
wooorm/wooorm.github.io@<code>c01f</code>
</a>
but actual output is (html):
<a href="https://github.com/wooorm/wooorm.github.io/commit/c01f">
https://github.com/wooorm/wooorm.github.io/commit/c01f
</a>
Because GitHub do so: wooorm/wooorm.github.io@c01f
For example, if you start off with:
#123
It becomes
[#123](https://github.com/wooorm/remark-github/issues/123)
However if you change the issue number it still has the same inaccurate link:
[#456](https://github.com/wooorm/remark-github/issues/123)
Because remark-github
extends the remark Parser to do its work, it doesn't process nodes that were added by an earlier plugin (after parsing). For example:
remark()
.use(require('remark-changelog'), { fix: true })
.use(require('remark-github'))
Is there something that other plugins can do to get their new (text) nodes processed by the parser and thus remark-github
?
[email protected]
(latest)I have this script:
#!/usr/bin/env node
const fs = require('fs');
const remark = require('remark');
const github = require('remark-github');
remark()
.use(github, {
repository: 'my/repo'
})
.process(fs.readFileSync('my-file.md', { encoding: 'utf8' }), function (err, file) {
if (err) throw err;
process.stdout.write(String(file));
});
function throwError(message) {
throw new Error(message);
}
This is the input:
- #123
- #456
This is the output:
- [#123](https://github.com/my/repo/issues/123)
- [#456](https://github.com/my/repo/issues/456)
It added spaces between the -
and the issue reference. Is that a misconfiguration on my part or a bug?
Hi!
This line causes a npm warning!
WARNING in ...Storybook_mono/node_modules/remark-github/lib/index.js
47:13-73 Critical dependency: the request of a dependency is an expression
Hello! It would be nice to add a support for an Enterprise GitHub, by providing custom base URL.
If not provided, it could be read from package.json and default to https://github.com
The logic would be
options.baseUrl
explicitly, use itoptions.repository
, extract and use itpackage.json
, extract and use itvar vfile = require('to-vfile')
var remark = require('remark')
var github = require('remark-github')
remark()
.use(github, { baseUrl: 'https://whatever-entreprise-github.company' } )
.process(vfile.readSync('example.md'), function(err, file) {
if (err) throw err
console.log(String(file))
})
I see none.
For example, 2.10.2.20200130
(a version number) is rendered as:
2.10.2.[2020013](https://github.com/remarkjs/remark-github/commit/20200130)
when it's expected to be rendered in verbatim. Also, note the omission of the trailing 0
.
remark-github
9.0.0 (via gatsby-plugin-mdx
)Try to render 2.10.2.20200130
in an MDX file.
2.10.2.20200130
should be rendered as it is.2.10.2.20200130
is rendered incorrectly:
2.10.2.[2020013](https://github.com/remarkjs/remark-github/commit/20200130)
remark-github
adds links to an email address that looks like a git commit and author.
[email protected]
, [email protected]
, [email protected]
(latest)test.md
:
example1 ([email protected])
example2 ([email protected])
const vfile = require('to-vfile')
const remark = require('remark')
const github = require('remark-github')
remark()
.use(github, { repository: 'https://github.com/test/test' })
.process(vfile.readSync('test.md'), function (err, file) {
if (err) throw err
console.log(String(file))
})
example1 ([email protected])
example2 ([email protected])
example1 ([`1234567`](https://github.com/test/test/commit/1234567)[**@example**](https://github.com/example).com)
example2 ([`abcdef0`](https://github.com/test/test/commit/abcdef0)[**@example**](https://github.com/example).com)
Note: doesn't happen when the email address is enclosed in <>
. Is that the preferred solution, or should it be fixed in remark-github
?
The ability to customize the generated tags w/ options such as...
{target: '_blank', ref: 'external'}
The primary use case is to define target="_blank"
to open links in a new tab.
Whatever valid options are defined are added to the generated anchor tags.
There is remark-external-links but unfortunately that only gets applied against the source markdown. These links exist only in their generated html and so it cannot be applied to them.
env: with npm and webpack
I don't know what to do to solve the problem
WARNING in .//mdast-github/index.js/mdast-github/index.js 368:19-370:14
Critical dependencies:
368:19-370:14 the request of a dependency is an expression
@ ./
WARNING in .//mdast-github/LICENSE/mdast-github ^./.*$
Module parse failed: /Users/user-mac/Desktop/workspace/test/www/node_modules/mdast-github/LICENSE Line 1: Unexpected identifier
You may need an appropriate loader to handle this file type.
| (The MIT License)
|
| Copyright (c) 2015 Titus Wormer [email protected]
@ ./
WARNING in .//mdast-github/history.md/mdast-github ^./.*$
Module parse failed: /Users/user-mac/Desktop/workspace/test/www/node_modules/mdast-github/history.md Line 7: Unexpected number
You may need an appropriate loader to handle this file type.
|
|
| 1.0.0 / 2015-08-19
| ==================
|
@ ./
WARNING in .//mdast-github/package.json/mdast-github ^./.*$
Module parse failed: /Users/user-mac/Desktop/workspace/test/www/node_modules/mdast-github/package.json Line 2: Unexpected token :
You may need an appropriate loader to handle this file type.
| {
| "_args": [
| [
| "mdast-github",
@ ./
WARNING in .//mdast-github/readme.md/mdast-github ^./.*$
Module parse failed: /Users/user-mac/Desktop/workspace/test/www/node_modules/mdast-github/readme.md Line 1: Unexpected token ILLEGAL
You may need an appropriate loader to handle this file type.
| # mdast-github
|
| Auto-link references to commits, issues, pull-requests, and users like GitHub: Writing on GitHub.
@ ./
webpack: bundle is now VALID.
webpack: bundle is now INVALID.
Hash: e08bf16a6fc25d471f1f
Version: webpack 1.12.9
Time: 346ms
Example:
https://github.com/wooorm/remark-github/issues/1#issuecomment-161998911
Is turned into:
And:
https://github.com/wooorm/remark/issues/133#issuecomment-172238087
(another repo), yields:
And a pr:
https://github.com/wooorm/remark/pull/134#issuecomment-172237535
Looks like:
In README, plugin currently only support issues, commits, comments, users...
It looks like https://github.com/remarkjs/remark-github
will not render to remarkjs/remark-github. Would like support it in the future? thx
https://github.com/remarkjs/remark-github
-> remarkjs/remark-github
Write a custom remark plugin
11.2.3
No response
It is kind of annoying to reproduce, but this is what causes remarkjs/vscode-remark#65 builds to fail on Windows. When VSCode is opened in Windows, it doesn’t send the desired cwd
to the language server process, meaning process.cwd()
doesn’t match file.cwd
. The language server makes sure file.cwd
is correct, and plugins are typically supposed to use that.
remark-github
uses file.cwd
to lookup package.json
, so an implementation can set a custom cwd
when runningt the unified pipeline.
remark-github
uses process.cwd()
, which is often the same as file.cwd
but not always. This leads to unexpected behaviour.
Node v16
npm 8
Linux
Other (please specify in steps to reproduce)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.