Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<pre> in backticks should be rendered as (escaped) html, not literal #380

Closed
Krinkle opened this issue May 31, 2013 · 1 comment
Closed

Comments

@Krinkle
Copy link
Contributor

Krinkle commented May 31, 2013

Given the following (based on VisualEditor:/modules/ve/ve/.js@4c5c18c241):

/**
 * @class test
 * @singleton
 */

/**
 * Get the actual inner HTML of a DOM node.
 *
 * In most browsers, .innerHTML is broken and eats newlines in `<pre>` elements, see
 * https://bugzilla.mozilla.org/show_bug.cgi?id=838954 . This function detects this behavior
 * and works around it, to the extent possible. `<pre>\nFoo</pre>` will become `<pre>Foo</pre>`
 * if the browser is broken, but newlines are preserved in all other cases.
 *
 * @method properInnerHtml
 * @param {HTMLElement} element HTML element to get inner HTML of
 * @returns {string} Inner HTML
 */

/**
 * Get the actual outer HTML of a DOM node.
 *
 * @see #properInnerHtml
 *
 * @method properOuterHtml
 * @param {HTMLElement} element HTML element to get outer HTML of
 * @returns {string} Outer HTML
 */

/**
 * Helper function for #properInnerHtml and #properOuterHtml.
 *
 * Detect whether the browser has broken `<pre>` serialization, and if so return a clone
 * of the node with extra newlines added to make it serialize properly. If the browser is not
 * broken, just return the original node.
 *
 * @method fixupPreBug
 * @param {HTMLElement} element HTML element to fix up
 */

I get:

Warning: Unclosed HTML tag: <pre>
Warning: Unclosed HTML tag: <pre>

Rendering like:

screen shot 2013-05-31 at 1 52 29 am

nene added a commit that referenced this issue May 31, 2013
The backwards-compatibility fix for code like:

    Here's the code example:<pre><code>
    alert("Blah");
    </code></pre>

was a bit too lose.  So tightened it up to only apply in case
where the <pre> or <pre><code> is at the end of line.

Fixes: #380
@nene
Copy link
Member

nene commented May 31, 2013

Thanks. Fixed.

@nene nene closed this as completed May 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants