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

Automatically Syntax-Highlight received Code #250

Closed
leolabs opened this issue Nov 10, 2014 · 142 comments
Closed

Automatically Syntax-Highlight received Code #250

leolabs opened this issue Nov 10, 2014 · 142 comments

Comments

@leolabs
Copy link

leolabs commented Nov 10, 2014

It would be great if we were able to send code snippets via Telegram in a way that is nicely readable by the receiver. I'm chatting a lot with other developers and often, I feel the need for such a feature.

Related issue on the Telegram bug tracker: https://bugs.telegram.org/c/824

@sigod
Copy link

sigod commented Nov 10, 2014

Also, support for GitHub's Markdown would be a wise feature.

@animalillo
Copy link

Code highlighting, or at least tabulation, would be awesome

@leolabs
Copy link
Author

leolabs commented Nov 11, 2014

The thing is, highlighted code doesn't have to be a new message format like images or videos as it's also just text. It could be marked like code in GitHub flavoured Markdown using three backticks or something like that.

@animalillo
Copy link

or just by using some library that detects most common programming structures, there is probably some library made to detect code inserted between text

@bararchy
Copy link

I'll also appreciate this !

code here

will be a nice addition

@meness
Copy link

meness commented Dec 16, 2014

I like the idea. I'm waiting for later versions of Telegram to see whether I need Kik Messenger installed on my phone or not. Please keep doing well developers.

@HallEffect
Copy link

I absolutely agree. Syntax highlighting is very useful thing

@ezdev128
Copy link

ezdev128 commented Mar 3, 2015

I disagree about automatic mode. Should be some markup language like [code]int main()...[/code] instead of automatic to avoid bugs and excessive CPU consumption on parsing messages.

@avestura
Copy link

Nice Feature, Like that ;)

@Ziul
Copy link

Ziul commented Jun 13, 2015

I would love that support! A markdown support as in GitHub or on HabitRPG's chat would solve well the problem about a non-dev sending a sample message and te app reading it as source code.

@andrecamposgm
Copy link

I know telegram is a mobile-first application, but we already have this kind of functionality in other chat tools like slack that use it in both mobile and desktop implementation.
This kind of markdown language would really help telegram to be adopted by technical teams on internal communication. I am trying to convince my team to replace slack and skype by telegram and this feature would help me a lot on this task!
Keep doing this great work!

@joeldrapper
Copy link

@GreatMedivack you just had to be different to everone else ⬆️

@brawaru
Copy link

brawaru commented Oct 6, 2015

+1 from me and +1 from my cat

@lawrencegs
Copy link

What would be the best way to handle this? Slack does code highlighting, but its not markdown style, rather code upload. UX matters too.

@pascalchevrel
Copy link

+1 for the same system as Github, backticks with the language code behind, would be super useful

@lopezjurip
Copy link

This was implemented, check this out:
image

Inline `code` has `back-ticks around` it.
```
var s = "Block highlighting";
alert(s);
```

@Ziul
Copy link

Ziul commented Nov 26, 2015

This is just the monospace, not Syntax-Highlight. And if a line have more than 51 characters, it breaks the line (if was even the 80 chars i would understand...but why 51?). And the mobile still not working well.
If the feature is already implemented, it need some improves.

@bskydive
Copy link

+1 highlight syntax like in gitter

@joeldrapper
Copy link

It's worth noting that it's now possible to format code blocks by using the @bold bot which accepts markdown.

@Niklan
Copy link

Niklan commented Jan 11, 2016

@joeldrapper @bold didn't support syntax highlighting and use word breaking to separate line. It's makes code more unreadable if you send some example to man for showing some example, it's hard to read and still better sending code with pastebin. It's needs horizontal scroll at minimum, but i don't know, support it's telegram or not.

@telegramdesktop
Copy link
Collaborator

@Niklan Currently TDesktop does not support horizontal scroll in messages layout :(

@theus
Copy link

theus commented Jan 13, 2016 via email

@lawrencegs
Copy link

If inline-bot is the preferred ways for bold & italic... then we will probably have to resort to inline-bot for this "programmer only" case?

@theus
Copy link

theus commented Jan 13, 2016

@lawrencegs Could be inline-bots a way to do this, but the API don't have a implement
to modify colors in text. It has only a simple markdown.

@haimn
Copy link

haimn commented Mar 1, 2016

I love the ``` block and I use it a lot, but syntax highlighting will be a new level.

@AndydeCleyre
Copy link
Contributor

A related development: tok, an early telegram client from the kde group, recently added this feature, though I haven't tested it.

@amogorkon
Copy link

There's a vscode extension for telegram I'd love to use, but it's a fairly pointless if such basic features aren't supported.

@ilya-fedin
Copy link
Contributor

There's a vscode extension for telegram I'd love to use

Am I missing something?
изображение

@amogorkon
Copy link

There's a vscode extension for telegram I'd love to use

Am I missing something?
изображение
Unbenannt

@ilya-fedin
Copy link
Contributor

for me it returns nothing :(

@amogorkon
Copy link

What version are you running? I've got 1.60.2

@ilya-fedin
Copy link
Contributor

VSCodium 1.59.0

@amogorkon
Copy link

Could be related to VSCodium/vscodium#448

@Miuler
Copy link

Miuler commented Sep 9, 2022

Please, add Syntax-Highlight

@adriangalilea
Copy link

Just here to also bump the request of Syntax-highlight.

@vsolontsov-ll
Copy link

+1 for this feature!

@Andrew15-5
Copy link

+1 for manual code block:

```language
```

@Andrew15-5
Copy link

As was pointed out here, web version does support manual code block (as I showed in my previous comment), but not for all languages. I tried python and latex and only the first one works (GitHub supports both).

@kirsan31
Copy link
Contributor

kirsan31 commented Oct 5, 2023

It's coming? 🤔🙏
2414e92

@john-preston
Copy link
Member

It's done in some way. In the upcoming version you'll be able to specify language after triple-tick:

```cpp
code here
```

Then it'll be a usual monospace block but with some syntax highlighting on top. It won't be supported in the message input field (at least for now, maybe ever), but some improvements may come when there is more time for that.

@john-preston
Copy link
Member

Lines will break as before, implementing a horizontal scroll for a part of a message in the middle of the message bubble is something really complex and not planned right now.

@kirsan31
Copy link
Contributor

kirsan31 commented Oct 6, 2023

@john-preston
First of all - thank you 🙏

I've tried current build. Bugs:

  1. ```cs (default for c#) doesn't work, ```dotnet doesn't work too, only ```csharp is working.
  2. For cpp and c# and I think for all same synaxis - wrong color for last closing bracer:
    image

@john-preston
Copy link
Member

@kirsan31 I see, prism.js has aliases for languages, that aren't handled in the libprisma fork. Thanks for pointing that out.

Last bracer is a bug, thanks, fixed in code.

@Aokromes
Copy link
Collaborator

b209683

@Piterden
Copy link

@john-preston , first of all thank you so much for this feature! Looks really good, but there are a few remarks:

  • Unnecessary line wrap. And here is what it looks like:
    image
  • It is impossible to change the highlighting language, moreover, when editing, the text indicating the language disappears completely. I would make a drop-down menu with a list of languages.
  • Lack of reaction to the change of app theme. It seems to me that it would be logical if the syntax highlighting colors were set by the theme editor, because there are not so many different highlighting areas to put them there.
  • Many people are using monospace font not for code, so the word code when no language is specified seems a bit superfluous to me. Monospaced code-blocks have the ability to be copied by a click on them and I had seen many times people are using this feature. But if be honest, it bothers me personally.
  • It would be ideal to have internal a code recognizer.

PS About prismjs: it hasn't code recognizer and this was the main reason I refused it, as I remember. I used highlight.js instead.

@john-preston
Copy link
Member

  1. Providing horizontal scrolling inside the message bubble is a very complex task on its own and not planned in this release definitely. Maybe later if there'll be time. Might be in another nine years though 🫣
  2. Editing is bad indeed, should be improved somehow.
  3. The colors are taken from theme, but from statistics color keys 😂
  4. For quotes there will be a dedicated feature starting with this release. So monospace code blocks are left for code. They can be copied by a click on the block title.
  5. It would be.

@rtfmoz2
Copy link

rtfmoz2 commented Oct 29, 2023

@Piterden So what languages are supported. There is no doco anywhere and once I find out I can update. Since you mentioned highlight.js I take it these then? https://highlightjs.org/

@kirsan31
Copy link
Contributor

So what languages are supported.

https://prismjs.com/index.html#supported-languages

@AndydeCleyre
Copy link
Contributor

AndydeCleyre commented Oct 29, 2023

So what languages are supported.

https://prismjs.com/index.html#supported-languages

This list includes Factor, but I don't get any highlighting for that in the latest Android app.


EDIT: I just tested on the desktop app, where it does color strings and numbers (only?) for Factor.

@Andrew15-5
Copy link

Speaking of Android app, I immediately noticed that syntax colors differ between desktop and mobile app. I even applied my custom "desktop" theme on the smartphone, and it still shows different colors on the same message with a code. I checked and didn't see any color values that are applied to the code. So these code color schemes are platform dependent. This is not what I expected. And I want to say that Android colors are better (at least green color for "strings" is more natural IMO than orange).

So, adding a list of color schemes would be a huge feature. Imagine, every dev will see the same code message (in a group chat) in the color scheme that they want. This would be amazing. But it would require a separate menu (section) with a variety of color schemes, including custom ones. But if this is too ambitious, then a set of values in theme's color palette, which are specific for each code token type (string, number, keyword etc.), would do the trick.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests