PlaceMarkersUsfmUpdateBlockHandler gets confused with table cells

未关闭
#614 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
62/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
csharp
领域
data

调研方向

Start with the UpdateUsfm_TableCells test and the PlaceMarkersUsfmUpdateBlockHandler it uses, and run the test to see the output. The bug is that table-cell markers such as \tc1 get moved to the end of the row and \tr rows lose their cell markers. Done means the test's target USFM matches the input USFM exactly, with the existing PlaceMarkers tests still passing.

由索引模型根据 Issue 内容生成。

描述

The SF test team has noticed an issue where tables of a reasonably long length were getting garbled and out of order, both in normal builds and to a lesser degree (but still occurring) in echo builds. This particularly occurred with the SNHB DBL resource, which has a table in Numbers 1. The NLT does this too, but places verse markers in the table cells, which may alter the behavior of this bug.

The following test recreates the bug:

[Test]
public void UpdateUsfm_TableCells()
{
    string source = "One Two Three Four Five Six Seven Eight Nine Ten Eleven Twelve Thirteen Fourteen Fifteen " +
                    "Sixteen Seventeen Eighteen Nineteen";
    var alignInfo = new PlaceMarkersAlignmentInfo(
        sourceTokens: [.. Tokenizer.Tokenize(source)],
        translationTokens: [.. Tokenizer.Tokenize(source)],
        alignment: ToWordAlignmentMatrix(
            "0-0 1-1 2-2 3-3 4-4 5-5 6-6 7-7 8-8 9-9 10-10 11-11 12-12 13-13 14-14 15-15 16-16 17-17 18-18"
        ),
        paragraphBehavior: UpdateUsfmMarkerBehavior.Preserve,
        styleBehavior: UpdateUsfmMarkerBehavior.Strip
    );
    IReadOnlyList<UpdateUsfmRow> rows =
    [
        new UpdateUsfmRow(
            ScrRef("MAT 1:1"),
            source,
            new Dictionary<string, object> { { "alignment_info", alignInfo } }
        ),
    ];
    string usfm =
        @"\id MAT
\c 1
\v 1 One
\tr \th1 Two \th2 Three
\tr \tc1 Four \tc2 Five
\tr \tc1 Six \tc2 Seven
\tr \tc1 Eight \tc2 Nine
\tr \tc1 Ten \tc2 Eleven
\tr \th1 Twelve \th2 Thirteen
\tr \tc1 Fourteen \tc2 Fifteen
\tr \tc1 Sixteen \tc2 Seventeen
\tr \tc1 Eighteen \tc2 Nineteen
";

    string target = UpdateUsfm(
        rows,
        usfm,
        paragraphBehavior: UpdateUsfmMarkerBehavior.Preserve,
        usfmUpdateBlockHandlers: [new PlaceMarkersUsfmUpdateBlockHandler()]
    );

    AssertUsfmEquals(target, usfm);
}

The target USFM created by this test is:

\id MAT
\c 1
\v 1 One
\tr \th1 Two \th2 Three
\tr \tc1 Four \tc2 Five
\tr \tc1 Six \tc2 Seven
\tr \tc1 Eight \tc2 Nine \tc1
\tr Ten \tc2 Eleven
\tr \th1 Twelve \th2 Thirteen
\tr \tc1 Fourteen \tc2 Fifteen
\tr \tc1 Sixteen \tc2 Seventeen \tc1
\tr Eighteen \tc2 Nineteen
主要语言
C#
星标
29
派生
16
平均合并
5 天 20 小时
30 天内合并 PR
11

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

sillsdev/machine 的其他 Issue

查看 sillsdev/machine 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。