Skip to content

Commit

Permalink
Support Black/White (.) labels for lower case letters.
Browse files Browse the repository at this point in the history
Partially addresses: issues/45
  • Loading branch information
artasparks committed Oct 9, 2015
1 parent eb1c208 commit 0879123
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 27 deletions.
Expand Up @@ -320,7 +320,7 @@ http://gogameguru.com/])
;B[om]
;W[ql]
;B[iq]
;W[rl]C[Black can't answer this ko threat, and]
;W[rl]C[White (a) is devastating -- Black can't answer this ko threat, and]
;B[ep]
;W[sk]C[White's winning by about 10 points. ]))
(;B[fq]LB[io:B][dp:C][fp:A][cq:D]C[Black should have played here instead. A is sente (because it aims to play B), so black can attach at C or D later. This way would have been more complicated than the game. Since black's already losing, he should look for a way to complicate things.])
Expand Down
Binary file modified examples/game_commentary/game_commentary.pdf
Binary file not shown.
16 changes: 8 additions & 8 deletions examples/game_commentary/game_commentary.tex
Expand Up @@ -8261,7 +8261,7 @@ \chapter{The Losing Move}
\gofigure
\subtext{(Moves: 132-135)}

\subtext{{\raisebox{-.17em}{\textnormal{{\gnoswi\char34}}}} at {\raisebox{-.17em}{\textnormal{\gnosOverlap{@}{\color{white}\small{a}}}}}.}
\subtext{{\raisebox{-.17em}{\textnormal{{\gnoswi\char34}}}} at Black a.}
\end{minipage}
\begin{minipage}[t]{115.19999999999999pt}
\setlength{\parskip}{0.5em}
Expand Down Expand Up @@ -8779,7 +8779,7 @@ \chapter{White fights back}
\gofigure
\subtext{(Moves: 152-159)}

\subtext{{\raisebox{-.17em}{\textnormal{{\gnosbi\char55}}}} at {\raisebox{-.17em}{\textnormal{\gnosOverlap{@}{\color{white}\small{a}}}}},}
\subtext{{\raisebox{-.17em}{\textnormal{{\gnosbi\char55}}}} at Black a,}

\subtext{{\raisebox{-.17em}{\textnormal{{\gnoswi\char58}}}} at {\raisebox{-.17em}{\textnormal{{\gnoswi\char52}}}}.}
\end{minipage}
Expand Down Expand Up @@ -8821,7 +8821,7 @@ \chapter{White fights back}
\gofigure
\subtext{(Moves: 160-168)}

\subtext{{\raisebox{-.17em}{\textnormal{{\gnoswi\char64}}}} at {\raisebox{-.17em}{\textnormal{\gnosOverlap{!}{\small{a}}}}},}
\subtext{{\raisebox{-.17em}{\textnormal{{\gnoswi\char64}}}} at White a,}

\subtext{{\raisebox{-.17em}{\textnormal{{\gnosbi\char67}}}} at {\raisebox{-.17em}{\textnormal{{\gnosbi\char61}}}}.}
\end{minipage}
Expand Down Expand Up @@ -9661,7 +9661,7 @@ \chapter{White fights back}
\gofigure
\subtext{(Moves: 183-188)}

\subtext{{\raisebox{-.17em}{\textnormal{{\gnosbi\char87}}}} at {\raisebox{-.17em}{\textnormal{\gnosOverlap{@}{\color{white}\small{a}}}}}.}
\subtext{{\raisebox{-.17em}{\textnormal{{\gnosbi\char87}}}} at Black a.}
\end{minipage}
\begin{minipage}[t]{115.19999999999999pt}
\setlength{\parskip}{0.5em}
Expand Down Expand Up @@ -9701,7 +9701,7 @@ \chapter{White fights back}
\gofigure
\subtext{(Moves: 189-205)}

\subtext{{\raisebox{-.17em}{\textnormal{{\gnosbi\char95}}}}, {\raisebox{-.17em}{\textnormal{{\gnosbii\char1}}}} at {\raisebox{-.17em}{\textnormal{\gnosOverlap{@}{\color{white}\small{a}}}}},}
\subtext{{\raisebox{-.17em}{\textnormal{{\gnosbi\char95}}}}, {\raisebox{-.17em}{\textnormal{{\gnosbii\char1}}}} at Black a,}

\subtext{{\raisebox{-.17em}{\textnormal{{\gnoswi\char98}}}}, {\raisebox{-.17em}{\textnormal{{\gnoswii\char4}}}} at {\raisebox{-.17em}{\textnormal{{\gnoswi\char92}}}}.}
\end{minipage}
Expand Down Expand Up @@ -9760,13 +9760,13 @@ \chapter{White fights back}
,)))))))@))))))))).\\
}
\centerline{\govariation\hyperref[Fujisawa-Hosai-vs-Go-Seigen-19430225:0:mainmove-189]{\textit{for} {\raisebox{-.17em}{\textnormal{{\gnosbii\char5}}}}}}
\subtext{{\raisebox{-.17em}{\textnormal{\gnosOverlap{!}{\small{6}}}}} at {\raisebox{-.17em}{\textnormal{\gnosOverlap{!}{\small{a}}}}},}
\subtext{{\raisebox{-.17em}{\textnormal{\gnosOverlap{!}{\small{6}}}}} at White a,}

\subtext{{\raisebox{-.17em}{\textnormal{\gnosOverlap{@}{\color{white}\small{9}}}}} at {\raisebox{-.17em}{\textnormal{\gnosOverlap{@}{\color{white}\small{3}}}}}.}
\end{minipage}
\begin{minipage}[t]{115.19999999999999pt}
\setlength{\parskip}{0.5em}
Black can't answer this ko threat, and
{\raisebox{-.17em}{\textnormal{\gnosOverlap{!}{\small{a}}}}} is devastating -- Black can't answer this ko threat, and


\end{minipage}
Expand Down Expand Up @@ -9868,7 +9868,7 @@ \chapter{White fights back}
\gofigure
\subtext{(Moves: 207-215)}

\subtext{{\raisebox{-.17em}{\textnormal{{\gnoswii\char10}}}} at {\raisebox{-.17em}{\textnormal{\gnosOverlap{!}{\small{a}}}}},}
\subtext{{\raisebox{-.17em}{\textnormal{{\gnoswii\char10}}}} at White a,}

\subtext{{\raisebox{-.17em}{\textnormal{{\gnosbii\char13}}}} at {\raisebox{-.17em}{\textnormal{{\gnosbii\char7}}}}.}
\end{minipage}
Expand Down
8 changes: 4 additions & 4 deletions src/compiled/gpub.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions src/compiled/gpub_combined.js
Expand Up @@ -2701,7 +2701,7 @@ gpub.diagrams = {
},

/**
* A flattener helper. Returns a Flattened object, which is key for
* A flattener helper. Returns a glift Flattened object, which is key for
* generating diagrams.
*/
// TODO(kashomon): Consider deleting this. It's really not doing much at all.
Expand Down Expand Up @@ -2801,7 +2801,8 @@ gpub.diagrams = {
row.push(color + ' ' + c.mvnum);
}
var colStoneColor = labelToColStoneColor[label];
colStoneColor = (colStoneColor === glift.enums.states.BLACK ? 'Black' : 'White') + ' ';
colStoneColor = (colStoneColor === glift.enums.states.BLACK ?
'Black' : 'White') + ' ';

var rowString = row.join(', ') + ' at ' + colStoneColor + label;
allRows.push(rowString);
Expand Down Expand Up @@ -3169,10 +3170,13 @@ gpub.diagrams.gnos = {
// TODO(kashomon): The font size needs to be passed in here so we can select
// the correct label size. Moreover, we need to use get getLabelDef to be
// consistent between the diagram and inlined moves.
return text.replace(/((Black)|(White)) (([A-Za-z])|([0-9]+))(?=([^A-Za-z]|$))/g,
function(fullmatch, p1, xx2, xx3, p4) {
return text.replace(
/((Black)|(White)) (([A-Z])|(\(.\))|([0-9]+))(?=([^A-Za-z]|$))/g,
function(fullmatch, p1, xx2, xx3, label) {
var stone = null;
var label = p4;
if (/^\(.\)$/.test(label)) {
label = label.replace(/^\(|\)$/g, '');
}
if (p1 === 'Black') {
stone = glift.flattener.symbols.BSTONE;
} else if (p1 === 'White') {
Expand Down
9 changes: 6 additions & 3 deletions src/diagrams/gnos/gnos.js
Expand Up @@ -64,10 +64,13 @@ gpub.diagrams.gnos = {
// TODO(kashomon): The font size needs to be passed in here so we can select
// the correct label size. Moreover, we need to use get getLabelDef to be
// consistent between the diagram and inlined moves.
return text.replace(/((Black)|(White)) (([A-Za-z])|([0-9]+))(?=([^A-Za-z]|$))/g,
function(fullmatch, p1, xx2, xx3, p4) {
return text.replace(
/((Black)|(White)) (([A-Z])|(\(.\))|([0-9]+))(?=([^A-Za-z]|$))/g,
function(fullmatch, p1, xx2, xx3, label) {
var stone = null;
var label = p4;
if (/^\(.\)$/.test(label)) {
label = label.replace(/^\(|\)$/g, '');
}
if (p1 === 'Black') {
stone = glift.flattener.symbols.BSTONE;
} else if (p1 === 'White') {
Expand Down
21 changes: 15 additions & 6 deletions src/diagrams/gnos/gnos_test.js
Expand Up @@ -43,19 +43,28 @@
var text = 'And then! Black 3 followed by White 4! Destruction. ' +
'Avoidable with White A. Followed by Black 101';
var t = g.renderInline(text);
ok(g.renderInline(text).indexOf('{\\gnosOverlap{!}') > -1,
ok(t.indexOf('{\\gnosOverlap{!}') > -1,
'Exp: overlap !. Rendered Text:' + t);
ok(g.renderInline(text).indexOf('{\\gnosOverlap{@}') > -1,
ok(t.indexOf('{\\gnosOverlap{@}') > -1,
'Exp: overlap @. Rendered Text:' + t);

ok(g.renderInline(text).indexOf('3') > -1,
ok(t.indexOf('3') > -1,
'Exp: overlap 3 Rendered Text:' + t);
ok(g.renderInline(text).indexOf('{4}') > -1,
ok(t.indexOf('{4}') > -1,
'Exp: overlap {4} Rendered Text:' + t);
ok(g.renderInline(text).indexOf('{A}') > -1,
ok(t.indexOf('{A}') > -1,
'Exp: overlap {A} Rendered Text:' + t);

ok(g.renderInline(text).indexOf('{\\gnosbi\\char1}') > -1,
ok(t.indexOf('{\\gnosbi\\char1}') > -1,
'Exp: overlap gnosbi. Rendered Text:' + t);
});

test('Gnos render for lowercase', function() {
var g = gpub.diagrams.gnos;
var text = 'And then! Black (a)';
var t = g.renderInline(text);
ok(t.indexOf('{\\gnosOverlap{@}') > -1,
'Exp: overlap !. Rendered Text:' + t);
ok(t.indexOf('{a}') > -1, 'Should remove parens:' + t);
});
})();

0 comments on commit 0879123

Please sign in to comment.