Explorar el Código

Join adjacent lines with only one word.

pull/24/head
Ben Kurtovic hace 12 años
padre
commit
e23a37dde8
Se han modificado 1 ficheros con 16 adiciones y 2 borrados
  1. +16
    -2
      toolserver/copyvios/highlighter.py

+ 16
- 2
toolserver/copyvios/highlighter.py Ver fichero

@@ -22,9 +22,10 @@ def highlight_delta(context, chain, delta):
i = degree
numwords = len(chain.text.split())
processed = []
for paragraph in chain.text.split("\n"):
paragraphs = chain.text.split("\n")
while paragraphs:
words = []
for i, word in enumerate(paragraph.split(), i):
for i, word in enumerate(_get_next(paragraphs), i):
if highlights[i]:
before = highlights[i - 1]
after = highlights[i + 1]
@@ -38,6 +39,19 @@ def highlight_delta(context, chain, delta):

return u"<p>" + u"</p>\n<p>".join(processed) + u"</p>"

def _get_next(paragraphs):
paragraph = paragraphs.pop(0)
body = paragraph.split()
if len(body) == 1:
while paragraphs:
next = paragraphs[0].split()
if len(next) == 1:
body += next
paragraphs.pop(0)
else:
break
return body

def _highlight_word(word, before, after, first, last):
if before and after:
# Word is in the middle of a highlighted block:


Cargando…
Cancelar
Guardar