Display C sources in chrome
2 comments
There are extensions that open such files. These extensions do mainly syntax highlighting like:
https://chrome.google.com/webstore/detail/cgjalgdhmbpaacnnej...
https://chrome.google.com/webstore/detail/epmaefhielclhlnmjo... (offers some more features but does not work when AdBlock is enabled)
So opening instead of downloading is possible by using an extension. Perhaps an extension already exists which does that without any other features.
So opening instead of downloading is possible by using an extension. Perhaps an extension already exists which does that without any other features.
I use slackware on a laptop with 512mb RAM. Last time i build chromium package with slackbuilds, it takes a night long..
After a bit of investigation i found that at least for local files you can override this by defining your preferred mime types in ~/.local/share/mime/globs2 as follows:
The first field is the priority (smaller number means more important), then follows the mime type, then the pattern that you are matching. The default rules (/usr/local/share/ ...) have a priority of 50 for .c, .h and so on.
For remotely-served files, the browser relies on the MIME Type supplied by the server and the trick above does not work.
Looking at the Chromium sources
it seems that a partial fix can be achieved by adding the list of types we want to display to the array
+ "text/x-csrc", + "text/x-chdr", ... }
although i'd rather find a way to override the server-supplied mime type in a way that does not require rebuilding Chrome.
Anyways, at least for local browsing, this seems a significant improvement.