microsoft / microsoft/WPF-Samples

Sometimes problem with 'orphaned' spaces

Open
#45 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
5.7k
Forks
3.3k
Avg merge
12d 8h
Merged PRs (30d)
2

Description

Sometimes the HtmlFromXamlConverter misses whitespace because it is not in a <Run> or similar tag. I hacked a fix by inserting the following code at line 46 of HtmlFromXamlConverter.cs:

            string regex = @"\>[ ]{1,}\<(?!\/)";
            Match m = Regex.Match(xamlString, regex);
            while (m != null && m.Success)
            {
                xamlString =
                      xamlString.Substring(0, m.Index + 1)
                    + "<Run xml:space='preserve'>" + new String(' ', m.Length - 2) + "</Run>"
                    + xamlString.Substring(m.Index + m.Length - 1, xamlString.Length - (m.Index + m.Length - 1));
                m = Regex.Match(xamlString, regex);
            }

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open HtmlFromXamlConverter.cs at line 46 and reproduce conversion of XAML containing whitespace outside a Run or similar tag. Review the reported regex and replacement behavior, then verify that the converted HTML preserves those spaces without changing other XAML content.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.