Created
October 6, 2015 04:19
-
-
Save suchipi/4f94e96faab1615965d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RegexHelpers = | |
# matches colors like #ffffff, #eee, rgb(255,255,255), and rgba(255, 255, 255, 0.25) | |
cssColorMatchString: '(?:#(?:[0-9a-f]{6}|[0-9a-f]{3}))|(?:rgba?\\((?:\\d+, *){2,3}(?:\\d+(?:\\.\\d+)?)\\))' | |
makeTagRegex: (tagName, attributeMatch=".*") -> | |
# matches: | |
# <tagName attribute>content</tagName> | |
# [tagName: attribute]content[/tagName] | |
# <tagName = attribute>content</tagName> | |
# <tagName>content</tagName> | |
# | |
# $1 is attribute, $2 is content | |
attributeMatch = attributeMatch.join('|') if _.isArray(attributeMatch) | |
new RegExp "(?:<|\\[)#{tagName}(?: *(?: |:|=) *(#{attributeMatch}))? *(?:>|\\])(.+)(?:<|\\[)\\/#{tagName}(?:>|\\])", 'ig' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment