@@ -33,6 +33,7 @@ def _quarto_re(lang=None): return re.compile(_dir_pre(lang) + r'\s*[\w|-]+\s*:')
3333# %% ../nbs/api/03_process.ipynb 11
3434def _directive (s , lang = 'python' ):
3535 s = re .sub ('^' + _dir_pre (lang ), f"{ langs [lang ]} |" , s )
36+ if s .strip ().endswith (':' ): s = s .replace (':' , '' ) # You can append colon at the end to be Quarto compliant. Ex: #|hide:
3637 if ':' in s : s = s .replace (':' , ': ' )
3738 s = (s .strip ()[2 :]).strip ().split ()
3839 if not s : return None
@@ -70,22 +71,22 @@ def extract_directives(cell, remove=True, lang='python'):
7071 cell ['source' ] = '' .join ([_norm_quarto (o , lang ) for o in dirs if _quarto_re (lang ).match (o ) or _cell_mgc .match (o )] + code )
7172 return dict (L (_directive (s , lang ) for s in dirs ).filter ())
7273
73- # %% ../nbs/api/03_process.ipynb 22
74+ # %% ../nbs/api/03_process.ipynb 21
7475def opt_set (var , newval ):
7576 "newval if newval else var"
7677 return newval if newval else var
7778
78- # %% ../nbs/api/03_process.ipynb 23
79+ # %% ../nbs/api/03_process.ipynb 22
7980def instantiate (x , ** kwargs ):
8081 "Instantiate `x` if it's a type"
8182 return x (** kwargs ) if isinstance (x ,type ) else x
8283
8384def _mk_procs (procs , nb ): return L (procs ).map (instantiate , nb = nb )
8485
85- # %% ../nbs/api/03_process.ipynb 24
86+ # %% ../nbs/api/03_process.ipynb 23
8687def _is_direc (f ): return getattr (f , '__name__' , '-' )[- 1 ]== '_'
8788
88- # %% ../nbs/api/03_process.ipynb 25
89+ # %% ../nbs/api/03_process.ipynb 24
8990class NBProcessor :
9091 "Process cells and nbdev comments in a notebook"
9192 def __init__ (self , path = None , procs = None , nb = None , debug = False , rm_directives = True , process = False ):
@@ -125,7 +126,7 @@ def process(self):
125126 "Process all cells with all processors"
126127 for proc in self .procs : self ._proc (proc )
127128
128- # %% ../nbs/api/03_process.ipynb 35
129+ # %% ../nbs/api/03_process.ipynb 34
129130class Processor :
130131 "Base class for processors"
131132 def __init__ (self , nb ): self .nb = nb
0 commit comments