Công cụ này giúp chuyển đổi bybywebscript .b (ví dụ: index.b) sang file HTML và trích xuất code Bybylang sang file riêng.
This tool converts bybywebscript .b files (e.g., index.b) to HTML and extracts Bybylang code to a separate file. The main script for conversion is main.py.
- Python 3.x đã cài đặt trên máy.
Python 3.x installed. - Các file test hoặc file nguồn cần chuyển đổi (định dạng
.b).
Test/source files in.bformat to convert.
Giả sử bạn có file index.b và muốn chuyển nó sang index.html và trích xuất mã Byby sang main.byby.
Suppose you have index.b and want to convert it to index.html and extract Byby code to main.byby.
python main.pyScript sẽ tự động chuyển file index.b thành index.html và tạo thêm file main.byby chứa khối mã Byby.
The script will automatically convert index.b into index.html and create main.byby containing Byby code blocks.
Trong main.py, dòng sau sẽ thực hiện chuyển đổi:
In main.py, this line performs the conversion:
parse_b_file('index.b', 'index.html', 'main.byby')Bạn có thể thay đổi tên file nguồn và file đầu ra trong hàm parse_b_file.
You can change input and output filenames in the parse_b_file function.
- Các dòng bắt đầu bằng tên thẻ HTML, ví dụ:
button: text='Click me', id='btn1'
Lines start with HTML tag name, e.g.,button: text='Click me', id='btn1' - Các block mã Byby bắt đầu bằng
byby:và kết thúc bằngbybyend
Byby code blocks start withbyby:and end withbybyend - Các khối script sẽ được nhận diện và đưa vào thẻ
<script>trong HTML.
Script blocks are recognized and put into<script>tags in HTML.
Sau khi thực hiện chuyển đổi, script sẽ tự động mở file HTML kết quả bằng chương trình mặc định của hệ điều hành.
After conversion, the script will automatically open the HTML file using the system's default program.
index.b
h1: text='Tiêu đề'
button: text='Nhấn', id='btn1'
byby:
print('Hello from Byby!')
bybyend
Sau khi chạy, bạn sẽ có:
After running, you will have:
index.htmlchứa nội dung HTML tương ứng
index.htmlwith the corresponding HTML contentmain.bybychứa mã Byby giữa hai dòngbyby:vàbybyend
main.bybywith the Byby code betweenbyby:andbybyend
Bạn có thể chỉnh sửa hàm parse_b_file trong main.py để thay đổi logic chuyển đổi hoặc xử lý thêm các loại thẻ HTML và thuộc tính khác.
You can edit the parse_b_file function in main.py to change conversion logic or support additional HTML tags and attributes.
Nếu bạn gặp lỗi hoặc muốn đóng góp, hãy tạo issue hoặc pull request tại GitHub repo.
If you find bugs or want to contribute, please create an issue or pull request at GitHub repo.