Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be103e1aa0 | ||
|
|
c4c388c036 | ||
|
|
ea91034d84 | ||
|
|
cc893be3d5 | ||
|
|
b6a00ed972 | ||
|
|
a639e5240e |
No files matched your search
@@ -101,12 +101,14 @@ Gewählte Option: „Dateiname ohne `.md`, zusätzlich als einzige `#`-Zeile“.
|
|||||||
* `< > : " / \ | ? * [ ] # ^`,
|
* `< > : " / \ | ? * [ ] # ^`,
|
||||||
* die Folge `%%`,
|
* die Folge `%%`,
|
||||||
* Steuerzeichen sowie U+2028 und U+2029,
|
* Steuerzeichen sowie U+2028 und U+2029,
|
||||||
|
* unsichtbare Formatzeichen (Unicode-Kategorie Cf, etwa U+200B, U+FEFF, Richtungszeichen); erlaubt bleiben die Verbinder U+200C und U+200D, die manche Schriften und Emojis brauchen, und die Tag-Zeichen von Regionalflaggen,
|
||||||
|
* die Endung `.md`, auch in anderer Schreibweise,
|
||||||
* Punkt oder Leerraum am Rand,
|
* Punkt oder Leerraum am Rand,
|
||||||
* Windows-Gerätenamen,
|
* Windows-Gerätenamen,
|
||||||
* ein leerer oder nicht NFC-normalisierter Titel,
|
* ein leerer oder nicht NFC-normalisierter Titel,
|
||||||
* mehr als 252 Bytes UTF-8 (der Dateiname mit `.md` darf 255 Bytes haben).
|
* mehr als 252 Bytes UTF-8 (der Dateiname mit `.md` darf 255 Bytes haben).
|
||||||
|
|
||||||
Das Komma ist erlaubt. Neue Seiten tragen den Titel wörtlich als einzige `#`-Zeile; der Code erzeugt sie aus dem Dateinamen. Die Originalform („Was ist X?“) steht in `aliases`. Gelesen wird tolerant: Eine fehlende oder abweichende `#`-Zeile ist kein Fehler, das meldet später der Lint. Verworfen:
|
Das Komma ist erlaubt. Unsichtbare Zeichen sind verboten, weil zwei Titel sonst gleich aussehen und doch verschieden sind. Die Endung `.md` ist verboten, weil Obsidian `[[README.md]]` als Link auf die Datei `README.md` liest, eine Seite dieses Titels aber `README.md.md` hieße ([Links](https://obsidian.md/help/links)); die Originalform steht dann in `aliases`. Neue Seiten tragen den Titel wörtlich als einzige `#`-Zeile; der Code erzeugt sie aus dem Dateinamen. Die Originalform („Was ist X?“) steht in `aliases`. Gelesen wird tolerant: Eine fehlende oder abweichende `#`-Zeile ist kein Fehler, das meldet später der Lint. Verworfen:
|
||||||
|
|
||||||
* Nur der Dateiname: Außerhalb von Obsidian ist die Seite titellos, und es widerspricht dem [Google-Style-Guide](https://google.github.io/styleguide/docguide/style.html) und [markdownlint MD041](https://github.com/DavidAnson/markdownlint/blob/main/doc/md041.md).
|
* Nur der Dateiname: Außerhalb von Obsidian ist die Seite titellos, und es widerspricht dem [Google-Style-Guide](https://google.github.io/styleguide/docguide/style.html) und [markdownlint MD041](https://github.com/DavidAnson/markdownlint/blob/main/doc/md041.md).
|
||||||
* `title:` im Frontmatter: Obsidian nutzt es weder als Linkziel noch zur Anzeige ([Links](https://obsidian.md/help/links), [Eigenschaften](https://obsidian.md/help/properties)).
|
* `title:` im Frontmatter: Obsidian nutzt es weder als Linkziel noch zur Anzeige ([Links](https://obsidian.md/help/links), [Eigenschaften](https://obsidian.md/help/properties)).
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ _ID_RE = re.compile(r"[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-
|
|||||||
_FORBIDDEN_CHARS = frozenset('<>:"/\\|?*[]#^')
|
_FORBIDDEN_CHARS = frozenset('<>:"/\\|?*[]#^')
|
||||||
_LINE_BREAKS = frozenset("\u2028\u2029")
|
_LINE_BREAKS = frozenset("\u2028\u2029")
|
||||||
_MAX_TITLE_BYTES = 252
|
_MAX_TITLE_BYTES = 252
|
||||||
|
# Invisible format characters (Cf) are forbidden, except the joiners that some
|
||||||
|
# scripts and emoji sequences need and the tag characters of subdivision flags.
|
||||||
|
_ALLOWED_FORMAT = frozenset("\u200c\u200d")
|
||||||
|
_TAGS = range(0xE0020, 0xE0080)
|
||||||
_DEVICE_NAMES = frozenset(
|
_DEVICE_NAMES = frozenset(
|
||||||
{"CON", "PRN", "AUX", "NUL", "CONIN$", "CONOUT$"}
|
{"CON", "PRN", "AUX", "NUL", "CONIN$", "CONOUT$"}
|
||||||
| {f"{name}{digit}" for name in ("COM", "LPT") for digit in "123456789¹²³"}
|
| {f"{name}{digit}" for name in ("COM", "LPT") for digit in "123456789¹²³"}
|
||||||
@@ -39,6 +43,14 @@ class PageTitle:
|
|||||||
raise InvalidTitleError(f"invalid title {self.value!r}: {reason}")
|
raise InvalidTitleError(f"invalid title {self.value!r}: {reason}")
|
||||||
|
|
||||||
|
|
||||||
|
def _invisible(char: str) -> bool:
|
||||||
|
return (
|
||||||
|
unicodedata.category(char) == "Cf"
|
||||||
|
and char not in _ALLOWED_FORMAT
|
||||||
|
and ord(char) not in _TAGS
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _title_problem(title: str) -> str | None:
|
def _title_problem(title: str) -> str | None:
|
||||||
if not title:
|
if not title:
|
||||||
return "empty"
|
return "empty"
|
||||||
@@ -48,6 +60,10 @@ def _title_problem(title: str) -> str | None:
|
|||||||
return "contains a forbidden character"
|
return "contains a forbidden character"
|
||||||
if any(unicodedata.category(c) == "Cc" or c in _LINE_BREAKS for c in title):
|
if any(unicodedata.category(c) == "Cc" or c in _LINE_BREAKS for c in title):
|
||||||
return "contains a control character or line break"
|
return "contains a control character or line break"
|
||||||
|
if any(_invisible(c) for c in title):
|
||||||
|
return "contains an invisible character"
|
||||||
|
if title.casefold().endswith(".md"):
|
||||||
|
return "ends with .md, which Obsidian reads as the file extension"
|
||||||
if title != title.strip() or title.startswith(".") or title.endswith("."):
|
if title != title.strip() or title.startswith(".") or title.endswith("."):
|
||||||
return "starts or ends with whitespace or a dot"
|
return "starts or ends with whitespace or a dot"
|
||||||
if title.split(".", 1)[0].rstrip(" ").upper() in _DEVICE_NAMES:
|
if title.split(".", 1)[0].rstrip(" ").upper() in _DEVICE_NAMES:
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ def test_invalid_id_raises(value: str) -> None:
|
|||||||
"Aux-Plan",
|
"Aux-Plan",
|
||||||
"a.b",
|
"a.b",
|
||||||
"x%y",
|
"x%y",
|
||||||
|
"md",
|
||||||
|
"notes.mdx",
|
||||||
|
"a.md b",
|
||||||
|
"Familie 👨" + chr(0x200D) + "👩",
|
||||||
|
"Mi" + chr(0x200C) + "zan",
|
||||||
|
"🏴" + "".join(chr(0xE0000 + ord(c)) for c in "gbeng") + chr(0xE007F),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_title_with_comma(value: str) -> None:
|
def test_title_with_comma(value: str) -> None:
|
||||||
@@ -96,6 +102,14 @@ def test_title_with_comma(value: str) -> None:
|
|||||||
"a" * 253,
|
"a" * 253,
|
||||||
"ä" * 127,
|
"ä" * 127,
|
||||||
"a\ud800b",
|
"a\ud800b",
|
||||||
|
"README.md",
|
||||||
|
"notes.MD",
|
||||||
|
"x.Md",
|
||||||
|
"a" + chr(0x200B) + "b",
|
||||||
|
chr(0xFEFF) + "a",
|
||||||
|
"a" + chr(0x202E) + "b",
|
||||||
|
"a" + chr(0x00AD) + "b",
|
||||||
|
"a" + chr(0x2060) + "b",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_invalid_title_raises(value: str) -> None:
|
def test_invalid_title_raises(value: str) -> None:
|
||||||
|
|||||||
Reference in new issue
Block a user