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

Very long code block #335

Open
3 tasks done
zhanzhenzhen opened this issue Jul 5, 2024 · 2 comments
Open
3 tasks done

Very long code block #335

zhanzhenzhen opened this issue Jul 5, 2024 · 2 comments

Comments

@zhanzhenzhen
Copy link

zhanzhenzhen commented Jul 5, 2024

Thank you for contributing to MarkdownUI!

Before you submit an issue, please complete the report with all the relevant details for your bug and go through every item in the checklist.

Describe the bug
If the code block is very long (this example contains 697 lines) and matches a certain pattern (for example, the first line is long), then the code block is not rendered. It just outputs an empty block.

Checklist

  • I can reproduce this issue with a vanilla SwiftUI project.
  • I can reproduce this issue using the main branch of this package.
  • This bug hasn't been addressed in an existing GitHub issue.

Steps to reproduce

Assign this long string (given at the bottom of this comment) to longText and use Markdown(longText) to see the effect. The code block isn’t rendered. Screenshot:

Screenshot 2024-07-08 at 22 19 50

But if I use a custom style without using ScrollView(.horizontal), as follows:

Markdown(longText)
.markdownBlockStyle(\.codeBlock) { configuration in
    configuration.label
    .fixedSize(horizontal: false, vertical: true)
    .relativeLineSpacing(.em(0.15))
    .markdownTextStyle {
        FontFamilyVariant(.monospaced)
    }
    .padding(10)
    .frame(maxWidth: .infinity, alignment: .leading)
    .background(.black.opacity(0.1))
    .markdownMargin(top: .zero, bottom: .em(1))
}

It’s rendered:

Screenshot 2024-07-08 at 22 20 41

This is the longText:

let longText = """
This is a code block:

```
abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg ab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a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
```
"""

Markdown(longText)

Expected behavior
I expect the code block to be rendered when using the default theme (with horizontal scroll view).

Version information

  • MarkdownUI: 2.3.1
  • OS: iOS 17.5.1, macOS 15.0 beta 2
  • Xcode: 16.0 beta 2
@zhanzhenzhen
Copy link
Author

I updated the description of the issue. Added two screenshots.

@zhanzhenzhen
Copy link
Author

@gonzalezreal Could you please have a look?

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

No branches or pull requests

1 participant