Skip to content
This repository was archived by the owner on Mar 7, 2020. It is now read-only.

Uniform white-space#321

Open
KOZ39 wants to merge 1 commit intotheheroGAC:masterfrom
KOZ39:master
Open

Uniform white-space#321
KOZ39 wants to merge 1 commit intotheheroGAC:masterfrom
KOZ39:master

Conversation

@KOZ39
Copy link

@KOZ39 KOZ39 commented Feb 11, 2020

Uniforms the length of all white-space so that it is equally aligned in browsers.

The code below was written in Python 3 and used for this operation.

import glob
import re

for file in glob.iglob('lang/*.lua'):
    if 'Langdatabase.lua' in file:
        continue

    for _ in range(2):
        with open(file, 'r', encoding='utf-8') as f:
            data = f.read()

        data = data.replace('\t', ' ')
        data = re.sub(r'[ \t]{2,}(?=")', r'', data)
        data = data.splitlines()

        data2 = []
        for i in data:
            if '=' in i and '{}' not in i:
                i = i.split('=', 1)
                i = (i[0] + '=').ljust(56) + i[1]
            data2.append(i)

        with open(file, 'w', encoding='utf-8') as f:
            f.write('\n'.join(data2))

Thank you for your tool and I will add Korean translation if it is available in the future.

@KOZ39
Copy link
Author

KOZ39 commented Feb 11, 2020

And if you set the space size to 2-4 in the text editor you use and enable the tab-to-spaces option, Python 3 code will be unnecessary. 😋

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant