1%D \module 2%D [ file=strc-bkm, 3%D version=2009.04.01, 4%D title=\CONTEXT\ Structure Macros, 5%D subtitle=Bookmarks, 6%D author=Hans Hagen, 7%D date=\currentdate, 8%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] 9%C 10%C This module is part of the \CONTEXT\ macro||package and is 11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for 12%C details. 13 14\writestatus{loading}{ConTeXt Structure Macros / Bookmarks} 15 16\registerctxluafile{strc-bkm}{} 17 18% \enabledirectives[references.bookmarks.preroll] 19 20\unprotect 21 22%D Bookmarks are a very viewer dependent feature. They are mostly used as additional 23%D table of contents and therefore relate directly to lists. 24%D 25%D A bookmark list is added to the document only when interaction is enabled. The 26%D given lists are bookmarked and a second argument specifies the opened bookmark 27%D trees. 28%D 29%D \starttyping 30%D \placebookmarks 31%D [chapter,section,subsection,mylist] 32%D [chapter] 33%D \stoptyping 34%D 35%D You can overloads the last set bookmark in a sectioning command: 36%D 37%D \starttyping 38%D \chapter {the first chapter} 39%D \bookmark {the first bookmark} 40%D \stoptyping 41%D 42%D However, in practice you can better use \type {\startchapter} and set the \type 43%D {bookmark} parameter. 44%D 45%D You can add entries to the bookmarklist: 46%D 47%D \starttyping 48%D \bookmark[mylist]{whatever} 49%D \stoptyping 50%D 51%D Use force to get titles in the bookmarklist. This is somewhat tricky as one does 52%D not want \quotation {Contents} in a table of contents but it has to be in the 53%D bookmark list. 54 55\installcorenamespace{bookmark} 56 57\installsetuponlycommandhandler \??bookmark {bookmark} % installdirectparametersethandler 58 59\setupbookmark 60 [\c!force=\v!no, % it's easier to force that to inhibit 61 \c!number=\v!yes, % might become v!no 62 \c!sectionblock=\v!no] % show sectionblock level + title 63 64\aliased\let\setupbookmarks\setupbookmark 65 66\permanent\protected\def\bookmark 67 {\iflocation 68 \expandafter\strc_bookmarks_bookmark_yes 69 \else 70 \expandafter\strc_bookmarks_bookmark_nop 71 \fi} 72 73\tolerant\def\strc_bookmarks_bookmark_yes[#1]#:#2% 74 {\begingroup 75 \simplifycommands 76 \ifnum\thenamedheadlevel{#1}>\zerocount 77 {#1}{\detokenize\expandafter{\normalexpanded{#2}}}% 78 \else 79 \writetolist[#1]{#2}{}% todo: a dedicated bookmark writer 80 \fi 81 \endgroup} 82 83\tolerant\def\strc_bookmarks_bookmark_nop[#1]#:#2% 84 {} 85 86\permanent\protected\def\placebookmarks 87 {\iflocation 88 \expandafter\strc_bookmarks_place_yes 89 \else 90 \expandafter\gobblethreeoptionals 91 \fi} 92 93\lettonothing\m_bookmarks_names 94\lettonothing\m_bookmarks_opened 95 96\tolerant\def\strc_bookmarks_place_yes[#1]#*[#S#2]#*[#S#3]% 97 {\begingroup 98 \edef\m_bookmarks_names{#1}% 99 \edef\m_bookmarks_opened{#2}% 100 \ifempty\m_bookmarks_names 101 \edef\m_bookmarks_names{\namedlistparameter\v!content\c!list}% 102 \fi 103 \ifempty\m_bookmarks_names 104 \let\m_bookmarks_names\v!all 105 \fi 106 \ifparameters\or\or 107 \doifelseassignment{#2}{\lettonothing\m_bookmarks_opened\setupcurrentbookmark[#2]}\donothing 108 \or 109 \setupcurrentbookmark[#3]% no every so not all possible 110 \fi 111 112 names {\m_bookmarks_names}% 113 opened {\m_bookmarks_opened}% 114 force {\bookmarkparameter\c!force}% 115 number {\bookmarkparameter\c!number}% 116 \relax 117 \endgroup} 118 119\appendtoks 120 121 separatorset {\bookmarkparameter\c!numberseparatorset}% 122 conversionset {\bookmarkparameter\c!numberconversionset}% 123 starter {\bookmarkparameter\c!numberstarter}% 124 stopper {\bookmarkparameter\c!numberstopper}% 125 segments {\bookmarkparameter\c!numbersegments}% 126 showblocktitle {\bookmarkparameter\c!sectionblock}% 127 \relax 128\to \everysetupbookmark 129 130%D There is a plugin mechanism but this is for experts only. The intermediate 131%D data structures are stable. 132%D 133%D \starttyping 134%D \startluacode 135%D structures.bookmarks.installhandler("check before","before",function(levels) 136%D logs.report("extra bookmarks","before (normal bookmarks)") 137%D inspect(levels) 138%D logs.report("extra bookmarks","before (extra bookmarks)") 139%D inspect(structures.bookmarks.extras.get()) 140%D return levels 141%D end) 142%D structures.bookmarks.installhandler("check after", "after", function(levels) 143%D logs.report("extra bookmarks","after (merged bookmarks)") 144%D inspect(levels) 145%D return levels 146%D end) 147%D \stopluacode 148%D \starttyping 149%D 150%D This mechanism was added when bookmark inclusion became (optional) part of graphic 151%D inclusion (which is needed by Taco). 152%D 153%D \starttyping 154%D \getfiguredimensions[somefile.pdf] 155%D \dorecurse {\noffigurepages} { 156%D \startTEXpage 157%D \externalfigure[somefile.pdf][interaction=bookmark,page=\recurselevel] 158%D \stopTEXpage 159%D } 160%D \starttyping 161 162\protect \endinput 163 164% \starttext 165% \setupinteraction[state=start]\setupinteractionscreen[option=bookmark] 166% \placebookmarks[chapter,section,subsection][chapter] 167% \chapter{First} 168% \bookmark{The First Indeed} 169% \section{alpha} 170% \bookmark[chapter]{The First Indeed Again} 171% \section{beta} 172% \chapter{Second} 173% \bookmark{The Second Indeed} 174% \section{gamma \tex{radiation}} 175% \subsection{a} 176% \subsection{b} 177% \section{delta} 178% \section{epsilon} 179% \chapter{Third \relax} 180% \chapter{我〈能吞下玻璃而不傷身〉體。} % whatever that means 181% \chapter{Idris Samawi Hamid ادريس سماوي حامد} 182% \stoptext 183 |