(self, full: bool = True)
| 22 | self.read(full=full) |
| 23 | |
| 24 | def read(self, full: bool = True): |
| 25 | try: |
| 26 | self.title = ' ' + os.path.basename(self.fn).replace('.md', '').replace('-', ' ') + ' ' |
| 27 | self.mtime = int(os.path.getmtime(self.fn)) |
| 28 | with open(self.fn, 'r', encoding='utf-8') as f: |
| 29 | content = f.read() |
| 30 | self.size = len(content) |
| 31 | self.lines = [line.strip().lower() + ' ' for line in content.splitlines() if len(line)>1] |
| 32 | self.h1 = [line[1:] for line in self.lines if line.startswith('# ')] |
| 33 | self.h2 = [line[2:] for line in self.lines if line.startswith('## ')] |
| 34 | self.h3 = [line[3:] for line in self.lines if line.startswith('### ')] |
| 35 | if not full: |
| 36 | self.lines.clear() |
| 37 | except Exception as e: |
| 38 | log.error(f'Wiki: page="{self.fn}" {e}') |
| 39 | |
| 40 | def search(self, text): |
| 41 | if not text or len(text) < 2: |
no test coverage detected