-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove spaces in single-line equations
- Loading branch information
Showing
17 changed files
with
87 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python3 | ||
import re | ||
from pathlib import Path | ||
|
||
from nbdev.clean import process_write | ||
|
||
pat = re.compile(r'\$\s*([^\$]+?)\s*\$') | ||
|
||
def clean_equations(nb): | ||
for cell in nb['cells']: | ||
if cell['cell_type'] != 'markdown': | ||
continue | ||
lines = [] | ||
for i, line in enumerate(cell['source']): | ||
line = pat.sub(r'$\1$', line) | ||
lines.append(line) | ||
cell['source'] = lines | ||
|
||
|
||
if __name__ == '__main__': | ||
repo_root = Path(__file__).parents[1] | ||
for nb in (repo_root / 'nbs' / 'docs').rglob('*.ipynb'): | ||
process_write(warn_msg='Failed to clean_nb', proc_nb=clean_equations, f_in=nb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.