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

Would like API to determine the language a file will be rendered as #374

Closed
aroben opened this issue Sep 26, 2014 · 4 comments · Fixed by #377
Closed

Would like API to determine the language a file will be rendered as #374

aroben opened this issue Sep 26, 2014 · 4 comments · Fixed by #377

Comments

@aroben
Copy link

aroben commented Sep 26, 2014

It would be nice to have an API like:

GitHub::Markup.language("README.md")
# => "markdown", or GitHub::Markup::Lanuage::MARKDOWN, or whatever

This would be useful for including in cache keys on github.com so we can make sure to re-render a file whenever its language changes. Right now we have to use the file's name instead as a proxy for this. But if something changes in GitHub::Markup's language-detection logic the cache won't get busted. Including the actual detected language in the cache key would fix this.

@bkeepers
Copy link
Contributor

>> GitHub::Markup.renderer("foo.md").class.name
=> "GitHub::Markup::Markdown"

Is that sufficient?

I've actually been thinking about this lately and wondering if this would make sense to push the render selection into linguist. There's not currently a huge need for it, but PRs like #343 and #252 made me think that this could be a linguist concern.

/cc @github/languages

@aroben
Copy link
Author

aroben commented Sep 26, 2014

Is that sufficient?

It'd be a shame to bust github.com's caches just because you decided to refactor your code. (Alternatively, it would be a shame to have to treat your class names as API, since you couldn't change them.) I think something more explicit would be better.

@bkeepers
Copy link
Contributor

Fair enough. What about adding #name to renderer?

>> GitHub::Markup.renderer("foo.md").name
=> "markdown"

@aroben
Copy link
Author

aroben commented Sep 26, 2014

That works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants