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

Bug(bbcode): converterMap 在某些情况下不能正常工作 #230

Open
trim21 opened this issue Nov 30, 2022 · 5 comments
Open

Bug(bbcode): converterMap 在某些情况下不能正常工作 #230

trim21 opened this issue Nov 30, 2022 · 5 comments

Comments

@trim21
Copy link
Contributor

trim21 commented Nov 30, 2022

  test('render code by custom converter, nested', () => {
    const input = '[b][url]qq[/url][/b]';
    expect(
      render(input, {
        url: (node) => {
          return '[url]convert map[/url]';
        },
      }),
    ).toBe('<strong>[url]convert map[/url]</strong>');
  });
 PASS  packages/website/src/hooks/use-pagination.spec.tsx
 FAIL  packages/utils/bbcode/__test__/html.test.ts
  ● html render bbcode string › render code by custom converter

    expect(received).toBe(expected) // Object.is equality

    Expected: "<strong>[url]convert map[/url]</strong>"
    Received: "<strong>[url]qq[/url]</strong>"

      249 |         },
      250 |       }),
    > 251 |     ).toBe(
          |       ^
      252 |       '<strong>[url]convert map[/url]</strong>',
      253 |     );
      254 |   });

      at Object.toBe (packages/utils/bbcode/__test__/html.test.ts:251:7)

也可以直接用这个 branch,这个case已经放在里面了 https://github.com/bangumi/frontend/compare/bbcode/convert-map-nested?expand=1

@trim21
Copy link
Contributor Author

trim21 commented Nov 30, 2022

@zhifengle 有兴趣修一下吗(

@zhifengle
Copy link
Contributor

@zhifengle 有兴趣修一下吗(

好的,我处理一下

@trim21
Copy link
Contributor Author

trim21 commented Nov 30, 2022

正好还有个场景,希望parser再加一个参数可以忽略某些BBCODE标签,比如用户主页是不支持img标签的。

@zhifengle
Copy link
Contributor

有个疑问 [url]qq[/url] 的使用场景是? 目前 Parser 是把 [url]qq[/url] 当作非法的 BBCode。
目前已修复 [url]http://qq.com[/url] 的情况

@trim21
Copy link
Contributor Author

trim21 commented Nov 30, 2022

这里是个convertMap没正常工作的例子,不是真正的使用场景。[url]http://qq.com[/url] 也可以

@zhifengle zhifengle mentioned this issue Dec 1, 2022
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

Successfully merging a pull request may close this issue.

2 participants