Skip to content

Latest commit

 

History

History
93 lines (87 loc) · 2.67 KB

rectangle-editing.md

File metadata and controls

93 lines (87 loc) · 2.67 KB

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.

  1. 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
  1. 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
  1. 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] &#x2026; More &#x2026;
    -   [X] Lec 24 |        1:24:47
    -   [X] Lec 25 |        1:25:21
  1. 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
    -   [ ] &#x2026; More &#x2026;
    -   [ ] Lec 24 |        1:24:47
    -   [ ] Lec 25 |        1:25:21
  1. 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
    -   [ ] &#x2026; More &#x2026;
    -   [ ] Lec 24 |        1:24:47
    -   [ ] Lec 25 |        1:25:21