Skip to content

bobbydeveloper2014/bybywebscrirpt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bybywebscrirpt

Giới thiệu / Introduction

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.


Cách sử dụng / How to use

1. Yêu cầu / Requirements

  • 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 .b format to convert.

2. Chuyển đổi file / Convert file

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.

Chạy script / Run script

python main.py

Script 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.

Mặc định trong mã nguồn / Default in source code

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.


3. Định dạng file .b / .b file format

  • 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ằng bybyend
    Byby code blocks start with byby: and end with bybyend
  • 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.

4. Mở file HTML sau khi chuyển đổi / Open HTML after conversion

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.


5. Ví dụ / Example

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.html chứa nội dung HTML tương ứng
    index.html with the corresponding HTML content
  • main.byby chứa mã Byby giữa hai dòng byby:bybyend
    main.byby with the Byby code between byby: and bybyend

Tùy chỉnh / Customization

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.


Liên hệ & Đóng góp / Contact & Contribute

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.