advanced-code.org

Turns out there’s more way to do code than just BEGIN_EXAMPLE.

# 1 Inline examples

This should work:

      fixed width? how does this work?
                            ...........
                           ............
                                      .
                           .  .   .   .
                           .          ..
                           ....... .....
                               .  .
                               ....

Two ASCII blobs.

# 2 BEGIN_SRC

And this:

    # Finds all emphasis matches in a string.
    # Supply a block that will get the marker and body as parameters.
    def match_all(str)
      str.scan(@org_emphasis_regexp) do |match|
        yield $2, $3
      end
    end

Now let’s test case-insensitive code blocks.

    # Finds all emphasis matches in a string.
    # Supply a block that will get the marker and body as parameters.
    def match_all(str)
      str.scan(@org_emphasis_regexp) do |match|
        yield $2, $3
      end
    end

    (def fib-seq
      (concat
       [0 1]
       ((fn rfib [a b]
            (lazy-cons (+ a b) (rfib b (+ a b)))) 0 1)))

    user> (take 20 fib-seq)
    (0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181)

Even if no language is set, it is still wrapped in code tags but class is empty.

    echo 'Defaults env_keeps="http_proxy https_proxy ftp_proxy"' | sudo tee -a /etc/sudoers

# 3 It should be possible to write a colon at the beginning of an example

> I really love to write about :symbols. They sure are the best things in the world!

    {
    :one => 1,
    :two => 2
    }

    (defproject helloworld "0.1"
    :dependencies [[org.clojure/clojure
                     "1.1.0-master-SNAPSHOT"]
                  [org.clojure/clojure-contrib
                     "1.0-SNAPSHOT"]]
    :main helloworld)