We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
An example of how we could add the Highlightr
import Highlightr
Add to Markdown.CodeBlockView the next code:
var body: some View { switch unit.type { case let .codeBlock(_, code): if let lang = codeType { content(codeType: codeType, code: code) } else { content(code: code) } default: EmptyView() } } private func content(codeType: String?, code: String) -> some View { ScrollView(.horizontal, showsIndicators: true) { CodeView(codeType: codeType, code: code) .scaledToFit() } .padding([.leading, .top, .trailing], 12) .background(Color.background) .cornerRadius(6) .padding(.bottom, 3) }
Example of the CodeView:
fileprivate struct CodeView: UIViewRepresentable { let codeType: String? let code: String init(codeType: String?, code: String) { self.codeType = codeType self.code = code } private var textStorage = CodeAttributedString() func makeUIView(context: Context) -> UITextView { textStorage.language = codeType?.lowercased() let layoutManager = NSLayoutManager() textStorage.addLayoutManager(layoutManager) let textContainer = NSTextContainer(size: .zero) layoutManager.addTextContainer(textContainer) let textView = UITextView(frame: .zero, textContainer: textContainer) textView.autoresizingMask = [.flexibleHeight, .flexibleWidth] textView.autocorrectionType = UITextAutocorrectionType.no textView.autocapitalizationType = UITextAutocapitalizationType.none textView.font = UIFont(name: "Menlo-Regular", size: 13) textView.textColor = UIColor(named: "codeBlockForeground") textView.isSelectable = true textView.isUserInteractionEnabled = true textView.isEditable = false textView.isScrollEnabled = false textView.dataDetectorTypes = .all textView.backgroundColor = .clear textView.textContainer.lineFragmentPadding = .zero textView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) textView.text = code return textView } func updateUIView(_ uiView: UITextView, context: Context) {} }
The text was updated successfully, but these errors were encountered:
Stampoo
Successfully merging a pull request may close this issue.
Describe the solution you'd like
An example of how we could add the Highlightr
Add to Markdown.CodeBlockView the next code:
Example of the CodeView:
The text was updated successfully, but these errors were encountered: