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

<p></p>标签得到的结果没有独自一个段落 #188

Open
zhouzhuo810 opened this issue Sep 13, 2024 · 2 comments
Open

<p></p>标签得到的结果没有独自一个段落 #188

zhouzhuo810 opened this issue Sep 13, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@zhouzhuo810
Copy link

zhouzhuo810 commented Sep 13, 2024

解析结果应该是块级元素,而不是行内元素。

修改demo:

image

运行结果:

image

期望结果:

image
@zhouzhuo810 zhouzhuo810 added the bug Something isn't working label Sep 13, 2024
@zhouzhuo810
Copy link
Author

zhouzhuo810 commented Sep 13, 2024

我改造了一下 ParagraphNode 实现了我想要的效果。

class ParagraphNode extends ElementNode {
  final PConfig pConfig;
  final Map<String, String> attribute;

  ParagraphNode(this.pConfig, this.attribute);

  @override
  InlineSpan build() {
    TextAlign? align;
    if (attribute['align'] == 'center') {
      align = TextAlign.center;
    } else if (attribute['align'] == 'right') {
      align = TextAlign.right;
    }
    return WidgetSpan(
        child: Row(
      children: [
        Expanded(
            child: Text.rich(
          TextSpan(
              children: List.generate(children.length, (index) {
            final child = children[index];
            return child.build();
          })),
          textAlign: align ?? pConfig.textAlign,
        ))
      ],
    ));
  }

  @override
  TextStyle? get style => pConfig.textStyle.merge(parentStyle);
}

image

@asjqkkkk
Copy link
Owner

image

@zhouzhuo810 你好,目前看来应该是编写的html解析那里没有正确识别换行导致的,因为html的解析属于example模块,所以它算是一个example中的错误例子,而不是markdown_widget本身的解析问题,后面如果有时间的话我会尝试去处理这个问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants