Escriba un org-mode
bloque de código en su lenguaje de programación favorito.
Ejemplo 1 : uso de un elisp
bloque de código
#+name: list-into-checklist-elisp
#+header: :results list raw replace output
#+header: :var data=my-list-block()
#+begin_src elisp
(dolist (x (split-string data "\n"))
(princ (format "[ ] %s\n" x)))
#+end_src
#+RESULTS: list-into-checklist-elisp
- [ ] 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
Ejemplo 2 : uso de un perl
bloque de código
#+name: list-into-checklist-perl
#+header: :results list raw replace output
#+header: :var data=my-list-block()
#+begin_src perl
map { printf qq([ ] %s\n), $_ } split(/\n/, $data);
#+end_src
#+RESULTS: list-into-checklist-perl
- [ ] 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
Ejemplo 3 : uso de un bash
bloque de código
#+name: list-into-checklist-bash
#+header: :results list raw replace output
#+header: :shebang #!/usr/bin/env bash
#+header: :var data=my-list-block()
#+begin_src sh
while IFS="\n" read -ra ADDR; do
for i in "${ADDR[@]}"; do
echo "[X] $i"
done
done <<< "$data"
#+end_src
#+RESULTS: list-into-checklist-bash
- [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
Ejemplo 4 : uso de un python
bloque de código
#+name: list-into-checklist-python
#+header: :results list raw replace output
#+header: :var data=my-list-block()
#+Begin_src python
l = ["[ ] {x}".format(x=row) for row in data.splitlines()]
for i in l: print i
#+end_src
#+RESULTS: list-into-checklist-python
- [ ] 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
Ejemplo 5 : uso de un ruby
bloque de código
#+name: list-into-checklist-ruby
#+header: :results list raw replace output
#+header: :var data=my-list-block()
#+Begin_src ruby
for l in data.split("\n")
puts "[ ] #{l}"
end
#+end_src
#+RESULTS: list-into-checklist-ruby
- [ ] 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
multiple cursors
oquery-search-replace
. Al convertir a la lista de verificación, simplemente quiere anteponer las líneas[ ]
, ¿correcto?