Codewars' Markdown Extensions
Codewars adds a few Markdown extensions for writing kata descriptions.
Sequential Code Blocks#
Used to display code blocks only in the language selected by the user.
Details#
- Each code block must have an info string set to a valid language ID. To find the language ID, visit its documentation from the languages page.
- The order of the code blocks/languages doesn't matter.
- To avoid rendering errors/problems:
- Always put an empty line before and after the complete group of code blocks
- Never put empty lines between individual code blocks of the same sequential group.
Example#
If the active language of the user is TypeScript, the above Markdown is rendered to the following:
Conditional Rendering#
Conditional rendering blocks renders the content when the language selected by the user matches the condition specified in the info string.
Basic syntax#
If the selected language is java, this block is showing up in the description, rendered to:
For java, use
Preloaded.check(input).
Details#
- The language name in the info string has to match a valid language ID. To find the language ID, visit its documentation from the languages page.
- To obtain proper rendering, language-specific blocks need an empty line before and after them, just like code blocks.
- You can use Markdown inside conditional blocks, but be careful when inserting code blocks.
- You can use different kinds of conditions or assigned them to groups of languages using the following syntaxes:
if:languageif:language,language2if-not:languageif-not:language1,language2
Examples#
if:languages#
If the active language is Ruby, the above renders:
Shown if the active language is Ruby.
if-not:languages#
If the active language is Ruby, the above renders:
Hidden if the active language is JavaScript or TypeScript.
Using Code Blocks Inside Conditional Blocks#
To use code blocks within these conditional blocks, use tildes (~) to declare the conditional block or increase the number of backticks used.
Math Typesetting#
Math typesetting is supported with the following two syntaxes:
- Inline: code span starting and ending with
$ - Block: code block with info string
math
See the support table on KaTeX to find all of the supported syntaxes.
Commonly used Symbols/Functions#
| Symbol/Function | Represents |
|---|---|
x_n | indice |
x^n | exponant |
\lt | lower than |
\leq | lower or equal |
\lgt | greater than |
\geq | greater or equal |
\sum | sigma (sum) |
\prod | pi (big) |
\pi | pi (small) |
\to | arrow |
\lim | limit |
\infty | infinite |
{ ... } | to group instructions |
Example#
Renders:
