s4

changeset 843:a0dcf6477310

Add markdown conversion of <ol>
author HIROSE Yuuji <yuuji@gentei.org>
date Fri, 26 Jun 2020 09:25:42 +0900
parents de2ef47143a0
children ab4f89043f23
files examples/common/default/default.css s4-blog.sh s4-funcs.sh
diffstat 3 files changed, 36 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/examples/common/default/default.css	Fri Jun 26 08:42:42 2020 +0900
     1.2 +++ b/examples/common/default/default.css	Fri Jun 26 09:25:42 2020 +0900
     1.3 @@ -108,9 +108,11 @@
     1.4      white-space: pre-wrap;
     1.5  }
     1.6  table.bloghead tr.preface td ul,
     1.7 +table.bloghead tr.preface td ol,
     1.8  table.blog_replies video,
     1.9  table.blog_replies iframe,
    1.10 -table.blog_replies ul, .blog_replies tr ul, .blog_replies td ul {
    1.11 +table.blog_replies ul, .blog_replies tr ul, .blog_replies td ul,
    1.12 +table.blog_replies ol, .blog_replies tr ol, .blog_replies td ol {
    1.13      text-align: left; white-space: normal; margin: 1ex 0;
    1.14  }
    1.15  table.blog_replies p.proficon {
     2.1 --- a/s4-blog.sh	Fri Jun 26 08:42:42 2020 +0900
     2.2 +++ b/s4-blog.sh	Fri Jun 26 09:25:42 2020 +0900
     2.3 @@ -548,9 +548,11 @@
     2.4  	$cachefile
     2.5    done
     2.6    
     2.7 -  help="=== コメントに使用できる特殊記法 ===
     2.8 +  help="=== コメントに使用できる特殊記法(記号は全て半角) ===
     2.9  行頭に href=URL でURLへのリンク
    2.10  行頭に iframe=URL でURL先を開く iframe
    2.11 +行頭「* 」で箇条書、次の行頭空白で継続、行頭詰めると箇条書終わり
    2.12 +行頭「1. 」で番号付、2行目以降も「1. 」で勝手に番号増える、行頭詰めで終わり
    2.13  [[#記事番号]] でs4内の記事番号に飛ぶリンク
    2.14  [[#検索キーワード]] でs4内の記事検索(記号はいくつか使えない)
    2.15  [[URL]] でURLへのリンク、        [[URL|文字列]]でアンカー文字列指定
     3.1 --- a/s4-funcs.sh	Fri Jun 26 08:42:42 2020 +0900
     3.2 +++ b/s4-funcs.sh	Fri Jun 26 09:25:42 2020 +0900
     3.3 @@ -696,6 +696,36 @@
     3.4  	  s/^\n/<li>/; s,$,</li></ul>,;	# 箇条書を書き切って終わり
     3.5  	  H; x
     3.6  	}
     3.7 +	x' | miniol
     3.8 +}
     3.9 +miniol() {
    3.10 +  sed -Ee '
    3.11 +	/^[1-9]\. / {;			# 行頭 "N. "
    3.12 +	 x; s,^,<ol>,; x;		# 1週目: ホールドスペース先頭に <ol> を
    3.13 +	:top
    3.14 +	 s/\n//;
    3.15 +	 s/^  *//;			# 2周目以降: 行頭空白削除
    3.16 +	 s,[1-9][0-9]*\. ,,;			# まず行頭の "* " を消しておく
    3.17 +	 H;				# 置き換え結果をホールドスペースに追加
    3.18 +	 s/.*//;			# パターンスペースは消しておく
    3.19 +	 # ↓最終行なら残ったホールドスペース処理のため :cont へ
    3.20 +	 $ b cont
    3.21 +	 N;				# 次の行を読む
    3.22 +	 s/\n//;			# 空白始まりは継続行
    3.23 +	 /^ /b top
    3.24 +	 x; s/\n/<li>/; s,$,</li>,;	# 継続行でなければ <li></li> で囲む
    3.25 +	 p; s/.*//;
    3.26 +	 x;				# 次も "* " ならループを抜けない
    3.27 +	 /^[1-9][0-9]*\. /b top
    3.28 +	 s,^,</ol>,;			# 次が一般行なら箇条書終わり
    3.29 +	}
    3.30 +
    3.31 +	:cont
    3.32 +	x;				# 行頭| 以外の行:
    3.33 +	/./ {;				# ホールドスペースに文字列があれば
    3.34 +	  s/^\n/<li>/; s,$,</li></ol>,;	# 箇条書を書き切って終わり
    3.35 +	  H; x
    3.36 +	}
    3.37  	x'
    3.38  }
    3.39  acclog() (