gitter-cli icon indicating copy to clipboard operation
gitter-cli copied to clipboard

Code Block Formmatting(Markdown default) does not include newline char

Open juliosueiras opened this issue 8 years ago • 4 comments

Before

2015-07-10-124838_1366x768_scrot

After

2015-07-10-125033_1366x768_scrot

The issue is located in marked.js which it does not insert newline character and cause the entire block to be oneline, is fixable by removing Renderer.prototype.code

though the padding is still incorrect, which result to be left of the screen

juliosueiras avatar Jul 10 '15 16:07 juliosueiras

Padding issues is mostly because of maxWidth of message

juliosueiras avatar Jul 10 '15 17:07 juliosueiras

One thought about the last comment, maybe we should replace the \n in the comments for \n + Array(authorLength + 1).join(' ') in the message code.

RodrigoEspinosa avatar Jul 14 '15 02:07 RodrigoEspinosa

Okie, I am able to narrow down the problem

  messageText = messageText.split('\n').map(function (line, index) {
      // If is the first line, then leave it as it is.
      console.log('line:' + line + ' index:' + index);

      if (index < 1) {
          return line;
      }

      // Append a number `authorLength` number of spaces before the line.
      return Array(authorLength + 1).join(' ') + line;
  }).join('\n');

this code is not correctly splitting newline

juliosueiras avatar Jul 14 '15 22:07 juliosueiras

UPDATE

The culprit is actually

  messageText = this.parseText(messageText, messageMaxWidth);

which it strip newline character (still checking if is marked is doing that or htmlToText)

juliosueiras avatar Jul 15 '15 04:07 juliosueiras