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

Table Alignment #136

Merged
merged 1 commit into from
Jun 1, 2023
Merged

Table Alignment #136

merged 1 commit into from
Jun 1, 2023

Conversation

trimental
Copy link
Collaborator

Adds table item horizontal alignment as shown below:

image

Looks like wrapping is still occurring in some weird places, might just be some f32 nonsense with the bounds changing slightly between rendering and layingout

Copy link
Collaborator

@CosmicHorrorDev CosmicHorrorDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! I never even noticed that tables didn't handle alignment before

Comment on lines +332 to +342
let align = tag
.attrs
.iter()
.find(|attr| attr.name.local == local_name!("align"))
.map(|attr| match attr.value.to_string().as_str() {
"left" => Some(Align::Left),
"center" => Some(Align::Center),
"right" => Some(Align::Right),
_ => None,
})
.unwrap_or_default();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this bit is repeated. Maybe it would make sense to make it a method on tag or tag.attrs?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was planning on refactoring things in a followup PR to use an AttrIter iterator since there's a lot of near duplicated code for attribute parsing scattered around the interpreter

@trimental trimental merged commit 7424a3d into main Jun 1, 2023
@CosmicHorrorDev CosmicHorrorDev added C-enhancement Category: New feature or request A-table Area: Dealing with markdown tables labels Jun 1, 2023
@CosmicHorrorDev CosmicHorrorDev deleted the table-alignment branch September 15, 2024 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-table Area: Dealing with markdown tables C-enhancement Category: New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants