Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
P
pgVersions
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hubert Lubaczewski
pgVersions
Commits
b72442ce
Commit
b72442ce
authored
Nov 16, 2019
by
Hubert depesz Lubaczewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Highlight only text, not tag attributes
parent
05e26afe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
1 deletion
+65
-1
lib/PgWhyUpgrade/Plugin/DB.pm
lib/PgWhyUpgrade/Plugin/DB.pm
+6
-1
test.pl
test.pl
+59
-0
No files found.
lib/PgWhyUpgrade/Plugin/DB.pm
View file @
b72442ce
...
...
@@ -337,7 +337,12 @@ sub get_all_diffs {
next unless $search_results->{ $new_version };
my @selected_changes = @{ $changes }[ @{ $search_results->{ $new_version } } ];
for my $item ( @selected_changes ) {
$item
=~
s{\b($keywords_re)\b}{<span class="searchhilight">$1</span>}gi
;
my @parts = split m{(<(?:[^>]*
|
"
[^
"]
*
"
|'[^']*')>)},
$item
;
for my
$element
(
@parts
) {
next if
$element
=~ m{
\
A<};
$element
=~ s{
\
b(
$keywords_re
)
\
b}{<span class=
"
searchhilight
"
>$1</span>}gi;
}
$item
= join '',
@parts
;
}
$changes
=
\
@selected_changes
;
}
...
...
test.pl
0 → 100755
View file @
b72442ce
#!/usr/bin/env perl
# UTF8 boilerplace, per http://stackoverflow.com/questions/6162484/why-does-modern-perl-avoid-utf-8-by-default/
use
v5
.14
;
use
strict
;
use
warnings
;
use
warnings
qw( FATAL utf8 )
;
use
utf8
;
use
open
qw( :std :utf8 )
;
use
Unicode::
Normalize
qw( NFC )
;
use
Unicode::
Collate
;
use
Encode
qw( decode )
;
if
(
grep
/\P{ASCII}/
=>
@ARGV
)
{
@ARGV
=
map
{
decode
(
'
UTF-8
',
$_
)
}
@ARGV
;
}
# If there is __DATA__,then uncomment next line:
# binmode( DATA, ':encoding(UTF-8)' );
# UTF8 boilerplace, per http://stackoverflow.com/questions/6162484/why-does-modern-perl-avoid-utf-8-by-default/
# Useful common code
use
autodie
;
use
Carp
qw( carp croak confess cluck )
;
use
English
qw( -no_match_vars )
;
use
Data::
Dumper
qw( Dumper )
;
# give a full stack dump on any untrapped exceptions
local
$SIG
{
__DIE__
}
=
sub
{
confess
"
Uncaught exception:
@_
"
unless
$^S
;
};
# now promote run-time warnings into stackdumped exceptions
# *unless* we're in an try block, in which
# case just generate a clucking stackdump instead
local
$SIG
{
__WARN__
}
=
sub
{
if
(
$^S
)
{
cluck
"
Trapped warning:
@_
"
}
else
{
confess
"
Deadly warning:
@_
"
}
};
# Useful common code
use
JSON
;
use
Data::
Dumper
;
use
Mojo::
File
;
use
Mojo::
DOM
;
my
$json
=
JSON
->
new
()
->
utf8
()
->
decode
(
Mojo::
File
->
new
("
db/10.js
")
->
slurp
);
my
$change
=
$json
->
[
4
];
my
@normalized_keywords
=
qw( returning set )
;
my
$keywords_re
=
join
(
'
|
',
map
{
''
eq
ref
$_
?
$_
:
join
(
'
|
',
@
{
$_
}
)
}
@normalized_keywords
);
for
my
$item
(
@
{
$change
}
)
{
my
@parts
=
split
m{(<(?:[^>]*|"[^"]*"|'[^']*')>)}
,
$item
;
for
my
$element
(
@parts
)
{
$element
=~
s{\b($keywords_re)\b}{<span class="searchhilight">$1</span>}gi
unless
$element
=~
m{\A<}
;
}
$item
=
join
'',
@parts
;
}
print
Dumper
(
$change
);
exit
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment