Markup for Editing with Simple Bracket Notation

Started by DrDave, November 10, 2008, 10:06:28 AM

Previous topic - Next topic

DrDave

I found this an interesting topic that I might be able to actually put to use.



http://humanized.com/weblog/2006/06/30/collaboration_made_simple_with_bracket_notation/">http://humanized.com/weblog/2006/06/30/ ... _notation/">http://humanized.com/weblog/2006/06/30/collaboration_made_simple_with_bracket_notation/


QuoteIt's simply three sets of square brackets. The first set denotes deletion, the second set denotes addition, and the third set denotes a comment.
...it is better to first strive for clarity and correctness and to make programs efficient only if really needed.

\"Getting Started with Erlang\"  version 5.6.2

cormullion

#1
I [like][love][- cormullion monday evening] it! Are you going to write the algorithm for parsing text written thus[?][!][- me again]

DrDave

#2
Quote from: "cormullion"I [like][love][- cormullion monday evening] it! Are you going to write the algorithm for parsing text written thus[?][!][- me again]

LOL. Not [write]
[DrD-MON pm] away. But I'll probably actuall[][y] [ewes][use] it this we[a][e]k.
...it is better to first strive for clarity and correctness and to make programs efficient only if really needed.

\"Getting Started with Erlang\"  version 5.6.2

cormullion

#3
I had a go at writing a function:


(define (ignore) "")

(define (process-bracket-notation str (stet-fn string) (delete-fn ignore) (insert-fn string) (comment-fn ignore))
    (let ((buff "") (prev-char "") (mode 0))
    (dolist (c (explode str))
        (cond   ((= c "[")  (if (= prev-char "]") (inc mode 2) (inc mode))) ; version 10 only :)
                ((= c "]")  (if (= mode 3) (set 'mode 0) (dec mode)))
                (true
                    (if (= prev-char "]") (set 'mode 0))
                    (cond
                        ((= mode 1)
                            (push (apply delete-fn (list c)) buff -1))
                        ((= mode 2)
                            (push (apply insert-fn (list c)) buff -1))
                        ((= mode 3)
                            (push (apply comment-fn (list c)) buff -1))
                        (true
                            (push (apply stet-fn (list c)) buff -1)))))
          (set 'prev-char c))
    buff))



You pass this a string and specify how you want to process it by supplying four functions:


(set 't {
The [silver] quick[-][ ]brow[ed][n] fox jum[][ped] over th[ier][eir][Remember,
I before E, unless after C. Unless the word is weird.] lazy dog. [][][Shouldn't "their" really be "the"?]})

(process-bracket-notation t string ignore string ignore)

;-> The  quick brown fox jumped over their lazy dog.


ie the original (stet) and corrections are output, but deletions and comments aren't. Or:


(set 'comments "")
(process-bracket-notation t string ignore string (fn (c) (push c comments -1) ""))
;-> The  quick brown fox jumped over their lazy dog.

comments
;-> Remember, I before E,
unless after C. Unless the word is weird.Shouldn't "their" really be "the"?


It wouldn't be too hard to write a newLISP-GS thing that shows the different parts using HTML tags.