Skip to content

Commit c82cbf4

Browse files
generate from efg directly
1 parent f6d1691 commit c82cbf4

File tree

2 files changed

+118
-205
lines changed

2 files changed

+118
-205
lines changed

src/draw_tree/core.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,16 @@ def draw_tree(ef_file: str, scale_factor: float = 1.0, show_grid: bool = False)
12621262
Returns:
12631263
Complete TikZ code ready for use in Jupyter notebooks or LaTeX documents.
12641264
"""
1265+
# If user supplied an EFG file, convert it to .ef first so the existing
1266+
# ef-based pipeline can be reused. efg_to_ef returns a path string when
1267+
# it successfully writes the .ef file.
1268+
if isinstance(ef_file, str) and ef_file.lower().endswith('.efg'):
1269+
try:
1270+
ef_file = efg_to_ef(ef_file)
1271+
except Exception:
1272+
# fall through and let ef_to_tex raise a clearer error later
1273+
pass
1274+
12651275
# Step 1: Generate the tikzpicture content using ef_to_tex logic
12661276
tikz_picture_content = ef_to_tex(ef_file, scale_factor, show_grid)
12671277

@@ -1374,6 +1384,13 @@ def generate_tex(ef_file: str, output_tex: Optional[str] = None, scale_factor: f
13741384
ef_path = Path(ef_file)
13751385
output_tex = ef_path.with_suffix('.tex').name
13761386

1387+
# If input is an EFG file, convert it first
1388+
if isinstance(ef_file, str) and ef_file.lower().endswith('.efg'):
1389+
try:
1390+
ef_file = efg_to_ef(ef_file)
1391+
except Exception:
1392+
pass
1393+
13771394
# Generate TikZ content using draw_tree
13781395
tikz_content = draw_tree(ef_file, scale_factor, show_grid)
13791396

0 commit comments

Comments
 (0)