dotnet / docfx

Static site generator for .NET API documentation.
https://dotnet.github.io/docfx/
MIT License
4.08k stars 865 forks source link

2.59.0 does not recognize a link reference definition that includes a link title and ends with CRLF #7850

Closed KalleOlaviNiemitalo closed 1 year ago

KalleOlaviNiemitalo commented 2 years ago

Operating System: Windows

DocFX Version Used: 2.59.0

Template used: default

Steps to Reproduce:

  1. Create a default docset with docfx init.
  2. Append the following to index.md using CRLF as line terminator:

    See [OpenAPI 2.0 Data Types] and [RFC 7807].
    
  3. docfx build
  4. Examine _site/index.html.

Expected Behavior:

This is what DocFX 2.58.9 outputs, and what DocFX 2.59.0 should likewise output.

<p>See <a href="https://swagger.io/specification/v2/#data-types" title="Data Types | OpenAPI Specification - Version 2.0 | Swagger">OpenAPI 2.0 Data Types</a> and <a href="http://www.rfc-editor.org/info/rfc7807" title="Nottingham, M. and E. Wilde, &quot;Problem Details for HTTP APIs&quot;, RFC 7807, DOI 10.17487/RFC7807, March 2016.">RFC 7807</a>.</p>

Actual Behavior:

This is what DocFX 2.59.0 incorrectly outputs instead.

<p>See [OpenAPI 2.0 Data Types] and [RFC 7807].</p>
<p>[OpenAPI 2.0 Data Types]: <a href="https://swagger.io/specification/v2/#data-types">https://swagger.io/specification/v2/#data-types</a> &quot;Data Types | OpenAPI Specification - Version 2.0 | Swagger&quot;
[RFC 7807]: <a href="http://www.rfc-editor.org/info/rfc7807">http://www.rfc-editor.org/info/rfc7807</a> &quot;Nottingham, M. and E. Wilde, &quot;Problem Details for HTTP APIs&quot;, RFC 7807, DOI 10.17487/RFC7807, March 2016.&quot;</p>

Notes:

Doesn't matter whether I use [RFC 7807], [RFC 7807][], or [RFC 7807][RFC 7807]. Adding <> around the URL doesn't help, either. Removing the link title from the link reference definition makes it work.

KalleOlaviNiemitalo commented 2 years ago

https://spec.commonmark.org/dingus/ agrees with DocFX 2.58.9.

KalleOlaviNiemitalo commented 2 years ago

It works if I use only LF as line terminator. It does not work with CRLF. This suggests the bug is related to https://github.com/xoofx/markdig/pull/560 or https://github.com/xoofx/markdig/commit/4c92fe5a3bb1a6d22ed5a3a236bf82f7b4e2eae5.

KalleOlaviNiemitalo commented 2 years ago

This is blocking my upgrade from 2.58.9.

yufeih commented 2 years ago

Most likely this is a regression from markdig line ending normalization feature. There were a couple of fixes but apparently more fixes and test cases are needed.

KalleOlaviNiemitalo commented 2 years ago

What's the next step: a standalone repro for Markdig and a bug report there?

I assume it is not feasible to patch Markdig locally for DocFX because it would restore the https://github.com/dotnet/docfx/issues/7701 version conflicts.

yufeih commented 2 years ago

A bug report of the case that blocks you in the markdig repo would definitely help. Meanwhile I can check more regressions detected in this PR and potentially send fixes to markdig.

KalleOlaviNiemitalo commented 2 years ago

This is still reproducible in 2.59.3

KalleOlaviNiemitalo commented 1 year ago

Using *.md eol=lf in .gitattributes as a workaround.