# Code fences work now.

```lang-js
function DeepThought(task) {
    this.task = task;
}
DeepThought.prototype.answer = function () {
    switch (this.task) {
        case "life, universe, and everything": return 42;
        default: throw "not implemented";
    }
}
```

([view source on this answer](https://meta.stackexchange.com/revisions/d29ee470-c239-4d38-8ab1-5583517d1f9c/view-source))

As much as that's possible for a partial feature, they are compliant with [CommonMark 0.28](https://spec.commonmark.org/0.28/#fenced-code-blocks). That means:

- An code fence consists of three or more backticks `` ``` `` or tildes `~~~`, indented by zero to three spaces.
- The closing code fence needs to use the same character, and at least the same number as the opening code fence.
- The code block will be de-dented by as many spaces as the opening code fence was indented with. So this:
    ```none
    See this:
      ~~~
      foo
        bar
      ~~~
    ```
    turns into this:
    > See this:
    >   ~~~
    >   foo
    >     bar
    >   ~~~

- An unclosed fenced codeblock continues to the end of the block (e.g. block quote) or post.

That last point is also the reason for the only real edge case breakage that this causes with existing content. If somebody created a horizontal line in a post with something like `~~~~~~~~~~~~~~`, that is now going to open a code block. As always when we make markdown changes, the question & answer view is not going to be impacted by this unless the post is edited, and it's extremely rare, so I'm not too worried about this.