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 % \ifhastok={#2}\lettonothing\m_bookmarks_opened\setupcurrentbookmark[#2]\fi 108 \doifelseassignment{#2}{\lettonothing\m_bookmarks_opened\setupcurrentbookmark[#2]}\donothing 109 \or 110 \setupcurrentbookmark[#3]% no every so not all possible 111 \fi 112 113 names {\m_bookmarks_names}% 114 opened {\m_bookmarks_opened}% 115 force {\bookmarkparameter\c!force}% 116 number {\bookmarkparameter\c!number}% 117 \relax 118 \endgroup} 119 120\appendtoks 121 122 separatorset {\bookmarkparameter\c!numberseparatorset}% 123 conversionset {\bookmarkparameter\c!numberconversionset}% 124 starter {\bookmarkparameter\c!numberstarter}% 125 stopper {\bookmarkparameter\c!numberstopper}% 126 segments {\bookmarkparameter\c!numbersegments}% 127 showblocktitle {\bookmarkparameter\c!sectionblock}% 128 \relax 129\to \everysetupbookmark 130 131%D There is a plugin mechanism but this is for experts only. The intermediate 132%D data structures are stable. 133%D 134%D \starttyping 135%D \startluacode 136%D structures.bookmarks.installhandler("check before","before",function(levels) 137%D logs.report("extra bookmarks","before (normal bookmarks)") 138%D inspect(levels) 139%D logs.report("extra bookmarks","before (extra bookmarks)") 140%D inspect(structures.bookmarks.extras.get()) 141%D return levels 142%D end) 143%D structures.bookmarks.installhandler("check after", "after", function(levels) 144%D logs.report("extra bookmarks","after (merged bookmarks)") 145%D inspect(levels) 146%D return levels 147%D end) 148%D \stopluacode 149%D \starttyping 150%D 151%D This mechanism was added when bookmark inclusion became (optional) part of graphic 152%D inclusion (which is needed by Taco). 153%D 154%D \starttyping 155%D \getfiguredimensions[somefile.pdf] 156%D \dorecurse {\noffigurepages} { 157%D \startTEXpage 158%D \externalfigure[somefile.pdf][interaction=bookmark,page=\recurselevel] 159%D \stopTEXpage 160%D } 161%D \starttyping 162 163\protect \endinput 164 165% \starttext 166% \setupinteraction[state=start]\setupinteractionscreen[option=bookmark] 167% \placebookmarks[chapter,section,subsection][chapter] 168% \chapter{First} 169% \bookmark{The First Indeed} 170% \section{alpha} 171% \bookmark[chapter]{The First Indeed Again} 172% \section{beta} 173% \chapter{Second} 174% \bookmark{The Second Indeed} 175% \section{gamma \tex{radiation}} 176% \subsection{a} 177% \subsection{b} 178% \section{delta} 179% \section{epsilon} 180% \chapter{Third \relax} 181% \chapter{我〈能吞下玻璃而不傷身〉體。} % whatever that means 182% \chapter{Idris Samawi Hamid ادريس سماوي حامد} 183% \stoptext 184 |