Search online for your language of choice, and you're sure to find a tool for formatting your code. A great one to use for C# is C# Formatter Online.
How to use code blocks code#
One of our favorite code beautifiers for Java is the Online Java Formatter. Want to make your code even prettier? There are plenty of online tools to help you do that. Well done! You’ve now created a well-formatted, easy-to-read code block! Now you can delete the old text and leave the code block! To edit the code, just click on the block, and it will pop back up. Hit the green “Save” box at the bottom, and you’ll end up with this: We have more languages than we care to count in our code block selector - you can just click in the field and start typing until you find what you want. In the field above the code, select the language (Shell, in this case). Pick “Code Block,” and a pop-up will appear. Select the space above or below it, then go back up to that “” button. Now you want to make the code easier to read.
days 365 –newkey rsa:2048 –keyout privateKey.key –out If you want to use them to create a self-signed certificate, you’d run something like:ĭocker run –v $PWD:/work –it nginx openssl req –x509 –sha256 –nodes “You’ll now see that the working directory on the host contains the files privateKey.key and CSR.csr.
To format code longer than a single line, we recommend creating a code block rather than a snippet, as this allows for easy formatting and syntax recognition. Hit “Code Snippet,” and your code format will change to this:Ĭongrats! You just formatted your code snippet! To format this single line of code, click on the “” icon in the menu bar of the article editor.Ī dropdown menu will appear. Shoot! You’d like your command to be formatted differently than the rest of your text so it stands out. Perhaps you want to insert a docker command into your article.
How to use code blocks how to#
Let’s go over how to add a code snippet and a code block to your post.
Sometimes just talking about your code isn’t going to cut it you need to show, rather than tell.īecause DZone’s readers prefer highly technical and detailed content, even down to the level of code itself, we’ve made it easy to include code in your articles.