Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def new_format(T,F):
- #@param T: text with style
- #@param F: format
- stili = ["italics", "plain", "bold", "underlined"] #stili possibili
- if (F[0] not in stili) or ( (F[1]>=len(T[0])) or (F[2]>=len(T[0])) ) or (F[1]<0 or F[2]<=0):
- pass
- else:
- flag = 0
- for i in range(1,len(T)):
- if(T[i][0] == F[0]):
- if (F[1]>=T[i][1] and F[1]<=T[i][2]) or (F[2]<=T[i][2] and F[2]>=T[i][1]) or ( not( (F[1]>T[i][2]) or (F[2]<T[i][1]) ) ):
- T[i][1] = min(T[i][1], F[1])
- T[i][2] = max(T[i][2], F[2])
- else:
- flag+=1
- else:
- flag+=1
- if flag == len(T[1:]):
- T.append(F)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement