You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dzmitry Malyshau edited this page Jun 1, 2018
·
1 revision
The old notes were archived on Google Docs. Process of converting them consists of 2 steps:
Download as "*.txt"
Run over this little Rust program:
use std::fs::{create_dir_all,File};use std::io::{stdin,BufRead,BufReader,Write};use std::path::Path;fnmain(){let prefix = "Daily - ";let list_starts = [' ','\t','*','-'];letmut current = File::create("dummy.md").unwrap();letmut in_list = false;for line inBufReader::new(stdin()).lines(){let line = line.unwrap();// Note: the prefix may start *after* the special UTF byte order mark...ifletSome(pos) = line.find(prefix){let path = Path::new(&line[pos + prefix.len() ..]).with_extension("md");let _ = create_dir_all(path.parent().unwrap());
current = File::create(path).unwrap();
in_list = false;}else{if line.starts_with(&list_starts[..]){
in_list = true;}elseif in_list {
in_list = false;// insert an extra newline after the end of listwriteln!(current).unwrap();}writeln!(current,"{}", line).unwrap();}}}