GitHubのミラーです
https://github.com/Hayao0819/hayao.fascode.net
Révision | e16691e3587524fa23775e851dad3041a5acd6d3 (tree) |
---|---|
l'heure | 2022-02-02 21:48:25 |
Auteur | Hayao0819 <Hayao0819@user...> |
Commiter | Hayao0819 |
deploy: 4b2771f06cd79de69cfdbd83f96f066cdca10802
@@ -2,6 +2,7 @@ import os | ||
2 | 2 | import ui |
3 | 3 | import time |
4 | 4 | import strconv as strc |
5 | +import regex | |
5 | 6 | //import eventbus |
6 | 7 | |
7 | 8 | const ( |
@@ -137,6 +138,28 @@ fn create_article(url string, title string){ | ||
137 | 138 | ui.message_box(result.output) |
138 | 139 | } |
139 | 140 | |
141 | + mut re := regex.regex_opt('^title: ".*"$') or {return} | |
142 | + mut path := os.resource_abs_path("./src/content/${filename}") | |
143 | + println(path) | |
144 | + mut article_md := os.read_lines(path) or { | |
145 | + ui.message_box("Failed to open \"$path\"") | |
146 | + return | |
147 | + //exit(1) | |
148 | + } | |
149 | + | |
150 | + for cnt,line in article_md{ | |
151 | + if re.matches_string(line){ | |
152 | + eprintln("書き換え対象を${cnt}行目に発見") | |
153 | + article_md[cnt] = re.replace(line, 'title: "$title"') | |
154 | + eprintln("${line} ==> title: \"$title\"") | |
155 | + break | |
156 | + } | |
157 | + } | |
158 | + | |
159 | + os.write_file(path, article_md.join("\n")) or { | |
160 | + ui.message_box("Failed to write to $path") | |
161 | + } | |
162 | + | |
140 | 163 | exit(0) |
141 | 164 | } |
142 | 165 |