mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 13:16:41 +00:00
tools/fixlexcode.py: support embedded backtick comments as used by ffmpegx
This commit is contained in:
parent
0f2bb9d1bc
commit
8814747508
@ -129,17 +129,35 @@ def fix_backticks(line, changed):
|
|||||||
changes = 0
|
changes = 0
|
||||||
newline = ''
|
newline = ''
|
||||||
intick = False
|
intick = False
|
||||||
|
iscomment = False
|
||||||
|
c = 0
|
||||||
|
|
||||||
for c in line:
|
# Don't fix backticks in comments as more likely to be markdown
|
||||||
if c == '`':
|
if line.startswith('#'):
|
||||||
if not intick:
|
return line
|
||||||
|
|
||||||
|
while c < len(line):
|
||||||
|
char = line[c:c+1]
|
||||||
|
charn = line[c+1:c+2]
|
||||||
|
|
||||||
|
# Don't convert "embedded" comments such as `# blah blah`
|
||||||
|
if not intick and char == '`' and charn == '#':
|
||||||
|
iscomment = True
|
||||||
|
|
||||||
|
if char == '`' and (intick or charn != '#'):
|
||||||
|
if iscomment:
|
||||||
|
newline += char
|
||||||
|
iscomment = False
|
||||||
|
elif not intick:
|
||||||
newline += '$('
|
newline += '$('
|
||||||
changes += 1
|
changes += 1
|
||||||
else:
|
else:
|
||||||
newline += ')'
|
newline += ')'
|
||||||
intick = not intick
|
intick = not intick
|
||||||
else:
|
else:
|
||||||
newline += c
|
newline += char
|
||||||
|
|
||||||
|
c += 1
|
||||||
|
|
||||||
changed['backticks'] += changes
|
changed['backticks'] += changes
|
||||||
changed['isdirty'] = (changed['isdirty'] or changes != 0)
|
changed['isdirty'] = (changed['isdirty'] or changes != 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user