8000 `<var>`s inside `<pre>`s get preprocessed away · Issue #84 · tc39/ecmarkup · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

<var>s inside <pre>s get preprocessed away #84

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

Open
domenic opened this issue Mar 18, 2016 · 3 comments
Open

<var>s inside <pre>s get preprocessed away #84

domenic opened this issue Mar 18, 2016 · 3 comments

Comments

@domenic
Copy link
Member
domenic commented Mar 18, 2016
<pre><code class="lang-javascript">global1.Zone.current; // succeeds
global2.Zone.current; // throws: <var>currentRealm</var> = <var>realm1</var>; <var>thisRealm</var> = <var>functionRealm</var> = <var>realm2</var>

const getter1 = Object.getOwnPropertyDescriptor(global1.Zone, "current").get;
const getter2 = Object.getOwnPropertyDescriptor(global2.Zone, "current").get;

getter1.call(global2.Zone); // throws: <var>currentRealm</var> = <var>functionRealm</var> = <var>realm1</var>; <var>thisRealm</var> = <var>realm2</var>
getter2.call(global1.Zone); // throws: <var>currentRealm</var> = <var>thisRealm</var> = <var>realm1</var>; <var>functionRealm</var> = <var>realm2</var>
</code></pre>

the output no longer contains the <var>. I think in general it's good to be able to call attention to certain things typographically inside examples even if you couldn't type them that way in a text editor, e.g. <var>, <mark>, <ins>, <del>, etc.

@bterlson
Copy link
Member

They are getting removed as I am currently passing innerText of the code block to hljs. I attempted simply changing this to innerHTML but hljs escapes any html elements in the incoming source text. I can't blindly unescape as some of the escapes are potentially added by hjls itself. Probably innerHTML is the right choice here anyway.

@domenic
Copy link
Member Author
domenic commented Apr 21, 2016

This came up in some other context recently and it seems like a hard problem in general. I'm not sure any syntax highlighters properly account for the kind of work necessary, which would involve something like processing the text node-by-node. If you run across one let me know.

@bterlson
Copy link
Member

Will do. In the meantime I am going to use innerHTML so at least the elements won't mysteriously disappear. Also seems handy for samples that include html tags as you don't need to escape them.

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
0