Last active
January 27, 2016 15:00
-
-
Save n13i/c3c92f3b2a5ba2860fe6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/nf-pw2md.rb b/nf-pw2md.rb | |
index 11862d4..c5581b2 100755 | |
--- a/nf-pw2md.rb | |
+++ b/nf-pw2md.rb | |
@@ -54,7 +54,8 @@ RE_BLINE_PW = "^-{3}" | |
RE_MAP = {} | |
-RE_MAP[RE_COMMENT_PW] = lambda{|x,y| "<!-- #{x} -->" } | |
+#RE_MAP[RE_COMMENT_PW] = lambda{|x,y| "<!-- #{x} -->" } | |
+RE_MAP[RE_COMMENT_PW] = lambda{|x,y| "" } | |
RE_MAP[RE_NEWLINE_PW] = lambda{|x,y| y.gsub(/~$/, " "*2) } | |
RE_MAP[RE_SEC_PW] = lambda{|x,y| "# #{x}" } | |
diff --git a/pw2hfs.rb b/pw2hfs.rb | |
index 613fea9..f6a8237 100755 | |
--- a/pw2hfs.rb | |
+++ b/pw2hfs.rb | |
@@ -12,7 +12,7 @@ require 'fileutils' | |
SRCDIR = "wiki" | |
DSTDIR = "dst" | |
-SRCCPS = "EUC-JP" | |
+SRCCPS = "UTF-8" | |
DSTCPS = "UTF-8" | |
SRCEXT = ".txt" | |
@@ -51,7 +51,8 @@ end | |
# ex. "q=%A5%D7%A5%EA%A5%AD%A5%E5%A5%A2" (uri query form) | |
# => "プリキュア" (string in EUC-JP) | |
# | |
-def _decode_as_s( uri, kcode=Encoding::EUCJP ) | |
+#def _decode_as_s( uri, kcode=Encoding::EUCJP ) | |
+def _decode_as_s( uri, kcode=Encoding::UTF_8 ) | |
URI.decode_www_form( uri, kcode ).last.last | |
end | |
@@ -68,14 +69,16 @@ end | |
# => "プリキュア" (in UTF-8) | |
# | |
def conv_fn2utf8( fn ) | |
- conv_eucjp2utf8( _decode_as_s( _encode_filename( fn ) ) ) | |
+ #conv_eucjp2utf8( _decode_as_s( _encode_filename( fn ) ) ) | |
+ _decode_as_s( _encode_filename( fn ) ) | |
end | |
# change string in utf-8 to EUC-JP-encoded string. | |
# ex. "プリキュア" (in UTF-8) | |
# => "A5D7A5EAA5ADA5E5A5A2" (EUC-coded string) | |
def conv_utf82fn( s_in_utf8 ) | |
- s_in_utf8.encode('EUC-JP','UTF-8').split(//).map{|c| c.codepoints.map{|cd| sprintf("%X",cd)}}.flatten.join | |
+ #s_in_utf8.encode('EUC-JP','UTF-8').split(//).map{|c| c.codepoints.map{|cd| sprintf("%X",cd)}}.flatten.join | |
+ s_in_utf8.split(//).map{|c| c.codepoints.map{|cd| sprintf("%X",cd)}}.flatten.join | |
end | |
################################################################ | |
@@ -137,16 +140,19 @@ def convert( srcdir = SRCDIR, dstdir = DSTDIR ) | |
if not( newfn ) | |
newfn = dstdir + "/" + tmp + DSTEXT | |
+ newfn_wo_dstdir_and_ext = tmp | |
else | |
newfn = dstdir + "/" + File.dirname( tmp ) + "/" + newfn + DSTEXT | |
+ newfn_wo_dstdir_and_ext = tmp #File.dirname( tmp ) + "/" + newfn | |
end | |
puts " Processing #{newfn}..." | |
#`cp -f #{old} #{newfn}` | |
- `echo "# #{newfn}" > "#{newfn}"` | |
+# `echo "# #{newfn}" > "#{newfn}"` | |
#`iconv -f #{SRCCPS} -t #{DSTCPS} #{old} >> "#{newfn}"` | |
- `iconv -f #{SRCCPS} -t #{DSTCPS} #{old} | ./nf-pw2md.rb >> "#{newfn}"` | |
+ `iconv -f #{SRCCPS} -t #{DSTCPS} #{old} | ./nf-pw2md.rb | ./convlink.pl #{newfn_wo_dstdir_and_ext} > "#{newfn}"` | |
+ `touch --reference="#{old}" "#{newfn}"` | |
puts " Done." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment