Comments (2)
Iām not sure if this is an issue related to MarkyMark, is the same set-up with a multi line UILabel working correctly?
Regards,
Jim
from marky-mark.
I had the same issue as @christie-alphero but was able to create my own label class that worked around the issue. This is the most wonderful markdown library on iOS, thank you so much for your hard work @jvanzummeren!
@IBDesignable
open class CustomMarkdownAttributedLabel: AttributedInteractiveLabel {
public let styling = DefaultStyling()
override open var font: UIFont? {
didSet {
styling.paragraphStyling.baseFont = font
markDownAttributedString = attributedText
}
}
override open var textColor: UIColor? {
didSet {
styling.paragraphStyling.textColor = textColor
markDownAttributedString = attributedText
}
}
override open var text: String? {
didSet {
if let attributedText = createMarkDownAttributedString(markDownText: text) {
markDownAttributedString = attributedText
}
}
}
override open var textAlignment: NSTextAlignment {
didSet {
styling.paragraphStyling.textAlignment = markyMarkTextAlignment(ofTextAlignment: textAlignment)
markDownAttributedString = attributedText
}
}
public init(font: UIFont? = nil) {
super.init()
self.font = font
configureViewProperties()
}
override public init(frame: CGRect) {
super.init(frame: CGRect())
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
configureViewProperties()
styling.paragraphStyling.baseFont = font
styling.paragraphStyling.textColor = textColor
styling.paragraphStyling.textAlignment = markyMarkTextAlignment(ofTextAlignment: textAlignment)
if let attributedText = createMarkDownAttributedString(markDownText: text) {
markDownAttributedString = attributedText
}
}
}
private extension CustomMarkdownAttributedLabel {
func createMarkDownAttributedString(markDownText: String?) -> NSAttributedString? {
guard let markDownText = markDownText else { return nil }
let markyMark = MarkyMark(build: {
$0.setFlavor(ContentfulFlavor())
})
// Parsing to MarkDownItem's
let markDownItems = markyMark.parseMarkDown(markDownText)
// Converting to views
let configuration = MarkDownToAttributedStringConverterConfiguration(styling: styling)
let converter = MarkDownConverter(configuration: configuration)
return converter.convert(markDownItems)
}
func markyMarkTextAlignment(ofTextAlignment textAlignment: NSTextAlignment) -> TextAlignment {
let markyMarkTextAlignment: TextAlignment
switch textAlignment {
case .left:
markyMarkTextAlignment = .left
case .right:
markyMarkTextAlignment = .right
case .center:
markyMarkTextAlignment = .center
default:
markyMarkTextAlignment = .left
}
return markyMarkTextAlignment
}
}
from marky-mark.
Related Issues (20)
- Won't open in Xcode 11.4 HOT 2
- Bold Italic sequence is working. But when you try to do italic bold sequence its not workin. HOT 2
- Dark Mode Support
- [iOS ]Unable to add <br/> tag functionality on MarkDowbTextView(). <br/> as it is display on UI. HOT 2
- MarkyMark does not support `<url>` style links
- Unable to render data corectly when I add "-" in the data HOT 3
- Couldn't convert text containing link when link has prefix exclamation mark HOT 2
- Setting MarkDownTextView.onDidConvertMarkDownItemToView does not work
- Image loading blocking UI HOT 2
- 'Key' is not a member type of 'NSAttributedString' HOT 2
- List items overlapping each other in MarkDownTextView HOT 1
- URLs containing underscores are being italicized HOT 3
- Any way to show latex?
- Handle tap on elements HOT 3
- Marky-Mark is not detecting url automatically. How to enable that?? HOT 4
- Ability to customize UITextView that's created in attributedString configuration of MarkdownTextView HOT 3
- LineBreaks not consistent
- [Q] - Using Local Images HOT 2
- Add spm support HOT 2
- URL handler in attributed string
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marky-mark.