MCPcopy Create free account
hub / github.com/917Dhj/DeepPaperNote / _frontmatter_fields

Function _frontmatter_fields

scripts/citation_links.py:149–190  ·  view source on GitHub ↗
(text: str)

Source from the content-addressed store, hash-verified

147
148
149def _frontmatter_fields(text: str) -> dict[str, Any] | None:
150 match = FRONTMATTER_RE.match(text)
151 if not match:
152 return None
153
154 fields: dict[str, Any] = {"aliases": []}
155 lines = match.group(1).splitlines()
156 index = 0
157 while index < len(lines):
158 line = lines[index]
159 stripped = line.strip()
160 key_match = FRONTMATTER_KEY_RE.match(stripped)
161 if not key_match:
162 index += 1
163 continue
164
165 key = key_match.group(1).strip().lower().replace("-", "_")
166 inline_value = key_match.group(2).strip()
167 if key == "aliases":
168 if inline_value:
169 fields["aliases"] = _parse_inline_aliases(inline_value)
170 index += 1
171 continue
172
173 aliases: list[str] = []
174 index += 1
175 while index < len(lines):
176 item = lines[index].strip()
177 if not item.startswith("- "):
178 break
179 alias = _strip_wrapping_quotes(item[2:])
180 if alias:
181 aliases.append(alias)
182 index += 1
183 fields["aliases"] = aliases
184 continue
185
186 if key in {"doi", "arxiv", "arxiv_id", "title"} and inline_value:
187 fields[key] = _strip_wrapping_quotes(inline_value)
188 index += 1
189
190 return fields
191
192
193def _h1_title(text: str) -> str:

Callers 1

build_vault_note_indexFunction · 0.85

Calls 2

_parse_inline_aliasesFunction · 0.85
_strip_wrapping_quotesFunction · 0.85

Tested by

no test coverage detected