@@ -283,7 +283,9 @@ __DATA__
283283 \global\@backmatterfalse
284284 \startXMLelement{front-matter}%
285285 \addXMLid
286+ \ifNEWappendixes@\else
286287 \def\XML@section@tag{sec}% TBD: remove this line
288+ \fi
287289 \fi
288290}
289291
@@ -299,7 +301,9 @@ __DATA__
299301 \addXMLid
300302 \startXMLelement{book-part}%
301303 \startXMLelement{body}%
304+ \ifNEWappendixes@\else
302305 \def\XML@section@tag{sec}% TBD: remove this line
306+ \fi
303307 \mainmatter@hook
304308 \fi
305309}
@@ -313,8 +317,10 @@ __DATA__
313317 \startXMLelement{book-back}%
314318 \addXMLid
315319 %% TBD: remove next two lines
320+ \ifNEWappendixes@\else
316321 \def\XML@section@tag{book-app}%
317322 \let\default@XML@section@tag\XML@section@tag
323+ \fi
318324 \fi
319325}
320326
@@ -324,57 +330,57 @@ __DATA__
324330
325331%% TBD: replace definition of \appendix
326332
327- \iftrue
333+ \ifNEWappendixes@
328334
329335\def\appendix{%
336+ \kernel@ifnextchar[\appendix@{\appendix@[]}%
337+ }
338+
339+ \def\appendix@[#1]{%
330340 \ifappendix\else
331341 \par
332342 \backmatter
333343 \appendixtrue
334- \startXMLelement{\XML@appendix@ group@element }%
344+ \startXMLelement{book-app- group}%
335345 \addXMLid
336- \@push@sectionstack{-1}{\XML@appendix@group@element}%
346+ \@push@sectionstack{\texml@book@app@group@level}{book-app-group}%
347+ \ifnum\strcmp{#1}{} = 0 \else
348+ \startXMLelement{book-part-meta}%
349+ \startXMLelement{title-group}%
350+ \thisxmlpartag{title}#1\par
351+ \endXMLelement{title-group}%
352+ \endXMLelement{book-part-meta}%
353+ \fi
354+ \let\chapter\chapter@app
337355 \c@chapter\z@
338356 \c@section\z@
339357 \c@subsection\z@
340358 \let\chaptername\appendixname
341359 \def\thechapter{\@Alph\c@chapter}%
342- \def\@chapterefsubtype{appendix}%
343360 \fi
344361}
345362
346- \let\default@XML@section@tag\XML@section@tag %% TBD: remove this line
347-
348363\else
349364
350365\def\appendix{%
351- \kernel@ifnextchar[\appendix@{\appendix@[]}%
352- }
353-
354- \def\appendix@[#1]{%
355366 \ifappendix\else
356367 \par
357368 \backmatter
358369 \appendixtrue
359- \startXMLelement{book-app- group}%
370+ \startXMLelement{\XML@appendix@ group@element }%
360371 \addXMLid
361- \@push@sectionstack{\texml@book@app@group@level}{book-app-group}%
362- \ifnum\strcmp{#1}{} = 0 \else
363- \startXMLelement{book-part-meta}%
364- \startXMLelement{title-group}%
365- \thisxmlpartag{title}#1\par
366- \endXMLelement{title-group}%
367- \endXMLelement{book-part-meta}%
368- \fi
369- \let\chapter\chapter@app
372+ \@push@sectionstack{-1}{\XML@appendix@group@element}%
370373 \c@chapter\z@
371374 \c@section\z@
372375 \c@subsection\z@
373376 \let\chaptername\appendixname
374377 \def\thechapter{\@Alph\c@chapter}%
378+ \def\@chapterefsubtype{appendix}%
375379 \fi
376380}
377381
382+ \let\default@XML@section@tag\XML@section@tag %% TBD: remove this line
383+
378384\fi
379385
380386\def\@Guess@FM@type#1{%
@@ -391,16 +397,16 @@ __DATA__
391397
392398% TBD: Replace \@chapdef
393399
394- \iftrue
395-
396- \def\@chapdef#1#2{\@ifstar{\@dblarg{#2}}{\@dblarg{#1}}}
397-
398- \else
400+ \ifNEWappendixes@
399401
400402\def\@chapdef#1#2{%
401403 \@ifstar {\st@rredtrue\@dblarg{#2}} {\st@rredfalse\@dblarg{#1}}%
402404}
403405
406+ \else
407+
408+ \def\@chapdef#1#2{\@ifstar{\@dblarg{#2}}{\@dblarg{#1}}}
409+
404410\fi
405411
406412\def\chaptername{Chapter}
@@ -410,63 +416,7 @@ __DATA__
410416 \@chapdef\@chapter\@schapter
411417}
412418
413- \iftrue
414-
415- \def\@chapterefsubtype{chapter}
416-
417- \def\@chapter[#1]#2{%
418- \def\@currentreftype{sec}%
419- \edef\@currentrefsubtype{\@chapterefsubtype}%
420- \def\@toclevel{0}%
421- \@Guess@FM@type{#2}%
422- \let\@secnumber\@empty
423- \ifnum\c@secnumdepth<\@toclevel\relax \else
424- \ifx\thechapter\@empty \else
425- \refstepcounter{chapter}%
426- \edef\@secnumber{\thechapter}%
427- \fi
428- \fi
429- \typeout{\ifx\chaptername\@empty\else\chaptername\space\fi\@secnumber}%
430- \@ams@inlinefalse
431- \start@XML@section{chapter}{0}{%
432- \ifnum\c@secnumdepth<\@toclevel \else
433- \ifx\chaptername\@empty\else
434- \chaptername\space
435- \fi
436- \fi
437- \@secnumber
438- }{#2}%
439- \let\XML@section@tag\default@XML@section@tag
440- \ifx\chaptername\appendixname
441- \@tocwriteb\tocappendix{chapter}{#2}%
442- \else
443- \@tocwriteb\tocchapter{chapter}{#2}%
444- \fi
445- \@afterheading
446- }
447-
448- \def\@schapter[#1]#2{%
449- \let\saved@footnote\footnote
450- \let\footnote\@gobble
451- \typeout{#2}%
452- \@Guess@FM@type{#2}%
453- \def\@toclevel{0}%
454- \let\@secnumber\@empty
455- \let\footnote\saved@footnote
456- \@ams@inlinefalse
457- \start@XML@section{chapter}{0}{}{#2}%
458- \let\XML@section@tag\default@XML@section@tag
459- \let\footnote\@gobble
460- \ifx\chaptername\appendixname
461- \@tocwriteb\tocappendix{chapter}{#2}%
462- \else
463- \@tocwriteb\tocchapter{chapter}{#2}%
464- \fi
465- \let\footnote\saved@footnote
466- \@afterheading
467- }
468-
469- \else
419+ \ifNEWappendixes@
470420
471421\def\@chapter[#1]#2{%
472422 \def\@currentreftype{sec}%
@@ -558,6 +508,62 @@ __DATA__
558508 \@afterheading
559509}
560510
511+ \else
512+
513+ \def\@chapterefsubtype{chapter}
514+
515+ \def\@chapter[#1]#2{%
516+ \def\@currentreftype{sec}%
517+ \edef\@currentrefsubtype{\@chapterefsubtype}%
518+ \def\@toclevel{0}%
519+ \@Guess@FM@type{#2}%
520+ \let\@secnumber\@empty
521+ \ifnum\c@secnumdepth<\@toclevel\relax \else
522+ \ifx\thechapter\@empty \else
523+ \refstepcounter{chapter}%
524+ \edef\@secnumber{\thechapter}%
525+ \fi
526+ \fi
527+ \typeout{\ifx\chaptername\@empty\else\chaptername\space\fi\@secnumber}%
528+ \@ams@inlinefalse
529+ \start@XML@section{chapter}{0}{%
530+ \ifnum\c@secnumdepth<\@toclevel \else
531+ \ifx\chaptername\@empty\else
532+ \chaptername\space
533+ \fi
534+ \fi
535+ \@secnumber
536+ }{#2}%
537+ \let\XML@section@tag\default@XML@section@tag
538+ \ifx\chaptername\appendixname
539+ \@tocwriteb\tocappendix{chapter}{#2}%
540+ \else
541+ \@tocwriteb\tocchapter{chapter}{#2}%
542+ \fi
543+ \@afterheading
544+ }
545+
546+ \def\@schapter[#1]#2{%
547+ \let\saved@footnote\footnote
548+ \let\footnote\@gobble
549+ \typeout{#2}%
550+ \@Guess@FM@type{#2}%
551+ \def\@toclevel{0}%
552+ \let\@secnumber\@empty
553+ \let\footnote\saved@footnote
554+ \@ams@inlinefalse
555+ \start@XML@section{chapter}{0}{}{#2}%
556+ \let\XML@section@tag\default@XML@section@tag
557+ \let\footnote\@gobble
558+ \ifx\chaptername\appendixname
559+ \@tocwriteb\tocappendix{chapter}{#2}%
560+ \else
561+ \@tocwriteb\tocchapter{chapter}{#2}%
562+ \fi
563+ \let\footnote\saved@footnote
564+ \@afterheading
565+ }
566+
561567\fi
562568
563569\def\part{\secdef\@part\@spart}
0 commit comments