fsprojects / FsReveal

FsReveal parses markdown and F# script file and generates reveal.js slides.
http://fsprojects.github.io/FsReveal
258 stars 100 forks source link

Latest F# Formatting generates strange line numbers #69

Closed forki closed 9 years ago

forki commented 9 years ago

With the FsReveal 0.7.6(unlisted on NuGet) I get

image

<h4>C#</h4> 

<table class="pre"><tr><td class="lines"><pre class="fssnip">
<span class="l">1: </span>
<span class="l">2: </span>
<span class="l">3: </span>
<span class="l">4: </span>
<span class="l">5: </span>
<span class="l">6: </span>
<span class="l">7: </span>
<span class="l">8: </span>
<span class="l">9: </span>
</pre>
</td>
<td class="snippet"><pre lang="cs"><span class="k">using</span> System;

<span class="k">class</span> Program
{
    <span class="k">static</span> <span class="k">void</span> Main()
    {
        Console.WriteLine(<span class="s">"Hello, world!"</span>);
    }
}
</pre></td></tr></table>

/cc @tpetricek

forki commented 9 years ago

as compared to F# syntax highlighting (which looks good (but is big)):

image

<h4>F# (with tooltips)</h4>

<table class="pre"><tr><td class="lines"><pre class="fssnip">
<span class="l">1: </span>
<span class="l">2: </span>
<span class="l">3: </span>
</pre>
</td>
<td class="snippet"><pre class="fssnip">
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs1', 1)" onmouseover="showTip(event, 'fs1', 1)" class="i">a</span> <span class="o">=</span> <span class="n">5</span>
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs2', 2)" onmouseover="showTip(event, 'fs2', 2)" class="f">factorial</span> <span onmouseout="hideTip(event, 'fs3', 3)" onmouseover="showTip(event, 'fs3', 3)" class="i">x</span> <span class="o">=</span> [<span class="n">1..</span><span onmouseout="hideTip(event, 'fs3', 4)" onmouseover="showTip(event, 'fs3', 4)" class="i">x</span>] <span class="o">|&gt;</span> <span onmouseout="hideTip(event, 'fs4', 5)" onmouseover="showTip(event, 'fs4', 5)" class="t">List</span><span class="o">.</span><span onmouseout="hideTip(event, 'fs5', 6)" onmouseover="showTip(event, 'fs5', 6)" class="f">reduce</span> <span class="o">(*)</span>
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs6', 7)" onmouseover="showTip(event, 'fs6', 7)" class="i">c</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs2', 8)" onmouseover="showTip(event, 'fs2', 8)" class="f">factorial</span> <span onmouseout="hideTip(event, 'fs1', 9)" onmouseover="showTip(event, 'fs1', 9)" class="i">a</span>
</pre>
</td>
</tr>
</table>
forki commented 9 years ago
<td class="snippet"><pre lang="cs">

vs.

<td class="snippet"><pre class="fssnip">

this?

tpetricek commented 9 years ago

Oh, I see - the line numbers are correct, but the font size for the code is smaller because of the missing fssnip class!

Thanks for pointing this out. I'll try to fix this today/tomorrow (but I have limited internet bandwidth this weekend, so I only have limited number of NuGet push attempts before I run out of limit :-)).

tpetricek commented 9 years ago

OK - I guess this could be fixed by handling this in CSS in FsReveal, but it sounds like the snippets generated for F# and other languages from F# Formatting should look the same - so the new version of F# Formatting adds fssnip class to non-F# snippets too (a bit silly name, in retrospect, but I think it is probably a good option - somehow marking all F# Formatting generated <pre> tag is a good thing to do).

This is now released in 2.9.6. But it changes the look of the FsReveal slides, because it makes the font size of non-F# snippets larger (they now have the same size as F# snippets) and some look a bit ugly, because they do not quite fit...

forki commented 9 years ago

thanks. it's fixed