Created
January 23, 2022 22:07
-
-
Save AnirudhDagar/a7cdfb283dd45078d47606736af39521 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 script tests if the syntax for slides is correct | |
## after generating the machine translations in d2l. | |
## Useful to debug errors all in one go like shown below | |
## Example: | |
## assert len(start) == len(end), f'some {p} are not enclosed in {text}' | |
## AssertionError: some ('[**', '**]') are not enclosed in [**Kayıp** hesaplanmadan önce] | |
######################################################## | |
import glob | |
import os | |
from d2lbook import slides, notebook, common | |
all_nb = [] | |
for full_name in glob.glob('chapter**/*.md', recursive=True): | |
if os.path.isfile(full_name): | |
all_nb.append(full_name) | |
def test_remove_slide_marks(all_nb): | |
for file in all_nb: | |
try: | |
with open(file, 'r+') as _md: | |
nb = _md.read() | |
except: | |
print("error opening") | |
nb = notebook.read_markdown(nb) | |
try: | |
nb = slides.remove_slide_marks(nb) | |
except Exception as e: | |
print(f"Assertion error in {file}:") | |
test_remove_slide_marks(all_nb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment