From a84908b7e8a0e2423afd6b836eccf27a420270b4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 20 Sep 2023 19:56:52 +0900 Subject: feat(blog/nuldoc): change content format from DocBook to NulDoc --- .../index.html | 4 ++-- .../python-unbound-local-error/index.html | 6 +++--- .../ruby-detect-running-implementation/index.html | 4 ++-- .../ruby-then-keyword-and-case-in/index.html | 24 +++++++++++----------- .../rust-where-are-primitive-types-from/index.html | 12 +++++------ .../index.html | 10 ++++----- .../vim-swap-order-of-selected-lines/index.html | 12 +++++------ 7 files changed, 36 insertions(+), 36 deletions(-) (limited to 'vhosts/blog/public/posts/2021-10-02') diff --git a/vhosts/blog/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html b/vhosts/blog/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html index 75ba6ea9..0954830d 100644 --- a/vhosts/blog/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html +++ b/vhosts/blog/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html @@ -69,7 +69,7 @@ タイトル落ち。まずはこのコードを見て欲しい。

-
#include <iostream>
+          
#include <iostream>
 
 [[alignas]] [[alignof]] [[and]] [[and_eq]] [[asm]] [[auto]] [[bitand]]
 [[bitor]] [[bool]] [[break]] [[case]] [[catch]] [[char]] [[char16_t]]
@@ -132,7 +132,7 @@
              上のコードでは [[using]] をコメントアウトしているが、これは using キーワードのみ属性構文の中で意味を持つからであり、このコメントアウトを外すとコンパイルに失敗する。 
           

-
// using の例
+          
// using の例
 [[using foo: attr1, attr2]] int x; // [[foo::attr1, foo::attr2]] の糖衣構文

diff --git a/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html b/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html index 105b946b..cb6efafb 100644 --- a/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html +++ b/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html @@ -73,7 +73,7 @@ Python でクロージャを作ろうと、次のようなコードを書いた。

-
def f():
+          
def f():
     x = 0
     def g():
         x += 1
@@ -95,7 +95,7 @@ f()
local変数 x が代入前に参照された、とある。これは、fx を参照するのではなく、新しく別の変数を g 内に作ってしまっているため。 前述のコードを宣言と代入を便宜上分けて書き直すと次のようになる。var を変数宣言のための構文として擬似的に利用している。

-
# 注: var は正しい Python の文法ではない。上記参照のこと
+          
# 注: var は正しい Python の文法ではない。上記参照のこと
 def f():
   var x           #  f の local変数 'x' を宣言
   x = 0           #  x に 0 を代入
@@ -110,7 +110,7 @@ f()
当初の意図を表現するには、次のように書けばよい。

-
def f():
+          
def f():
     x = 0
     def g():
         nonlocal x   ## (*)
diff --git a/vhosts/blog/public/posts/2021-10-02/ruby-detect-running-implementation/index.html b/vhosts/blog/public/posts/2021-10-02/ruby-detect-running-implementation/index.html
index d9f9e79f..16b6b0bb 100644
--- a/vhosts/blog/public/posts/2021-10-02/ruby-detect-running-implementation/index.html
+++ b/vhosts/blog/public/posts/2021-10-02/ruby-detect-running-implementation/index.html
@@ -78,7 +78,7 @@
              上記ページの例から引用する: 
           

-
$ ruby-1.9.1 -ve 'p RUBY_ENGINE'
+          
$ ruby-1.9.1 -ve 'p RUBY_ENGINE'
 ruby 1.9.1p0 (2009-03-04 revision 22762) [x86_64-linux]
 "ruby"
 $ jruby -ve 'p RUBY_ENGINE'
@@ -203,7 +203,7 @@ jruby 1.2.0 (ruby 1.8.6 patchlevel 287) (2009-03-16 rev 9419) [i386-java]
             mruby 該当部分のソース より引用: 
           

-
/*
+          
/*
 * Ruby engine.
 */
 #define MRUBY_RUBY_ENGINE  "mruby"
diff --git a/vhosts/blog/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html b/vhosts/blog/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html index fcd653e2..a483ee73 100644 --- a/vhosts/blog/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html +++ b/vhosts/blog/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html @@ -78,7 +78,7 @@ 使われることは稀だが、Ruby では then がキーワードになっている。次のように使う:

-
if cond then
+            
if cond then
   puts "Y"
 else
   puts "N"
@@ -88,7 +88,7 @@
                このキーワードが現れうる場所はいくつかあり、ifunlessrescuecase 構文がそれに当たる。 上記のように、何か条件を書いた後 then を置き、式がそこで終了していることを示すマーカーとして機能する。 
             

-
# Example:
+            
# Example:
 
 if x then
   a
@@ -116,13 +116,13 @@
                普通 Ruby のコードで then を書くことはない。なぜか。次のコードを実行してみるとわかる。 
             

-
if true puts 'Hello, World!' end
+
if true puts 'Hello, World!' end

次のような構文エラーが出力される。

-
20:1: syntax error, unexpected local variable or method, expecting `then' or ';' or '\n'
+            
20:1: syntax error, unexpected local variable or method, expecting `then' or ';' or '\n'
 if true puts 'Hello, World!' end
         ^~~~
 20:1: syntax error, unexpected `end', expecting end-of-input
@@ -136,7 +136,7 @@ if true puts 'Hello, World!' end
                ポイントは改行が then (や ;) の代わりとなることである。true の後に改行を入れてみる。 
             

-
if true
+            
if true
 puts 'Hello, World!' end

@@ -150,18 +150,18 @@ puts 'Hello, World!' if a b end

+
if a b end

then; も改行もないのでエラーになるが、これは条件式がどこまで続いているのかわからないためだ。 この例は二通りに解釈できる。

-
# a という変数かメソッドの評価結果が truthy なら b という変数かメソッドを評価
+            
# a という変数かメソッドの評価結果が truthy なら b という変数かメソッドを評価
 if a then
 b
 end
-
# a というメソッドに b という変数かメソッドの評価結果を渡して呼び出し、
+            
# a というメソッドに b という変数かメソッドの評価結果を渡して呼び出し、
 # その結果が truthy なら何もしない
 if a(b) then
 end
@@ -185,7 +185,7 @@ b https://github.com/ruby/ruby/blob/221ca0f8281d39f0dfdfe13b2448875384bbf735/parse.y#L3961-L3986

-
p_case_body : keyword_in
+            
p_case_body : keyword_in
 {
   SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
   p->command_start = FALSE;
@@ -216,7 +216,7 @@ p_cases
                簡略版: 
             

-
p_case_body : keyword_in p_top_expr then compstmt p_cases
+            
p_case_body : keyword_in p_top_expr then compstmt p_cases
 ;

@@ -227,7 +227,7 @@ p_cases これにより、case - when による従来の構文と同じように、then 等をパターンの後ろに挿入すればよいことがわかった。つまり次の3通りのいずれかになる:

-
case x
+            
case x
 in 1 then a
 in 2 then b
 in 3 then c
@@ -252,7 +252,7 @@ p_cases
                ところで、p_top_expr には if による guard clause が書けるので、その場合は if - then と似たような見た目になる。 
             

-
case x
+            
case x
 in 0 then a
 in n if n < 0 then b
 in n then c
diff --git a/vhosts/blog/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html b/vhosts/blog/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html
index 7509e3a0..063f4f42 100644
--- a/vhosts/blog/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html
+++ b/vhosts/blog/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html
@@ -68,7 +68,7 @@
                Rust において、プリミティブ型の名前は予約語でない。したがって、次のコードは合法である。 
             

-
#![allow(non_camel_case_types)]
+            
#![allow(non_camel_case_types)]
 #![allow(dead_code)]
 
 struct bool;
@@ -122,7 +122,7 @@
               rustc はセルフホストされている (= rustc 自身が Rust で書かれている) ので、boolchar などで適当に検索をかけてもノイズが多すぎて話にならない。 しかし、お誂え向きなことに i128/u128 というコンパイラ自身が使うことがなさそうな型が存在するのでこれを使って git grep してみる。 
             

-
$ git grep "\bi128\b" | wc      # i128
+            
$ git grep "\bi128\b" | wc      # i128
 165    1069   15790
 
 $ git grep "\bu128\b" | wc      # u128
@@ -135,7 +135,7 @@ $ git grep "\bbool\b" | wc      # cf. bool の結果
                165 程度であれば探すことができそうだ。今回は、クレート名を見ておおよその当たりをつけた。 
             

-
$ git grep "\bi128\b"
+            
$ git grep "\bi128\b"
 ...
 rustc_resolve/src/lib.rs:        table.insert(sym::i128, Int(IntTy::I128));
 ...
@@ -144,7 +144,7 @@ rustc_resolve/src/lib.rs: table.insert(sym::i128, Int(IntTy::I128)); rustc_resolve というのはいかにも名前解決を担いそうなクレート名である。該当箇所を見てみる。

-
/// Interns the names of the primitive types.
+            
/// Interns the names of the primitive types.
 ///
 /// All other types are defined somewhere and possibly imported, but the primitive ones need
 /// special handling, since they have no place of origin.
@@ -191,7 +191,7 @@ rustc_resolve/src/lib.rs:        table.insert(sym::i128, Int(IntTy::I128));
                とある。次はこの struct の使用箇所を追う。追うと言っても使われている箇所は次の一箇所しかない。なお説明に不要な箇所は大きく削っている。 
             

-
/// This resolves the identifier `ident` in the namespace `ns` in the current lexical scope.
+            
/// This resolves the identifier `ident` in the namespace `ns` in the current lexical scope.
 /// (略)
 fn resolve_ident_in_lexical_scope(
     &mut self,
@@ -229,7 +229,7 @@ rustc_resolve/src/lib.rs:        table.insert(sym::i128, Int(IntTy::I128));
                動作がわかったところで、例として次のコードを考える。 
             

-
#![allow(non_camel_case_types)]
+            
#![allow(non_camel_case_types)]
 
 struct bool;
 
diff --git a/vhosts/blog/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html b/vhosts/blog/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html
index ea874004..69e28ce1 100644
--- a/vhosts/blog/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html
+++ b/vhosts/blog/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html
@@ -119,14 +119,14 @@
                 https://github.com/vim/vim/blob/8e6be34338f13a6a625f19bcef82019c9adc65f2/src/autocmd.c#L85-L86
               

-
{"BufAdd",      EVENT_BUFADD},
+              
{"BufAdd",      EVENT_BUFADD},
 {"BufCreate",   EVENT_BUFADD},

https://github.com/vim/vim/blob/8e6be34338f13a6a625f19bcef82019c9adc65f2/src/autocmd.c#L95-L97

-
{"BufRead",     EVENT_BUFREADPOST},
+              
{"BufRead",     EVENT_BUFREADPOST},
 {"BufReadCmd",  EVENT_BUFREADCMD},
 {"BufReadPost", EVENT_BUFREADPOST},
@@ -134,7 +134,7 @@ https://github.com/vim/vim/blob/8e6be34338f13a6a625f19bcef82019c9adc65f2/src/autocmd.c#L103-L105

-
{"BufWrite",    EVENT_BUFWRITEPRE},
+              
{"BufWrite",    EVENT_BUFWRITEPRE},
 {"BufWritePost",    EVENT_BUFWRITEPOST},
 {"BufWritePre", EVENT_BUFWRITEPRE},
@@ -149,7 +149,7 @@ https://github.com/neovim/neovim/blob/71d4f5851f068eeb432af34850dddda8cc1c71e3/src/nvim/auevents.lua#L119-L124

-
aliases = {
+              
aliases = {
 BufCreate = 'BufAdd',
 BufRead = 'BufReadPost',
 BufWrite = 'BufWritePre',
@@ -160,7 +160,7 @@ FileEncoding = 'EncodingChanged',
                  ところで、上では取り上げなかった FileEncoding だが、これは :help FileEncoding にしっかりと書いてある。 
               

-
                                                              *FileEncoding*
+              
                                                              *FileEncoding*
 FileEncoding                    Obsolete.  It still works and is equivalent
                                 to |EncodingChanged|.
diff --git a/vhosts/blog/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html b/vhosts/blog/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html index 9ca04808..deb55b48 100644 --- a/vhosts/blog/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html +++ b/vhosts/blog/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html @@ -64,7 +64,7 @@

TL; DR

-
" License: Public Domain
+            
" License: Public Domain
 
 command! -bar -range=%
     \ Reverse
@@ -137,7 +137,7 @@ command! -bar -range=%
                  なお、:g/^/m0 は全ての行を入れ替えるが、:N,Mg/^/mN-1 とすることで N行目から M行目を処理範囲とするよう拡張できる。手でこれを入力するわけにはいかないので、次のようなコマンドを用意する。 
               

-
command! -bar -range=%
+              
command! -bar -range=%
     \ Reverse
     \ <line1>,<line2>g/^/m<line1>-1
@@ -172,7 +172,7 @@ command! -bar -range=% 前述した :Reverse コマンドの定義を少し変えて、次のようにする:

-
function! s:reverse_lines(from, to) abort
+            
function! s:reverse_lines(from, to) abort
     execute printf("%d,%dg/^/m%d", a:from, a:to, a:from - 1)
 endfunction
 
@@ -198,7 +198,7 @@ command! -bar -range=%
               

- Autocommands do not change the current search patterns. Vim saves the current search patterns before executing autocommands then restores them after the autocommands finish. This means that autocommands do not affect the strings highlighted with the `hlsearch' option. + Autocommands do not change the current search patterns. Vim saves the current search patterns before executing autocommands then restores them after the autocommands finish. This means that autocommands do not affect the strings highlighted with the `hlsearch' option.

@@ -212,7 +212,7 @@ command! -bar -range=%

- (略) This command doesn’t work in an autocommand, because the highlighting state is saved and restored when executing autocommands |autocmd-searchpat|. Same thing for when invoking a user function. + (略) This command doesn’t work in an autocommand, because the highlighting state is saved and restored when executing autocommands |autocmd-searchpat|. Same thing for when invoking a user function.

@@ -229,7 +229,7 @@ command! -bar -range=%

-
command! -bar -range=%
+            
command! -bar -range=%
     \ Reverse
     \ keeppatterns <line1>,<line2>g/^/m<line1>-1
-- cgit v1.2.3-70-g09d2