Skip to content

Header text is truncated sometimes - Proposed fix #369

@yccheok

Description

@yccheok

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
Header text is truncated sometimes, randomly

issue

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
It happens randomly. This is the markdown text I am using

# Exploring the Fragility of Life in an Infinite Universe

## The Central Question of Existence
- The primary philosophical inquiry is: **What does it mean to live a finite, fragile life in an infinite, eternal universe?**
- The universe contains approximately **2 trillion galaxies**, with the Milky Way housing around **400 billion stars**.
- Despite the vastness, Earth is the only known place where life and meaning exist.

## The Scale of the Universe
- Light takes over **100,000 years** to traverse a galaxy, emphasizing the immense scale of the universe.
- The visible universe is likely just a small portion of a potentially infinite cosmos.
- The challenge of visualizing this scale is acknowledged; it is beyond human comprehension.

## Human Significance in the Universe
- Although humans are physically insignificant in the grand scheme, we are unique as **collections of atoms** that can think and create.
- The idea that the universe understands itself through human consciousness is highlighted, referencing **Carl Sagan**.
- The rarity of intelligent life is suggested, as there is no evidence of other civilizations in our galaxy despite extensive searches.

## The Development of Life on Earth
- Life on Earth began around **3.8 billion years ago**, with complex life taking over **3 billion years** to evolve from single-celled organisms.
- The timeline from simple to complex life is significant, indicating the precarious nature of life's evolution.
- The extinction of dinosaurs **65 million years ago** allowed mammals to thrive, leading to the emergence of human civilization.

## Conclusion: The Precarious Nature of Civilization
- The absence of evidence for other civilizations suggests that Earth may be the **only place** where intelligent life has developed.
- The survival and evolution of life are portrayed as fragile and dependent on a series of fortunate events in a violent universe.

Expected behavior
Header text without truncation

Screenshots
I avoid this is to use the following

// https://stackoverflow.com/a/56558187/72437
.fixedSize(horizontal: false, vertical: true)

For instance,

.heading1 { configuration in
  VStack(alignment: .leading, spacing: 0) {
    configuration.label
      // https://stackoverflow.com/a/56558187/72437
      .fixedSize(horizontal: false, vertical: true)
      .relativePadding(.bottom, length: .em(0.3))
      .relativeLineSpacing(.em(0.125))
      .markdownMargin(top: 24, bottom: 16)
      .markdownTextStyle {
        FontWeight(.semibold)
          FontSize(.em(1.45))
        ForegroundColor(Color(UIColor.tintColor))
      }
    Divider().overlay(Color.divider)
  }
}

It looks like

fix

Version information

  • MarkdownUI: 2.4.1
  • OS: iOS 16
  • Xcode: 16.0

Additional context
Can I propose such a fix to?

https://github.com/gonzalezreal/swift-markdown-ui/blob/a9c7615fb50323069c2979c69263973aa1b24a8f/Sources/MarkdownUI/Theme/Theme%2BGitHub.swift

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions