atom / markdown-preview

📝 Markdown preview in Atom
MIT License
1.23k stars 358 forks source link

Fenced code verbosity #128

Open allykzam opened 10 years ago

allykzam commented 10 years ago

As of recently, (specifically looks like the results of #113) the HTML output from saving a rendered preview contains excessive HTML entities and loads of span tags to help format fenced code. I briefly tried forking the repo and reverting those changes, but I'm relatively new to atom package development and I'm not sure how to deal with atom telling me it can't load fs-plus.

Is there any way that this new behavior could be made an option, such that I can return to having code snippets rendered somewhere along the lines of <pre><code> ... </code></pre>? Not that I'm completely against &nbsp;, but it seems rather excessive to replace every space with a non-breaking space, and I'd rather have the output that works with my site's syntax highlighter.

izuzak commented 9 years ago

@amazingant Are you still seeing this? I just tried previewing a simple snippet and didn't notice any &nbsp;s in there.

screen shot 2015-01-30 at 18 19 24

allykzam commented 9 years ago

Just updated Atom to 0.176.0 to check, and I must admit, it isn't giving me any extra &nbsp; now...or anything else from code fences? I'll poke around and see if something's wrong with my install just in case. Screenshot with input, preview, and the current output. The output (results of "Save As HTML...") is where I was originally seeing the &nbsp;s.

screen shot 2015-02-02 at 9 38 15 am

izuzak commented 9 years ago

@amazingant Sorry for not replying to this! I think the issue you reported is a duplicate of https://github.com/atom/markdown-preview/issues/195 which was fixed in a more recent version of Atom. I'm going to close this, but let me know if you can reproduce this in the latest version of Atom. Thanks again for these reports!

allykzam commented 9 years ago

@izuzak well, code fences were working when I originally submitted this, their conversion to HTML just didn't look right. Less of a duplicate of #195 and more of I happened to run into that problem while trying to reproduce for you. Now that I've read through the thread for #195 (I'm still seeing code fences omitted when running the Save As HTML... option with Atom 0.184.0 & markdown-preview 0.137.0), and tried the workaround, this screenshot might be more helpful.

screen shot 2015-03-02 at 9 38 10 am

The html file shown here is what came from the markdown-preview:copy-html command. My expectation is that something in a code fence should go in a <pre> tag (which it does), and be left as-is (which it doesn't), so the code snippet should be verbatim:

<pre class="editor-colors lang-text">
let x =
    let y = 5
    let z = 7
    y * z
</pre>

I'm not super concerned with what the conversion does with most text of course, but as code fences are supposed to be pre-formatted text, it's odd when you open the HTML and see a big mess. Originally ran into this because the syntax highlighter I'm using doesn't like highlighting code littered with &nbsp; where its grammar definitions expect regular spaces; have filed a bug report with them as well so they can maybe help that along too.

izuzak commented 9 years ago

Thanks for clarifying -- I definitely see the strange layout now when I use copy-as-html.

ChrisChinchilla commented 9 years ago

@izuzak

Hi, I was going to report a similar 'bug'. What's your progress with this? I would happy to have a try at fixing this if you could point me in the general direction of what code generates the code export.

izuzak commented 9 years ago

What's your progress with this?

I haven't looked at this issue beyond reproducing it.

I would happy to have a try at fixing this if you could point me in the general direction of what code generates the code export.

I wish I could do that -- but I don't know. Maybe someone else from the @atom/feedback can help?