Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
1eabc8c8
Commit
1eabc8c8
authored
Jan 25, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include end position in result
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
1fd77b3b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
17 deletions
+23
-17
weblate/trans/checks/format.py
weblate/trans/checks/format.py
+1
-3
weblate/trans/checks/markup.py
weblate/trans/checks/markup.py
+8
-4
weblate/trans/templatetags/translations.py
weblate/trans/templatetags/translations.py
+3
-4
weblate/trans/tests/test_format_checks.py
weblate/trans/tests/test_format_checks.py
+4
-4
weblate/trans/tests/test_markup_checks.py
weblate/trans/tests/test_markup_checks.py
+7
-2
No files found.
weblate/trans/checks/format.py
View file @
1eabc8c8
...
...
@@ -211,9 +211,7 @@ class BaseFormatCheck(TargetCheck):
ret
=
[]
match_objects
=
self
.
regexp
.
finditer
(
source
)
for
match
in
match_objects
:
if
match
.
start
()
==
match
.
end
():
continue
ret
.
append
((
match
.
start
(),
match
.
group
()))
ret
.
append
((
match
.
start
(),
match
.
end
(),
match
.
group
()))
return
ret
class
PythonFormatCheck
(
BaseFormatCheck
):
...
...
weblate/trans/checks/markup.py
View file @
1eabc8c8
...
...
@@ -71,8 +71,12 @@ class BBCodeCheck(TargetCheck):
return
[]
ret
=
[]
for
match
in
BBCODE_MATCH
.
finditer
(
source
):
ret
.
append
((
match
.
start
(
'start'
),
match
.
group
(
'start'
)))
ret
.
append
((
match
.
start
(
'end'
),
match
.
group
(
'end'
)))
for
tag
in
(
'start'
,
'end'
):
ret
.
append
((
match
.
start
(
tag
),
match
.
end
(
tag
),
match
.
group
(
tag
)
))
return
ret
...
...
@@ -118,7 +122,7 @@ class XMLTagsCheck(TargetCheck):
def
check_highlight
(
self
,
source
,
unit
):
ret
=
[]
for
match
in
XML_MATCH
.
finditer
(
source
):
ret
.
append
((
match
.
start
(),
match
.
group
()))
ret
.
append
((
match
.
start
(),
match
.
end
(),
match
.
group
()))
for
match
in
XML_ENTITY_MATCH
.
finditer
(
source
):
ret
.
append
((
match
.
start
(),
match
.
group
()))
ret
.
append
((
match
.
start
(),
match
.
end
(),
match
.
group
()))
return
ret
weblate/trans/templatetags/translations.py
View file @
1eabc8c8
...
...
@@ -98,14 +98,13 @@ def fmt_check_highlights(value, checks):
if
hl_idx
>=
len
(
highlights
):
break
elref
=
highlights
[
hl_idx
]
elref_end
=
elref
[
0
]
+
len
(
elref
[
1
])
for
hl_idx_next
in
xrange
(
hl_idx
+
1
,
len
(
highlights
)):
if
hl_idx_next
>=
len
(
highlights
):
break
eltest
=
highlights
[
hl_idx_next
]
if
eltest
[
0
]
>=
elref
[
0
]
and
eltest
[
0
]
<
elref
_end
:
if
eltest
[
0
]
>=
elref
[
0
]
and
eltest
[
0
]
<
elref
[
1
]
:
highlights
.
pop
(
hl_idx_next
)
elif
eltest
[
0
]
>
elref
_end
:
elif
eltest
[
0
]
>
elref
[
1
]
:
break
#then transform highlights to escaped html
highlights
=
[(
h
[
0
],
escape
(
force_text
(
h
[
1
])))
for
h
in
highlights
]
...
...
@@ -152,7 +151,7 @@ def format_translation(value, language, diff=None, search_match=None,
# Create span for checks highlights
if
highlights
:
start_search
=
0
for
htext
in
[
h
[
1
]
for
h
in
highlights
]:
for
htext
in
[
h
[
2
]
for
h
in
highlights
]:
find_highlight
=
value
.
find
(
htext
,
start_search
)
if
find_highlight
>=
0
:
newpart
=
u'<span class="hlcheck">{0}</span>'
.
format
(
htext
)
...
...
weblate/trans/tests/test_format_checks.py
View file @
1eabc8c8
...
...
@@ -37,7 +37,7 @@ class PythonFormatCheckTest(CheckTestCase):
self
.
test_highlight
=
(
'python-format'
,
'%sstring%d'
,
[(
0
,
u'%s'
),
(
8
,
u'%d'
)],
[(
0
,
2
,
u'%s'
),
(
8
,
10
,
u'%d'
)],
)
def
test_no_format
(
self
):
...
...
@@ -133,7 +133,7 @@ class PHPFormatCheckTest(CheckTestCase):
self
.
test_highlight
=
(
'php-format'
,
'%sstring%d'
,
[(
0
,
u'%s'
),
(
8
,
u'%d'
)],
[(
0
,
2
,
u'%s'
),
(
8
,
10
,
u'%d'
)],
)
def
test_no_format
(
self
):
...
...
@@ -229,7 +229,7 @@ class CFormatCheckTest(CheckTestCase):
self
.
test_highlight
=
(
'c-format'
,
'%sstring%d'
,
[(
0
,
u'%s'
),
(
8
,
u'%d'
)],
[(
0
,
2
,
u'%s'
),
(
8
,
10
,
u'%d'
)],
)
def
test_no_format
(
self
):
...
...
@@ -311,7 +311,7 @@ class PythonBraceFormatCheckTest(CheckTestCase):
self
.
test_highlight
=
(
'python-brace-format'
,
'{0}string{1}'
,
[(
0
,
u'{0}'
),
(
9
,
u'{1}'
)],
[(
0
,
3
,
u'{0}'
),
(
9
,
12
,
u'{1}'
)],
)
def
test_no_format
(
self
):
...
...
weblate/trans/tests/test_markup_checks.py
View file @
1eabc8c8
...
...
@@ -40,7 +40,7 @@ class BBCodeCheckTest(CheckTestCase):
self
.
test_highlight
=
(
''
,
'[a]string[/a]'
,
[(
0
,
'[a]'
),
(
9
,
'[/a]'
)]
[(
0
,
3
,
'[a]'
),
(
9
,
13
,
'[/a]'
)]
)
...
...
@@ -56,5 +56,10 @@ class XMLTagsCheckTest(CheckTestCase):
self
.
test_highlight
=
(
''
,
'<b><a href="foo">bar</a></b>'
,
[(
0
,
'<b>'
),
(
3
,
'<a href="foo">'
),
(
20
,
'</a>'
),
(
24
,
'</b>'
)]
[
(
0
,
3
,
'<b>'
),
(
3
,
17
,
'<a href="foo">'
),
(
20
,
24
,
'</a>'
),
(
24
,
28
,
'</b>'
),
]
)
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