FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
developer.github.com/lib/strings.rb at master · garethmj/developer.github.com · GitHub
garethmj
/
developer.github.com
Public
forked from
github/developer.github.com
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
developer.github.com
/
lib
/
strings.rb
Copy path
More file actions
More file actions
Latest commit
History
History
History
28 lines (23 loc) · 664 Bytes
Breadcrumbs
developer.github.com
/
lib
/
strings.rb
Copy path
File metadata and controls
28 lines (23 loc) · 664 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require
'active_support/core_ext/string'
module
GitHub
module
Strings
# taken from Liquid: http://git.io/vBNqH
def
strip_html
(
str
)
str
.
to_s
.
gsub
(
%r{<script.*?</script>}m
,
''
)
\
.
gsub
(
/<!--.*?-->/m
,
''
)
\
.
gsub
(
%r{<style.*?</style>}m
,
''
)
\
.
gsub
(
/<.*?>/m
,
''
)
end
# taken from Rails: http://git.io/vBNcY
def
squish
(
str
)
str
.
gsub
(
/[[:space:]]+/
,
' '
)
.
strip
end
def
escape_quoted_characters
(
str
)
str
.
gsub
(
'\\'
,
'\\\\\\'
)
.
gsub
(
'"'
,
'\"'
)
end
def
clean_for_json
(
str
)
strip_html
(
squish
(
escape_quoted_characters
(
str
)
)
)
end
end
end
include
GitHub
::
Strings
Back
|
FazBrowse Home
|
New Git URL