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

allow mutating line and character rules #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

IlyaPuchkaTW
Copy link

Right now it's not possible to easily implement the subset of markdown that would strip all unsupported markdown tags away. The simplest way to do that seem to allow mutating the styles in characters and lines rules. This way users of the library can create set of rules that will strip away unsupported tags, i.e. like this:

extension SwiftyMarkdown {
   static private let stripLineRules = SwiftyMarkdown.lineRules.map { rule -> LineRule in 
       var noStyle = rule
       noStyle.type = .body
       return noStyle
   }
   
   static private let stripCharacterRules = SwiftyMarkdown.characterRules.map { rule -> CharacterRule in
        var noStyle = rule
        noStyle.styles = rule.styles.mapValues { _ in
            CharacterStyle.none
        }
        return noStyle
    }
}

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