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

Implement code and pre blocks support on iOS #306

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

maksg
Copy link
Contributor

@maksg maksg commented Apr 12, 2024

Details

Adds support for displaying and customising code and pre blocks on iOS.

@tomekzaw
Copy link
Collaborator

Still discussing the expected behavior for codeblocks here

@tomekzaw
Copy link
Collaborator

tomekzaw commented Apr 16, 2024

It looks like padding in markdownStyle only affects the size of the rectangle in the background and not the text itself:

Screenshot 2024-04-17 at 01 35 09

It's okay for the initial implementation but ultimately we'd like padding to affect the text layout here as well.

I don't think it's possible to achieve padding for inline code on iOS (Slack for iOS also does not support it).

However, I think it should be possible to implement padding for codeblocks. As for horizontal padding, I've copied this code from blockquotes and it seems to work:

NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
paragraphStyle.firstLineHeadIndent = indent;
paragraphStyle.headIndent = indent;
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:range];

Screenshot 2024-04-17 at 01 36 38

As for vertical padding, ChatGPT says that the only option is to set lineSpacing but this affects the height of the cursor so I'm not really sure how to implement it.

We can implement that in a follow-up PR.

@tomekzaw
Copy link
Collaborator

There seems to be some problem with codeblocks containing only one character:

Screen.Recording.2024-04-17.at.01.52.15.mov

@maksg maksg force-pushed the @maksg/code-and-pre-blocks branch from 09f4caf to 76bed9d Compare April 23, 2024 09:45
@tomekzaw tomekzaw self-requested a review April 25, 2024 14:20
@maksg maksg force-pushed the @maksg/code-and-pre-blocks branch from 76bed9d to dfc3362 Compare April 29, 2024 09:12
@maksg maksg force-pushed the @maksg/code-and-pre-blocks branch from dfc3362 to a5d038c Compare May 21, 2024 09:28
@maksg maksg force-pushed the @maksg/code-and-pre-blocks branch from a5d038c to 589feb1 Compare May 21, 2024 09:57
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 this pull request may close these issues.

2 participants