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
- This keeps the JSON clean - examples without BinderHub links don't have the field
455
+
- Avoids `null` or empty string values in the metadata
456
+
457
+
**5. Line Processing Behavior**:
458
+
459
+
The `BINDER_ID` line is removed from output through the same mechanism as other marker lines:
460
+
461
+
-**How it works**: Setting `output = False` prevents the line from reaching the `else` block that calls `content.append(l)`
462
+
-**Line number impact**: Because the line is never added to `content`, it doesn't affect line number calculations for steps, highlights, or hidden ranges
463
+
-**Result**: The processed file is clean, containing only the actual code without any marker comments
464
+
465
+
**Common Pitfalls**:
466
+
1.**Forgetting `output = False`**: The line will appear in processed output
467
+
2.**Wrong placement in elif chain**: May not be detected or may interfere with other markers
468
+
3.**Using `if` instead of `elif`**: Could cause multiple conditions to match
469
+
4.**Not checking `if match`**: Could cause AttributeError if regex doesn't match
470
+
5.**Adding field unconditionally**: Results in `"binderId": null` in JSON for examples without the marker
471
+
472
+
**6. Complete Example Flow**:
473
+
474
+
Here's a complete example showing how a file is processed:
-**Verify**: Check processed file in `examples/{example_id}/` - should not contain `BINDER_ID` line
1178
+
1179
+
-**Symptom 3**: `"binderId": null` in metadata
1180
+
-**Cause**: Field added unconditionally instead of conditionally
1181
+
-**Fix**: Only add field if `example.binder_id` is not None:
1182
+
```python
1183
+
if example.binder_id:
1184
+
example_metadata['binderId'] = example.binder_id
1185
+
```
1186
+
1187
+
-**Symptom 4**: Wrong hash value extracted
1188
+
-**Cause**: Regex capture group not matching correctly
1189
+
-**Debug**: Check the regex pattern includes capture group: `([a-f0-9]{40})`
1190
+
-**Fix**: Ensure using `match.group(1)` to extract the captured hash
1191
+
1009
1192
### Performance Issues
1010
1193
1011
1194
**Build takes too long**:
@@ -1269,16 +1452,20 @@ In Markdown files:
1269
1452
1270
1453
| Marker | Purpose | Example | Notes |
1271
1454
|--------|---------|---------|-------|
1272
-
|`EXAMPLE: id`| Define example ID|`# EXAMPLE: home_vecsets` | Must be first line |
1273
-
|`BINDER_IDhash`| Define BinderHub commit hash|`# BINDER_ID 6bbed3da294e8de5a8c2ad99abf883731a50d4dd` | Optional, typically line 2. Used to generate interactive notebook links. Hash is a Git commit SHAfrom binder-launchers repo. |
|`EXAMPLE: id`| Define example ID|`# EXAMPLE: home_vecsets` | **Required**. Must be first line. Removed from processed output. |
1456
+
|`BINDER_IDhash`| Define BinderHub commit hash|`# BINDER_ID 6bbed3da294e8de5a8c2ad99abf883731a50d4dd` | **Optional**. Typically line 2 (after EXAMPLE). Hash must be exactly 40 hexadecimal characters (Git commit SHA). Removed from processed output. Stored as `binderId` in metadata. Used to generate interactive Jupyter notebook links. |
1457
+
|`HIDE_START`| Start hidden block |`# HIDE_START` | Code hidden by default, revealed with eye button |
1275
1458
|`HIDE_END`| End hidden block |`# HIDE_END` | Must close HIDE_START |
0 commit comments