http://stackoverflow.com/questions/451486/pre-tag-loses-line-breaks-when-setting-innerhtml-in-ie
http://stackoverflow.com/questions/195363/inserting-a-newline-into-a-pre-tag-ie-javascript
517048
function setHtmlIe8SafeWay(element, html) {
  var newElement = angular.element('<pre>' + html + '</pre>');

  element.empty();
  element.append(newElement.contents());
  return element;
}
163965
function _getText(el) {
    var theText;
    // Make sure to check for type of string because if the body of the page
    // doesn't have any text it'll be "" which is falsey and will go into
    // the else which is meant for Firefox and shit will break
    if (typeof document.body.innerText == 'string') {
      theText = el.innerText;
    }
    else {
      // First replace <br>s before replacing the rest of the HTML
      theText = el.innerHTML.replace(/<br>/gi, "\n");
      // Now we can clean the HTML
      theText = theText.replace(/<(?:.|\n)*?>/gm, '');
      // Now fix HTML entities
      theText = theText.replace(/&lt;/gi, '<');
      theText = theText.replace(/&gt;/gi, '>');
    }
    return theText;
  }
485556
function handleTag_dd() {
    if ($this->parser->isStartTag) {
      if (substr(ltrim($this->parser->html), 0, 3) == '<p>') {
        # next comes a paragraph, so we'll need an extra line
        $this->out("\n".$this->indent);
      } elseif (substr($this->output, -2) == "\n\n") {
        $this->output = substr($this->output, 0, -1);
      }
      $this->out(':   ');
      $this->indent('    ', false);
    } else {
      # lookahead for next dt
      if (substr(ltrim($this->parser->html), 0, 4) == '<dt>') {
        $this->setLineBreaks(2);
      } else {
        $this->setLineBreaks(1);
      }
      $this->indent('    ');
    }
  }
158549
def inject!
      @html.each_line do |line|
        if line =~ /^\s*<h([1-6])>(.*?)<\/h[1-6]>$/
          level = $1.to_i
          original_text = $2
          text = Util::HTML.strip_tags(original_text)
          id = title_to_id(text)

          if include_to_toc?(level)
            @toc.add(level, id, text)
          end

          @new_html << "<h#{level} id='#{id}'>#{original_text}</h#{level}>\n"
        else
          @new_html << line
        end
      end

      inject_toc!

      @new_html.flatten.join
    end
70486
def insert_line_above(self, copy_margin=True):
        
        if copy_margin:
            insert = self.document.leading_whitespace_in_current_line + '\n'
        else:
            insert = '\n'

        self.cursor_position += self.document.get_start_of_line_position()
        self.insert_text(insert)
        self.cursor_position -= 1
567083
function (e) {

/*Line 27 - 'AtomPostButton.js' */                var inv = this._invalid;
/*Line 28 - 'AtomPostButton.js' */                if (inv) {
/*Line 29 - 'AtomPostButton.js' */                    if ($.isArray(inv)) {
/*Line 30 - 'AtomPostButton.js' */                        inv = inv.join();
/*Line 31 - 'AtomPostButton.js' */                    }
/*Line 32 - 'AtomPostButton.js' */                    if (inv) {
/*Line 33 - 'AtomPostButton.js' */                        alert(inv);
/*Line 34 - 'AtomPostButton.js' */                        return;
/*Line 35 - 'AtomPostButton.js' */                    }
/*Line 36 - 'AtomPostButton.js' */                }


/*Line 39 - 'AtomPostButton.js' */                if (this._confirm) {
/*Line 40 - 'AtomPostButton.js' */                    var _this = this;
/*Line 41 - 'AtomPostButton.js' */                    Atom.confirm(this._confirmMessage, function () {
/*Line 42 - 'AtomPostButton.js' */                        _this.onConfirmed(e);
/*Line 43 - 'AtomPostButton.js' */                    });
/*Line 44 - 'AtomPostButton.js' */                    return;
/*Line 45 - 'AtomPostButton.js' */                }
/*Line 46 - 'AtomPostButton.js' */                this.onConfirmed(e);
/*Line 47 - 'AtomPostButton.js' */            }
508571
function reportRequiredLineBreak(token) {
            const tokenBefore = sourceCode.getTokenBefore(token, { includeComments: true });

            context.report({
                loc: {
                    start: tokenBefore.loc.end,
                    end: token.loc.start
                },
                messageId: "missingLineBreak",
                fix(fixer) {
                    return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n");
                }
            });
        }
638781
function (node) {
            if (node.startToken.prev && node.startToken.prev.type !== 'LineBreak') {
                insertBefore(node.startToken, nextLineFactory());
            }
        }
1164785
def insert_line_below(self, copy_margin=True):
        
        if copy_margin:
            insert = '\n' + self.document.leading_whitespace_in_current_line
        else:
            insert = '\n'

        self.cursor_position += self.document.get_end_of_line_position()
        self.insert_text(insert)
961609
function innertext (html) {
  // Drop everything inside <...> (i.e., tags/elements), and keep the text.
  // Unlike browser innerText, this removes newlines; it also doesn't handle
  // un-encoded `<` or `>` characters very well, so don't feed it malformed HTML
  return entities.decode(html.split(/<[^>]+>/)
    .map(function (chunk) { return chunk.trim() })
    .filter(function (trimmedChunk) { return trimmedChunk.length > 0 })
    .join(' ')
  );
}
102794
function handleTag_pre() {
    if ($this->keepHTML && $this->parser->isStartTag) {
      # check if a simple <code> follows
      if (!preg_match('#^\s*<code\s*>#Us', $this->parser->html)) {
        # this is no standard markdown code block
        $this->handleTagToText();
        return;
      }
    }
    $this->indent('    ');
    if (!$this->parser->isStartTag) {
      $this->setLineBreaks(2);
    } else {
      $this->parser->html = ltrim($this->parser->html);
    }
  }
1320508
function wrap(xhtml, tag) {
  var e = document.createElement('div');
  e.innerHTML = xhtml;
  return e;
}
621725
function( tagName ) {
			var rules = this._.rules[ tagName ];

			if ( rules && rules.indent )
				this._.indentation = this._.indentation.substr( this.indentationChars.length );

			if ( this._.indent )
				this.indentation();
			// Do not break if indenting.
			else if ( rules && rules.breakBeforeClose ) {
				this.lineBreak();
				this.indentation();
			}

			this._.output.push( '</', tagName, '>' );
			tagName == 'pre' && ( this._.inPre = 0 );

			if ( rules && rules.breakAfterClose ) {
				this.lineBreak();
				this._.needsSpace = rules.needsSpace;
			}

			this._.afterCloser = 1;
		}
1237486
function insertFormattedLineBreak(cursor) {
	const indent = cursor.editor.getTabText();
	const lineIndent = getLineIndent(cursor);

	cursor.selection.insertText(`\n${lineIndent}${indent}\n${lineIndent}`, { autoIndent: false });

	// Put caret at the end of indented newline
	cursor.moveUp();
	cursor.moveToEndOfLine();
}
1311586
function isCollapsedLineBreak(br) {
        if (!isHtmlElement(br, "br")) {
            return false;
        }

        // Add a zwsp after it and see if that changes the height of the nearest
        // non-inline parent.  Note: this is not actually reliable, because the
        // parent might have a fixed height or something.
        var ref = br.parentNode;
        while (getComputedStyleProperty(ref, "display") == "inline") {
            ref = ref.parentNode;
        }
        var refStyle = ref.hasAttribute("style") ? ref.getAttribute("style") : null;
        ref.style.height = "auto";
        ref.style.maxHeight = "none";
        ref.style.minHeight = "0";
        var space = document.createTextNode("\u200b");
        var origHeight = ref.offsetHeight;
        if (origHeight == 0) {
            throw "isCollapsedLineBreak: original height is zero, bug?";
        }
        br.parentNode.insertBefore(space, br.nextSibling);
        var finalHeight = ref.offsetHeight;
        space.parentNode.removeChild(space);
        if (refStyle === null) {
            // Without the setAttribute() line, removeAttribute() doesn't work in
            // Chrome 14 dev.  I have no idea why.
            ref.setAttribute("style", "");
            ref.removeAttribute("style");
        } else {
            ref.setAttribute("style", refStyle);
        }

        // Allow some leeway in case the zwsp didn't create a whole new line, but
        // only made an existing line slightly higher.  Firefox 6.0a2 shows this
        // behavior when the first line is bold.
        return origHeight < finalHeight - 5;
    }
804692
private static void addLineNo(Content pre, int lineno) {
        HtmlTree span = new HtmlTree(HtmlTag.SPAN);
        span.addStyle(HtmlStyle.sourceLineNo);
        if (lineno < 10) {
            span.addContent("00" + Integer.toString(lineno));
        } else if (lineno < 100) {
            span.addContent("0" + Integer.toString(lineno));
        } else {
            span.addContent(Integer.toString(lineno));
        }
        pre.addContent(span);
    }
475707
function emitTextUpTo(sourceIdx) {
      if (sourceIdx > outputIdx) {
        if (openDecoration && openDecoration !== currentDecoration) {
          // Close the current decoration
          html.push('</span>');
          openDecoration = null;
        }
        if (!openDecoration && currentDecoration) {
          openDecoration = currentDecoration;
          html.push('<span class="', openDecoration, '">');
        }
        // This interacts badly with some wikis which introduces paragraph tags
        // into pre blocks for some strange reason.
        // It's necessary for IE though which seems to lose the preformattedness
        // of <pre> tags when their innerHTML is assigned.
        // http://stud3.tuwien.ac.at/~e0226430/innerHtmlQuirk.html
        // and it serves to undo the conversion of <br>s to newlines done in
        // chunkify.
        var htmlChunk = textToHtml(
            tabExpander(sourceText.substring(outputIdx, sourceIdx)))
            .replace(lastWasSpace
                     ? startOrSpaceRe
                     : adjacentSpaceRe, '$1&#160;');
        // Keep track of whether we need to escape space at the beginning of the
        // next chunk.
        lastWasSpace = trailingSpaceRe.test(htmlChunk);
        html.push(htmlChunk.replace(newlineRe, lineBreaker));
        outputIdx = sourceIdx;
      }
    }