You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way for BeautifyRuby to skip beautifying sections of code? I made a workaround that I put in beautify_ruby.py:
def extract_no_beautify(text):
lines = text.splitlines()
no_beautify = []
noformat_start = -1
for index, line in enumerate(lines):
if line.lstrip().startswith("#") and "@noformat start" in line.lower():
noformat_start = index + 1
elif line.lstrip().startswith("#") and "@noformat end" in line.lower():
no_beautify.append([noformat_start, index])
no_beautify = ['\n'.join(lines[start:end]) for start, end in no_beautify]
return no_beautify
def insert_no_beautify(text, no_beautify):
lines = text.splitlines()
no_beautify_regions = []
noformat_start = -1
for index, line in enumerate(lines):
if line.lstrip().startswith("#") and "@noformat start" in line.lower():
noformat_start = index + 1
elif line.lstrip().startswith("#") and "@noformat end" in line.lower():
no_beautify_regions.append([noformat_start, index])
for index, region in enumerate(no_beautify_regions):
lines[region[0]:region[1]] = [no_beautify[index]]
return '\n'.join(lines)
I have not tried the code above but I would love to have it added as a feature. For example some strings inside %w() are causing the indentation to get messed up.
Activity
roycetech commentedon Apr 17, 2016
I have not tried the code above but I would love to have it added as a feature. For example some strings inside %w() are causing the indentation to get messed up.