今回はCSSについて・・・と見せてWordPressカスタマイズの記事です。
ホームページやブログでAA(アスキーアート)が崩れてしまうことがあります。
以下は修正方法です。
まず、適切なCSSを設定してフォントや文字幅などを調整します。
1 | font-family : IPAMonaPGothic, 'MS Pゴシック' , sans-serif ; |
2 | font-size : 16px ; |
3 | line-height : 18px ; |
大抵はこれで表示がうまくいくのですが、
WordPressには半角のダブルクォーテーションを自動で変換してくれる機能があり
これが悪さしてAAが崩れてしまうことがあったりします。
例)

これを修正するには
wp-includesディレクトリ内にある「formatting.php」を修正します。
(修正は自己責任で)
置換しているあたりをコメントアウト
01 | // Only call _wptexturize_pushpop_element if first char is correct tag opening |
02 | $first = $curl [0]; |
03 | if ( '<' === $first ) { |
04 | _wptexturize_pushpop_element( $curl , $no_texturize_tags_stack , $no_texturize_tags , '<' , '>' ); |
05 | } elseif ( '[' === $first ) { |
06 | _wptexturize_pushpop_element( $curl , $no_texturize_shortcodes_stack , $no_texturize_shortcodes , '[' , ']' ); |
07 | } elseif ( empty ( $no_texturize_shortcodes_stack ) && empty ( $no_texturize_tags_stack ) ) { |
08 | // This is not a tag, nor is the texturization disabled static strings |
09 | $curl = str_replace ( $static_characters , $static_replacements , $curl ); |
10 | // regular expressions |
11 | //$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); |
12 | } |
13 | $curl = preg_replace( '/&([^#])(?![a-zA-Z1-4]{1,8};)/' , '&$1' , $curl ); |
14 | } |
15 | return implode( '' , $textarr ); |
16 | } |
これで綺麗にAAが表示されましす。やったね(^ω^)
_,,....,,_
-''":::::::::::::`''-、
ヽ::::::::::::::::::::::::::::ヽ
|::::::;ノ´ ̄\:::::::::::\_,. -‐ァ __ _____ ______
|::::ノ ヽ、ヽr-r'"´ (.__ ,´ _,, '-´ ̄ ̄`-ゝ 、_ イ、
_,.!イ_ _,.ヘーァ'二ハ二ヽ、へ,_7 'r ´ ヽ、ン、
_..,,-":::::rー''7コ-‐'"´ ; ', `ヽ/`7 ,'==─- -─==', i
"-..,,_r-'ァ'"´/ /! ハ ハ ! iヾ_ノ i イ iゝ、イ人レ/_ルヽイ i |
`!イ´ ,' | /__,.!/ V 、!__ハ ,' ,ゝ レリイi (ヒ_] ヒ_ン ).| .|、i .||
`! !/レi' (ヒ_] ヒ_ン レ'i ノ !Y!"" ,___, "" 「 !ノ i |
,' ノ !'" ,___, "' i .レ' .L.',. ヽ _ン L」 ノ| .|
ノノ ( ,ハ. ヽ _ン 人! | ||ヽ、 ,イ| ||イ| /
( ,.ヘ ,)、 )>,、 _____, ,.イ ハ レ ル` ー--─ ´ルレ レ´