-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
全てのページのサンプルコードの言語指定を拡張記法に置き換える #480
Labels
Comments
これができたら cpprefjp/site_generator#48 |
やります。 |
スクリプトを書いて置き換えました。 def enumerate_recursive_dir(path)
Dir::foreach(path) {|f|
next if f == '.' or f == '..'
if path =~ /\/$/
f = path + f
else
f = path + '/' + f
end
if FileTest::directory?(f)
enumerate_recursive_dir(f) {|nested_file|
yield nested_file
}
else
yield f
end
}
end
def find_example_codes(data)
codes = []
now_pos = 0
while true do
start_pos = data.index("```cpp", now_pos)
if start_pos == nil then
break
end
end_pos = data.index("```", start_pos + 3)
codes << data[start_pos, end_pos - start_pos]
now_pos = end_pos
end
return codes
end
enumerate_recursive_dir('site') {|md_path|
if File.extname(md_path) != ".md"
next
end
data = File.open(md_path).read
new_data = data.clone
find_example_codes(data).each {|code|
if code.index("#include") && code.index("int main(") then
new_code = code.gsub("```cpp", "```cpp example")
new_data.gsub!(code, new_code)
end
}
if data != new_data then
File.write(md_path, new_data)
end
} |
@faithandbrave 対応ありがとうございます。今後このようにスクリプトを利用した大規模な変更を行う場合は、ブランチを切ってself-PRしていただけると助かります。確信は無いのですが恐らくこの変更が原因で全ページのコード実行機能が動かなくなってしまっているので、一時的にrevertしたい時にPRだとやりやすいです。 これは想像ですがバックエンドでは問題なくてkunaiの問題だと思うので、調査しますが少し時間はかかります。 |
あれー、すいません。exampleを付けるのは検証済みだと思っていたので、確認なしでpushしてしまいました。 |
saki7
added a commit
to cpprefjp/kunai
that referenced
this issue
Nov 27, 2017
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#473 が決まったのでまずは現在の記事を全て機械的に置き換える
The text was updated successfully, but these errors were encountered: