docco icon indicating copy to clipboard operation
docco copied to clipboard

Code blocks seem broken

Open possibilities opened this issue 12 years ago • 6 comments
trafficstars

Perhaps I'm doing something wrong, otherwise it's surprising that someone else hasn't noticed this. Given this input:

```javascript
SimpleGadget.prototype.onConfigChange = function(config) {
  if (config.myImage && config.myImage !== this.config.myImage) {
    this.config.myImage = config.myImage;
  }
}
```

I get this output:

<pre><code class="lang-javascript">SimpleGadget.prototype.onConfigChange = function(config) {
if (config.myImage &amp;&amp; config.myImage !== this.config.myImage) {
this.config.myImage = config.myImage;
}
}</code></pre>

Maybe the problem isn't obvious given the medium but basically the issue is indentation is lost from my code blocks.

Anyone noticing this? Or see what I'm doing wrong?

Thanks, Mike

possibilities avatar Apr 08 '13 21:04 possibilities

I confirm that this is an issue and also that running the same code through marked alone has the desired output, so it must be something docco is doing.

neocotic avatar Apr 11 '13 08:04 neocotic

Also, it appears that the code is treated as docs instead of code and is rendered as such. This makes the fix more complicated. I wouldn't consider this urgent as it only applies to markdown files but it should definitely be fixed as it promotes literate programming.

neocotic avatar Apr 11 '13 08:04 neocotic

I'm not really sure you need to be running docco against a plain markdown file as it will only output doc sections. You may be interested in using a file name like test.js.md and use normal code blocks (i.e. indented) to highlight you embedded code.

Am I correct in assuming this snippet is taken from a markdown file?

neocotic avatar Apr 11 '13 10:04 neocotic

Cool, yeah, I am just processing markdown with docco (along with proper use of docco) to gain the benefits of the layout functionality. Keeps everything uniform by using 1 tool, etc. I took your advice and renamed to .js.md and switched to normal code blocks... happiness achieved!

Thanks for your help on this @neocotic.

My sense is this is closable but for the moment I'm going to leave it hanging in case Jeremy has additional thoughts on this.

-Mike

possibilities avatar Apr 11 '13 19:04 possibilities

Issue is now a year old. I'm going to close it, if anyone experiences this issue and feels like reopening (especially if they reopen with a PR to fix it) then feel free.

keithamus avatar Apr 11 '14 23:04 keithamus

3yrs later and I've run into this same issue. Was there a solution other than "don't do it that way"?

I was hoping to use my main repo README.md as the documentation index, so I don't have to rewrite general setup instructions. I have coffee and javascript markdown code blocks, but they're losing all indentation.

timkinnane avatar Aug 08 '17 02:08 timkinnane