I sent my code to my friend over Gmail but as you guess, the code is not highlighted in Gmail. Is there solution to highlight code that is sent over Gmail?
consider using gist.github.com
some benefits:
- you can copy and paste the syntax highlighted code into gmail
- snippet(s) can be shared with a hyperlink (also bookmarkable)
- you don't need an account to share code snippets
- code can still be kept private and is only shared with those have the secret link
- you can specify the language or snippet type, or even multiple snippets on a single page
- each lang can be specified with github flavored markdown
- you can also access historical changes of the snippet making it easy to track revisions over time
Paste your code to an online (maybe offline) syntax highlighter, like http://tohtml.com/ . Then copy/paste it to gmail & send.
consider using gist.github.com
some benefits:
- you can copy and paste the syntax highlighted code into gmail
- snippet(s) can be shared with a hyperlink (also bookmarkable)
- you don't need an account to share code snippets
- code can still be kept private and is only shared with those have the secret link
- you can specify the language or snippet type, or even multiple snippets on a single page
- each lang can be specified with github flavored markdown
- you can also access historical changes of the snippet making it easy to track revisions over time
Unless you absolutely have to have the code in the email, I would just put your code on Pastebin and link to the code.
If you must put your code in the email, you could use a GreaseMonkey script such as this C++ highlighter, however that will not work for the person you're sending it to, only you. Another solution is to export your code as HTML (with coloring), and send it to the person as HTML. Try Visual Studio's CopySourceAsHtml plugin if you're using Visual Studio.
If your language is not available at http://tohtml.com but you use GitHub you can also paste into a (private) gist there - http://gist.github.com/ - then copy&paste back to gmail.
Use markdown-here. You can write markdown in mails with the extension. The extension format mail content to html and highlight the code. I think this is an excellent extension.
If I have to send a snippet of Java code from Eclipse, I copy paste the code into Microsoft Word and then from Word into Gmail. That preserves the HTML formatting. If you use an email program such as Outlook, just copying and pasting from Eclipse into Outlook works.
You can use MSFT's monaco editor via github.dev
for this in two ways:
1. Just copy nice code
- Open https://github.dev
- Delete the contents of the markdown file, and write your code in syntax highlighting blocks (eg, "```ts").
- Copy code into gmail:
Personally, this is exactly what I was looking for.
2. Copy full markdown
- Write your whole email as markdown in the README editor.
- Press the "[Preview] README.md" tab.
- Copy/paste the result into gmail:
It is still nicely editable within gmail (though of course it won't re-highlight your syntax if you edit code).
The syntax highlighting is different (and in my opinion, uglier) with this option. The markdown preview engine is also a little wonky (definitely not the same as Github's); see the source for the above screenshot for an example (note the need to over-indent the inner numbered list).
Note that when you close & reopen the tab, the last contents you had will still be there. IMO this is a tremendous advantage, but if you are writing something private, you should delete the contents before closing the github.dev tab.
Try http://jsbin.com/. Easy to write html/JavaScript and test. Just copy paste the code from jsbin to gmail.
mac-oriented solution with Xcode:
I convert the code into an RTF file (using Xcode's qlmanage -p source_file -o
Command described in here http://hints.macworld.com/article.php?story=20091104002118164).
Then open it in Word (NOT in textedit, when copying from textedit color gets lost), and copy and paste it from Word into gmail.
For those of you looking to copy/paste from xCode to email, I simply copy from xCode and paste into Mac's default email client ("Mail"). It keeps all the formatting with colors.
© 2022 - 2024 — McMap. All rights reserved.