<commit_before>import Aztec
import Foundation

public extension Element {
    static let gutenpack = Element("gutenpack")
}

public class GutenpackConverter: ElementConverter {
    
    // MARK: - ElementConverter
    
    public func convert(
        _ element: ElementNode,
        inheriting attributes: [NSAttributedStringKey: Any],
        childrenSerializer serializeChildren: ChildrenSerializer) -> NSAttributedString {
        
        precondition(element.type == .gutenpack)
        
        let attachment = HTMLAttachment()
        let decoder = GutenbergAttributeDecoder()
        if let content =  decoder.decodedAttribute(named: GutenbergAttributeNames.selfCloser, from: element) {
            attachment.rawHTML = String(content.prefix(upTo: content.index(before:content.endIndex)))
            attachment.rootTagName = String(content.trimmingCharacters(in: .whitespacesAndNewlines).prefix(while: { (char) -> Bool in
                char != " "
            }))
        } else {
            let serializer = HTMLSerializer()
            attachment.rootTagName = element.name
            attachment.rawHTML = serializer.serialize(element)
        }

            return NSAttributedString(attachment: attachment, attributes: attributes)
    }
        
}<commit_msg>Remove double space.<commit_after>import Aztec
import Foundation

public extension Element {
    static let gutenpack = Element("gutenpack")
}

public class GutenpackConverter: ElementConverter {
    
    // MARK: - ElementConverter
    
    public func convert(
        _ element: ElementNode,
        inheriting attributes: [NSAttributedStringKey: Any],
        childrenSerializer serializeChildren: ChildrenSerializer) -> NSAttributedString {
        
        precondition(element.type == .gutenpack)
        
        let attachment = HTMLAttachment()
        let decoder = GutenbergAttributeDecoder()
        if let content = decoder.decodedAttribute(named: GutenbergAttributeNames.selfCloser, from: element) {
            attachment.rawHTML = String(content.prefix(upTo: content.index(before:content.endIndex)))
            attachment.rootTagName = String(content.trimmingCharacters(in: .whitespacesAndNewlines).prefix(while: { (char) -> Bool in
                char != " "
            }))
        } else {
            let serializer = HTMLSerializer()
            attachment.rootTagName = element.name
            attachment.rawHTML = serializer.serialize(element)
        }

            return NSAttributedString(attachment: attachment, attributes: attributes)
    }
        
}
{'fraction_non_alphanumeric': 0.08391881342701014, 'fraction_numerical': 0.0, 'mean_word_length': 2.677187948350072, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3146294', 'n_tokens_mistral': 648, 'n_tokens_neox': 628, 'n_words': 138}