`md2xml` fails on ` ` entities returned by the GitLab Markdown API (non-breaking spaces in source)

Offen Anfängerfreundlich
#39 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
68/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Bereich
documentation

Rechercherichtung

Start in docmaker.GitLab/md2xml, where the issue’s stack trace shows parser.parseString receives the GitLab Markdown API HTML and fails on  . Read the conversion path around that call and check how the XML parser handles HTML entities. Done means converting Markdown containing U+00A0 succeeds without requiring source files to replace it with regular spaces.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

If the Markdown contains a non-breaking space (U+00A0), the GitLab Markdown API returns it as  . md2xml then parses that HTML with matlab.io.xml.dom.Parser, which only recognizes XML's built-in entities, so parsing fails.

Reproduction Steps:
>> f = websave(fullfile(tempdir, "MATLAB_DocMaker.mltbx"), ...
               "https://github.com/mathworks/docmaker/releases/download/v0.8.0/MATLAB_DocMaker.mltbx");
>> matlab.addons.install(f);

>> setenv("DOCMAKER_CONVERTER", "GitLab") % with GitLab token configured
>> setenv("DOCMAKER_GITLAB_HOSTNAME", "gitlab.mathworks.com")

>> docmaker.converter().md2xml("a" + char(160) + "b")
Error using matlab.io.xml.dom.Parser/parseString
Unable to parse string: "<div><p data-sourcepos="1:1-1:4" dir="auto">a&nbsp;b</p></div>". Reason: entity 'nbsp' not found.

Error in docmaker.GitLab/md2xml (line 92)
            doc = parser.parseString( "<div>" + xml + "</div>" );
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Current Workaround:

Replace U+00A0 with regular spaces in the .md sources before converting.

Vorherrschende Sprache
MATLAB
Sterne
10
Forks
3
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus mathworks/docmaker

Alle Issues in mathworks/docmaker

Ähnliche Issues

Weitere Issues zu MATLAB

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.