Skip to content

Instantly share code, notes, and snippets.

@cscotta
Created October 10, 2008 19:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cscotta/16132 to your computer and use it in GitHub Desktop.
Save cscotta/16132 to your computer and use it in GitHub Desktop.
# Basic regex + Ruby method to strip textile formatting.
# Handles all test cases at http://hobix.com/textile/ down to "Phrase Attributes."
def strip_textile(text)
text.gsub(/\b[_+^*~@%\-]{1,2}|[_+^*~@%\-]{1,2}\b|\b\?\?|\?\?\b|h\d\.\s|bq.\s|fn\d\.\s|\D\{.*\}\.\s?|\{.*\}\.\s?|\%\{.*\}|\D\(.*\)\.\s?|\{%.*\%\}\s|<.*?>/, "")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment