Page 2 of 2

Re: Beautiful SGF indentation

Posted: Mon Mar 09, 2015 1:01 pm
by anazawa
[off topic]

SGF representaion of HTML:

Code: Select all

(
  ;FF[4]                  <-- required
   HTML[lang:en]          <-- Compose type
  (
    ;HEAD[]               <-- None
    (
      ;META[charset:utf8] <-- Compose type
    )
    (
      ;TITLE[]            <-- None
       C[Not Found]
    )
    (
      ;SCRIPT[type:text/javascript]
       C[function sum (a, b) {
  return a + b;
}
]
    )
  )
  (
    ;BODY[]
    (
      ;HI[]               <-- H1 is illegal
       C[Not Found]
    )
    (
      ;P[class:text-muted]
       C[The requested URL was not found on this server.]
    )
  )
)

How should I handle "<p>foo<br>bar</p>"?

[/off topic]

Re: Beautiful SGF indentation

Posted: Wed Mar 11, 2015 4:07 am
by anazawa
@Bantari

Thanks for your kind words :)
I was thinking about the use cases of SGF files:

1. A SGF file that is transferred by HTTP and opened by MultiGo or something via web browsers
2. A SGF file that is opened by CUI viewers such as less/more to debug
3. A SGF file that is attached to email and sent to his/her friends/students/teachers
4. A SGF file that is bundled by SGF applications such as SmartGo
5. A SGF file that is generated by SGF editors such as MultiGo, CGoban or SmartGo
...

I may be missing something, though.

It seems a SGF indentation is not required in most cases. Like you said,
even when I'm debugging SGF generators, the indentation has to make sense to only me
if I'm developing the software alone.

Anyway, thinking about a SGF indentation is fun at least for me
because it's not a binary format but text one. We are allowed to think about
how to indent the SGF file. In addition, I don't want to invent the styles
whenever I debug the generator, but rather choose one of them.

Re: Beautiful SGF indentation

Posted: Wed Mar 11, 2015 4:39 am
by anazawa
KGS (CGoban) style:

Code: Select all

(;GM[1]FF[4]CA[UTF-8]AP[CGoban:3]ST[2]
RU[Japanese]SZ[19]KM[6.50]TM[0]OT[80x10 byo-yomi]
PW[foo]PW[bar]WR[6d]BR[6d]DR[2015-02-26]PC[The KGS Go Server at http://www.gogks.com/]RE[B+Resign]
;B[pd]BL[10]OB[80]C[foo [6d\]: hi
bar [6d\]: hi
]
;W[qp]WL[10]OW[80]
...
)


Line 1: Root properties that summarizes the SGF file itself
Line 2: Rules of the game (a part of gameinfo properties)
Line 3: Player name/rank, date, place, game result, etc. (the rest of gameinfo properties?)
Line 4-: The main line of play

- one node per line except for the root node
- no indentation