Skip to content

Commit

Permalink
拡張子ミスのような不正な内部リンクが検出されていなかったのを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
faithandbrave committed Jan 16, 2023
1 parent 53c9bf6 commit a0a65d9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
46 changes: 35 additions & 11 deletions .github/workflows/script/link_check.py
Expand Up @@ -44,7 +44,13 @@ def fix_link(link: str) -> str:
link = link + ")"
return re.sub("#.*", "", link.strip())
else:
return ""
if not link:
return ""

if link.startswith("#"):
return ""

return link

IGNORE_LIST = [
"https://web.archive.org", # 確実に存在すると思われる
Expand Down Expand Up @@ -72,17 +78,35 @@ def add_link(origin_link: str):
else:
inner_links.append(link)

for m in re.finditer(r'\[(.*?)\]\((.*?)\)', text):
link = m.group(2)
if '(' in link:
index = text.find(')', m.end(0))
after_link = text[m.start(2):index]
add_link(after_link)
else:
add_link(link)
in_code_block = False
for line in text.split("\n"):
# コードブロックのなかは、チェックしない
is_code_block = line.strip().startswith("```")
if is_code_block:
in_code_block = not in_code_block
continue

if in_code_block:
continue

for m in re.finditer(r'\[(.*?)\]\((.*?)\)', line):
pretext = line[0:m.start(0)]
# コード修飾のなかは、チェックしない
incode = pretext.count("`")
if pretext.count("`") % 2 != 0:
continue

link = m.group(2)
if '(' in link:
index = line.find(')', m.end(0))
after_link = line[m.start(2):index]
add_link(after_link)
else:
add_link(link)

for m in re.finditer(r'[\*-] (.*?)\[link (.*?)\]', text):
add_link(m.group(2))
for line in text.split("\n"):
for m in re.finditer(r'[\*-] (.*?)\[link (.*?)\]', line):
add_link(m.group(2))

return inner_links, outer_links

Expand Down
2 changes: 1 addition & 1 deletion reference/string/basic_string/substr.md
Expand Up @@ -48,7 +48,7 @@ constexpr basic_string
## 備考
C++23から(2)[右辺値修飾オーバーロード](/lang/cpp11/ref_qualifier_for_this)の追加にともない、従来からある(1)はconst左辺値参照オーバーロードに変更される。
C++23から(2)[右辺値修飾オーバーロード](/lang/cpp11/ref_qualifier_for_this.md)の追加にともない、従来からある(1)はconst左辺値参照オーバーロードに変更される。
同時にメンバ関数`substr`のライブラリ仕様記述は、新たに追加された`basic_string`コンストラクタを用いて書き直されるものの、基本的な動作はC++20までと同一である。
Expand Down
2 changes: 1 addition & 1 deletion reference/string_view/basic_string_view/op_constructor.md
Expand Up @@ -82,7 +82,7 @@ snprintf(buf, sizeof(buf), "abc");
string_view str(buf);
```

- ヌル文字を含む文字列リテラル全体から`basic_string_view`を構築したい場合は[`std::string_view_literals::svリテラル`](op_sv.html)を用いる。
- ヌル文字を含む文字列リテラル全体から`basic_string_view`を構築したい場合は[`std::string_view_literals::svリテラル`](op_sv.md)を用いる。


##
Expand Down
2 changes: 1 addition & 1 deletion start_editing/page_names.md
Expand Up @@ -88,4 +88,4 @@ C++にはこの表に含まれない演算子もいくつかあるが、ここ


## その他、例外的なページファイル名
- [`std::_Exit()`](/reference/cstdlib/exit_.html)は、ページファイル名を先頭アンダースコアしたところ、Chromeブラウザで404 Page Not Foundとなったため、回避策として末尾にアンダースコアを付けている
- [`std::_Exit()`](/reference/cstdlib/exit_.md)は、ページファイル名を先頭アンダースコアしたところ、Chromeブラウザで404 Page Not Foundとなったため、回避策として末尾にアンダースコアを付けている

0 comments on commit a0a65d9

Please sign in to comment.