# Code fences don't seem to deal with C comments

**URL:** <https://meta.discourse.org/t/code-fences-dont-seem-to-deal-with-c-comments/33339>\
**Category:** Support\
**Created:** [2015年九月16日 05:47 UTC](https://meta.discourse.org/t/code-fences-dont-seem-to-deal-with-c-comments/33339 "2015-09-16T05:47:35Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)\
**Post date:** [2015年九月16日 21:56 UTC](https://meta.discourse.org/t/code-fences-dont-seem-to-deal-with-c-comments/33339/21 "2015-09-16T21:56:04Z")

</div>

Done.

[https://github.com/isagalaev/highlight.js/issues/937](https://github.com/isagalaev/highlight.js/issues/937)

The example worked differently there, but still cpp versus nothing was different.

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2015年九月16日 22:01 UTC](https://meta.discourse.org/t/code-fences-dont-seem-to-deal-with-c-comments/33339/22 "2015-09-16T22:01:45Z")

</div>

Careful, github do not use highlight js, it needs to be tested on highlight js latest, will upgrade us next week just in case

---

<div class="post-metadata">

**Author:** ![isagalaev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/isagalaev/32/116712_2.png) [@isagalaev](https://meta.discourse.org/u/isagalaev)\
**Post date:** [2015年九月17日 04:41 UTC](https://meta.discourse.org/t/code-fences-dont-seem-to-deal-with-c-comments/33339/23 "2015-09-17T04:41:21Z")

</div>

Hey there! The author of highlight.js here 🙂

@codinghorror is spot on: indeed this code is recognized as something else because there’s enough of interesting stuff happening within the comment. This is one of the cases where heuristics fails and that’s why we have the ability to set the language explicitly — don’t refrain from using it!

Having said that, I think it will be possible to improve our heuristics across the board so highlighting of this comment will probably be fixed as a side effect.

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2015年九月17日 09:11 UTC](https://meta.discourse.org/t/code-fences-dont-seem-to-deal-with-c-comments/33339/24 "2015-09-17T09:11:51Z")

</div>

Super awesome, and thanks for highlight, let us know if you need us to test anything

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2015年九月20日 01:31 UTC](https://meta.discourse.org/t/code-fences-dont-seem-to-deal-with-c-comments/33339/25 "2015-09-20T01:31:23Z")

</div>

Super awesome

> **[Improve detection of C block comments · highlightjs/highlight.js@266e03e](https://github.com/highlightjs/highlight.js/commit/266e03e0e9d6a782c0c499235c3d3b4fe509ae81)**
>
> Illegalized \`/\*\` in a bunch of languages and added some new phrasal
> words to comments. This was prompted by a real example in
> https://meta.discourse.org/t/code-fences-dont-seem-to-deal-with-c-comme...

---

<div class="post-metadata">

**Author:** ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)\
**Post date:** [2015年十月5日 23:25 UTC](https://meta.discourse.org/t/code-fences-dont-seem-to-deal-with-c-comments/33339/26 "2015-10-05T23:25:51Z")

</div>

I suppose everyone here realizes that the issue is still showing meta.

But I now have another question about code fence implementation with Discourse.

My understanding is that the opening and closing fences need to be _at least 3 `_ long and opening and closing fences must be the same length. In this way, you can fence in anything you want, containing an arbitrary number of `s on a line. A contrived example, this input should properly quote the code fence in the here-documents:

* * *

## ````bash perl reportprogram \> $tmpfile (cat \<\<“ReportHeader”; cat $tmpfile; cat \<\<“ReportFooter”) | perl post-to-discourse This is a report I generated. ``` ReportHeader ``` Feel free to ask questions. ReportFooter ````

Actual results:

````bash
perl reportprogram > $tmpfile
(cat <<"ReportHeader"; cat $tmpfile; cat <<"ReportFooter") | perl post-to-discourse
This is a report I generated.
```
ReportHeader
```
Feel free to ask questions.
ReportFooter

````

---

<div class="post-metadata">

**Author:** ![johnmuhl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johnmuhl/32/43413_2.png) [@johnmuhl](https://meta.discourse.org/u/johnmuhl)\
**Post date:** [2015年十月6日 01:08 UTC](https://meta.discourse.org/t/code-fences-dont-seem-to-deal-with-c-comments/33339/27 "2015-10-06T01:08:30Z")

</div>

The markdown implementation in Discourse does not (yet) follow the Commonmark standard. So anything outside of the original markdown “spec” should be considered unimplemented for now; and any non-standard markdown that works as pure coincidence.

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2015年十月6日 10:06 UTC](https://meta.discourse.org/t/code-fences-dont-seem-to-deal-with-c-comments/33339/28 "2015-10-06T10:06:18Z")

</div>



[上一頁](https://meta.discourse.org/t/code-fences-dont-seem-to-deal-with-c-comments/33339.md?page=1)
