Answer Use Org-mode Code Blocks to Convert from a String to List of Checkboxes in Multiple Languages
Wrap your list inside a named dynamic block
Lec 1 | 1:20:36
Lec 2 | 1:10:32
Lec 3 | 1:08:33
Lec 4 | 1:20:33
... More ...
Lec 24 | 1:24:47
Lec 25 | 1:25:21
Write or find an org-mode code block in your favorite programming language.
Example 1 - Using an elisp
Code Block
(dolist (x (split-string data " \n " ))
(princ (format " [ ] %s \n " x)))
- [ ] Lec 1 | 1:20:36
- [ ] Lec 2 | 1:10:32
- [ ] Lec 3 | 1:08:33
- [ ] Lec 4 | 1:20:33
- [ ] … More …
- [ ] Lec 24 | 1:24:47
- [ ] Lec 25 | 1:25:21
Example 2 - Using a perl
Code Block
map { printf qq( [ ] %s \n ) , $_ } split (/ \n / , $data );
- [ ] Lec 1 | 1:20:36
- [ ] Lec 2 | 1:10:32
- [ ] Lec 3 | 1:08:33
- [ ] Lec 4 | 1:20:33
- [ ] … More …
- [ ] Lec 24 | 1:24:47
- [ ] Lec 25 | 1:25:21
Example 3 - Using a bash
Code Block
while IFS='
' read -ra ADDR; do
for i in " ${ADDR[@]} " ; do
echo " [X] $i "
done
done <<< " $data"
- [X] Lec 1 | 1:20:36
- [X] Lec 2 | 1:10:32
- [X] Lec 3 | 1:08:33
- [X] Lec 4 | 1:20:33
- [X] … More …
- [X] Lec 24 | 1:24:47
- [X] Lec 25 | 1:25:21
Example 4 - Using a python
Code Block
l = ["[ ] {x}" .format (x = row ) for row in data .splitlines ()]
for i in l : print i
- [ ] Lec 1 | 1:20:36
- [ ] Lec 2 | 1:10:32
- [ ] Lec 3 | 1:08:33
- [ ] Lec 4 | 1:20:33
- [ ] … More …
- [ ] Lec 24 | 1:24:47
- [ ] Lec 25 | 1:25:21
Example 5 - Using a ruby
Code Block
for l in data . split ( "\n " )
puts "[ ] #{ l } "
end
- [ ] Lec 1 | 1:20:36
- [ ] Lec 2 | 1:10:32
- [ ] Lec 3 | 1:08:33
- [ ] Lec 4 | 1:20:33
- [ ] … More …
- [ ] Lec 24 | 1:24:47
- [ ] Lec 25 | 1:25:21