Syntax highlighting for the coders, invites for everyone
Another open-source contribution has now been implemented - @Soptik wrote the code to add support for syntax highlighting, which should be great for topics like the programming challenges in ~comp.
I'll update the formatting documentation to include info about it shortly, but it's straightforward to use. You have to use a "fenced code block", which usually means that you put 3 backticks above and below the code, and include the name of the language after the 3 backticks above it. So for example, markdown like this:
```python
def word_count(string: str) -> int:
"""Count the number of words in the string."""
return len(WORD_REGEX.findall(string))
```
will render as:
def word_count(string: str) -> int:
"""Count the number of words in the string."""
return len(WORD_REGEX.findall(string))
This is being done by the "Pygments" library, which supports a lot of languages: http://pygments.org/docs/lexers/
And completely unrelated to that, it's been a while since I gave everyone some invite codes, so I've topped everyone back up to 5 (and as always, feel free to let me know if you need more). You can access them on this page: https://tildes.net/invite
That's all for now, thanks everyone (and @Soptik in particular). There should also be more changes coming before too long, I've been working on some major updates to the comment-tagging system and hopefully should be able to implement those soon.
Congrats @Soptik on your first contribution!
Awesome addition. Thanks!
As an aside, can the font family not be enforced for code blocks?
This is the current CSS, which sets the font to not-so-pretty Courier on my machine:
How about setting just
font-family: monospace;
. Then I can see the code blocks in my browser-default monospace font (Iosevka rocks!).Awesome! That's a Firefox (which is my default browser too) add-on too. I haven't ever used this add-on; will have a look. Thanks!
Don't details and summary work?
Testing ..
This is summary. Click to expand.
Here are more details.Update: Nope, it doesn't, sorry for that useless comment notification.
Update 2: There's an issue tracking support for
details
/summary
. If anyone is interested, please vote it!Oh sure, I can probably change that. That font list is coming from Spectre.css, which is what I'm using as the "base" CSS: https://picturepan2.github.io/spectre/elements.html#typography-fonts
Yay!
Update: Well, it's a bit shabby for Nim, but not too bad.
@Soptik you just hit one of my biggest wishlist items. Nice work!
On a side note, now I need to retroactively add syntax highlighting to all of my old code snippets!
Oh, neat, it has support for formatting markdown! That could be useful for explaining formatting to people.
I wrote the above using:
All this is making me miss the
source
button on Reddit (or maybe RES adds it) that lets you see the original markdown source of a comment.source
is most definitely an RES feature. Having a native equivalent on Tildes would be nice too though IMO... which Deimos seemed to somewhat agree with, by the looks of it.That would be a nice thing to have for sure.
This doesn't sound difficult to implement - has no one made a pull request for it yet?
Is this a bug or is it meant to work like this? I had an invite code generated and then when you gave me five it actually ended up allowing me to have 6 total. I currently have 6 total codes. Is that a bug or is it intended to work like that? So theoretically someone could generate five invite codes and then if you give them five more they'll have 10 total. Is it meant to work like that?
It's not really intentional, but I'm also not really worried about it. I'll generally give people codes whenever they ask anyway, they're not difficult for people to get if they want to.
Okay. Just wanted to ask.
This is really cool!
I wonder though, if it might be worth revisiting the styles for the highlighted code blocks. At least on my display with either Solarized Light or Solarized Dark themes, the font/weight and contrast are just a little harder to read.
That’s awesome, and has the potential of making Tildes a prime destination for programming content. You guys (developers and contributors) never cease to surprise me positively. Thanks a bunch and keep up the good work!
Great addition. Very nicely done.
This is the day I've been waiting so long for!