Skip to content

Commit

Permalink
Add information to README about spacing policy
Browse files Browse the repository at this point in the history
  • Loading branch information
charrondev committed Nov 12, 2023
1 parent 9ccc578 commit 5037a87
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,29 @@ To extend the tag name and customize its style, you can use the ExtendTagName cl
let parser = ZHTMLParserBuilder.initWithDefault().add(ExtendTagName("zhgchgli"), withCustomStyle: MarkupStyle(backgroundColor: MarkupStyleColor(name: .aquamarine))).build()
```

#### Paragraph Spacing Policy

Often, you will want to create some type of spacing between various paragraphs or elements to increase legibility. There are two strategies to handle this:

1. Create additional line breaks in between paragraphs and sections. This means that there will be the size of 1 empty paragraph between each other paragraph. This is the default behaviour. In this mode you will likely want to ensure you are ***Not*** using paragraph spacing in in your markup styles.
2. Make use of `paragraphSpacing` through `MarkupStyleParagraphStyle` or `NSParagraphStyle`. If you are using these you will likely want to disable the additional line breaks.

This can be configured on your your `ZHTMLParserBuilder` as follows:

```swift
let parser = ZHTMLParserBuilder
.initWithDefault()
// Indicate that we should use paragraph spacing for spacing.
.set(spacingPolicy: .paragraphSpacing)
// Create our spacing using paragraphSpacing.
.set(rootStyle: .init(
paragraphStyle: .init(
paragraphSpacing: 12
)
))
.build()
```

### Render HTML String
```swift
parser.render(htmlString) // NSAttributedString
Expand Down

0 comments on commit 5037a87

Please sign in to comment.