Prepare Go diagram text using Quarry

The Quarry application allows users to play Go against computer programs, or view and edit game records. This is my favorite Go application under Linux. The description here is based on version 0.2.0 of Quarry (unfortunately it is no longer in active development).

IMAGE(/go/sites/default/files/field/image/quarry-SL.png)

Quarry contains an option to save its current board positions as Sensei's Library Diagrams, as shown in the screen capture. After selecting that menu item, the generated text would be saved in the system clipboard and can be pasted as below:

$$B $$ +---------------------------------------+ $$ | . . . . . . . . . . . . . . O . . . . | $$ | . . . . . . . . . . . . X O . O O . . | $$ | . . . . . X . O . . . X O . O X X . . | $$ | . . . O . . O . . . . X X O . O X . . | $$ | . . . . . . . X . . . X O O O X . . . | $$ | . . O . . . . . . . . . O X X . X . . | $$ | . . . . . . . X . . . O . O . X X . . | $$ | . . . . . . . . . . . . O X X . O . . | $$ | . . . . . . . . . . . . . O . O . . . | $$ | . . . . . . . . . . . . O X O . O . . | $$ | . . . . . . . . . . . . X X . O O . . | $$ | . . . . . . . . . . . . . . . X . . . | $$ | . . X . . . . . . X . O . . X . X . . | $$ | . . . . O . . . . . . . . . O X O . . | $$ | . . X O . X . . X . O . . . . X X . . | $$ | . . X . . . . . . . . X . X . X . . . | $$ | . . . X O . . 1 X O O . . O X . . . . | $$ | . . O O . . . . O . . . . O . . . . . | $$ | . . . . . . . . . . . . . . . . . . . | $$ +---------------------------------------+

After enclosing the text in the correct tags, this results in the following diagram. Note the text generated by Quarry is not entirely correct as the hoshi (star) points are not handled properly (this can be manually fixed by using commas at the correct locations).