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

Code blocks leave ugly trailing blank lines #644

Closed
MaxWilson opened this issue Feb 15, 2021 · 4 comments
Closed

Code blocks leave ugly trailing blank lines #644

MaxWilson opened this issue Feb 15, 2021 · 4 comments

Comments

@MaxWilson
Copy link

MaxWilson commented Feb 15, 2021

I was adding documentation to fsharp-core-docs and at dsyme's suggestion I formatted the code blocks like so:

    /// <example>
    /// <code>
    ///     None |> Option.toList // evaluates to []
    ///     Some 42 |> Option.toList // evaluates to [42]
    /// </code>
    /// </example>

Unfortunately it seems that that leaves ugly whitespace at the end of the code block (and I'm not wild about the indented left margin either). Partial screenshot:

image

Ideally fsdocs would trim the trailing whitespace within the code block, and also normalize left-indentation so that the outermost indented block isn't indented.

Known workaround

I can format my code-in-comments without whitespace within the code block:

    /// <example>
    /// <code>None |> Option.toList // evaluates to []
    ///Some 42 |> Option.toList // evaluates to [42]</code>
    /// </example>

That is tremendously ugly though, especially lack of spacing on the third line before "Some 42". The output looks nicer though (partial screenshot):

image

@dsyme
Copy link
Contributor

dsyme commented Mar 24, 2021

Fixed in 9.0.4 by #653

@dsyme dsyme closed this as completed Mar 24, 2021
@Evelios
Copy link

Evelios commented Nov 16, 2022

@Dysme I'm still having this issue.

It doesn't matter what the parent tag is for my code block, the extra whitespace is still included. In the code I linked I have the code block inside an <example> tag and a <note> tag an both have the unintended whitespace added.

image

/// <summary>
/// An <c>Acceleration</c> represents an acceleration in meters per second squared,
/// feet per second squared or
/// <a href="https://en.wikipedia.org/wiki/G-force#Unit_and_measurement">gees</a>.
/// It is stored as a number of meters per second squared.
/// </summary>
/// 
/// <example>
/// You can also do rate-related calculations with <c>Acceleration</c> values to compute
/// <c>Speed</c> or <c>Duration</c>:
/// <code lang="fsharp">
///     let changeInSpeed =
///         acceleration |> Quantity.for duration
///     let alsoChangeInSpeed =
///         duration |> Quantity.at acceleration
///     let duration =
///         changeInSpeed |> Quantity.at_ acceleration
/// </code>
/// </example>
///
/// <note>
/// Since <c>MetersPerSecondSquared</c> is defined as <c>Rate MetersPerSecond Seconds</c>
/// (change in speed per unit time), you can construct an <c>Acceleration</c>
/// value using <c>Quantity.per</c>:
/// <code lang="fsharp">
///     let acceleration =
///         changeInSpeed |> Quantity.per duration
/// </code>
/// </note>
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module Math.Units.Acceleration

@nhirschey
Copy link
Collaborator

Thanks for pointing out @MaxWilson, this poor formatting is caused by PR #762 from @yazeedobaid.

Deleting the HTML added by that PR fixes the formatting. Thoughts @yazeedobaid?

html-element

@yazeedobaid
Copy link
Contributor

@nhirschey I looked at PR #762 and the trim for the new line still exists. Please see this line. Maybe it is caused by a css rule that got applied after the addition of the code element inside the pre element?

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

5 participants