Have you ever wondered how to get the nice code formatting in comments and posts on dev.to?
Here's an example:
const myMethod = (a, b) => {
...
For further actions, you may consider blocking this person and/or reporting abuse
As I made my way down the post, I was wondering if we'd arrive here. Definitely a bit of a "yo dawg" Markdown situation. 😆
Yep! 😆
Is three a way I can make a text to wrap to new line. I find that my readers have to scroll when I show some code examples. For instance:
Is there a way I can prevent the scroll, here?
Now I knew about some of this bit knowing the library behind it is very helpful, thank you for deep diving so I don't have to. Unless it's al wrote down somewhere, in that case, thank you for reading that so I don't have to. 🐠 Why is there no diver emoji?
No problem - The ability to deep dive is a bonus of DEV being open source! There's a technical overview doc that mentions that they use rouge and redcarpet for markdown parsing: github.com/thepracticaldev/dev.to/...
>
and<
?You got it :) I believe there are a few other ways to do it as well though; I tried about 3 before I just used that one
Boss-level debugger 😎
My original thought was the trusty rusty backslash, but that can have all kinds of unexpected parsing behaviors compared to the HTML character codes.
Although, now I wonder what subset of HTML is parsed and what subset is scrubbed, and if there are backdoors in every dev.to post 😰
... ahhh, it's probably fine.
I actually went digging through the dev.to source after I posted this, and found that answer! Here you can see the allowed tags and allowed attributes:
github.com/thepracticaldev/dev.to/...
Neat!
Oh wow, didn't even know some of these, especially
diff
.Thanks for sharing 😇
About the
<pre>
and backticks, did you use HTML escape sequnces?You have just made my life so much easier, Chris. Thank you!!! <3
Glad to hear it!
How about a react code formatter. Like I wrapped my react js with and javascript but instead it only showed the html files in web format
How to highlight commands in linux command line?
For example, color the commands: "sudo", "echo", "cd", "ls", "apt-get". And if possible, color "git", "docker", "java", "python", etc.
Thanks for this, I've been wondering why mine is always white
Is there any way to make the background white instead of black?
This saved my life thank you
Thank you!! 😁
Thank you, Chris