diff -r 708743578e45 -r 82e945d472d5 src/Doc/Isar_Ref/Document_Preparation.thy --- a/src/Doc/Isar_Ref/Document_Preparation.thy Sat Mar 23 20:27:56 2019 +0100 +++ b/src/Doc/Isar_Ref/Document_Preparation.thy Sun Mar 24 13:48:46 2019 +0100 @@ -466,43 +466,89 @@ \ -section \Markup via command tags \label{sec:tags}\ +section \Document markers and command tags \label{sec:document-markers}\ text \ - Each Isabelle/Isar command may be decorated by additional presentation tags, - to indicate some modification in the way it is printed in the document. + \emph{Document markers} are formal comments of the form \\<^marker>\marker_body\\ + (using the control symbol \<^verbatim>\\<^marker>\) and may occur anywhere within the + outer syntax of a command: the inner syntax of a marker body resembles that + for attributes (\secref{sec:syn-att}). In contrast, \emph{Command tags} may + only occur after a command keyword and are treated as special markers as + explained below. \<^rail>\ - @{syntax_def tags}: ( tag * ) + @{syntax_def marker}: '\<^marker>' @{syntax cartouche} + ; + @{syntax_def marker_body}: (@{syntax name} @{syntax args} * ',') + ; + @{syntax_def tags}: tag* ; tag: '%' (@{syntax short_ident} | @{syntax string}) \ - Some tags are pre-declared for certain classes of commands, serving as - default markup if no tags are given in the text: + Document markers are stripped from the document output, but surrounding + white-space is preserved: e.g.\ a marker at the end of a line does not + affect the subsequent line break. Markers operate within the semantic + presentation context of a command, and may modify it to change the overall + appearance of a command span (e.g.\ by adding tags). + + Each document marker has its own syntax defined in the theory context; the + following markers are predefined in Isabelle/Pure: + + \<^rail>\ + (@@{document_marker_def title} | + @@{document_marker_def creator} | + @@{document_marker_def contributor} | + @@{document_marker_def date} | + @@{document_marker_def license} | + @@{document_marker_def description}) @{syntax embedded} + ; + @@{document_marker_def tag} @{syntax name} + \ - \<^medskip> - \begin{tabular}{ll} - \document\ & document markup commands \\ - \theory\ & theory begin/end \\ - \proof\ & all proof commands \\ - \ML\ & all commands involving ML code \\ - \end{tabular} - \<^medskip> + \<^descr> \\<^marker>\title arg\\, \\<^marker>\creator arg\\, \\<^marker>\contributor arg\\, \\<^marker>\date arg\\, + \\<^marker>\license arg\\, and \\<^marker>\description arg\\ produce markup in the PIDE + document, without any immediate effect on typesetting. This vocabulary is + taken from the Dublin Core Metadata + Initiative\<^footnote>\\<^url>\https://www.dublincore.org/specifications/dublin-core/dcmi-terms\\. + The argument is an uninterpreted string, except for @{document_marker + description}, which consists of words that are subject to spell-checking. + + \<^descr> \\<^marker>\tag name\\ updates the list of command tags in the presentation + context: later declarations take precedence, so \\<^marker>\tag a, tag b, tag c\\ + produces a reversed list. The default tags are given by the original + \<^theory_text>\keywords\ declaration of a command, and the system option + @{system_option_ref document_tags}. + + An old-style command tag \<^verbatim>\%\\name\ is treated like a document marker + \\<^marker>\tag name\\: the list of command tags precedes the list of document + markers. The head of the resulting tags in the presentation context is + turned into {\LaTeX} environments to modify the type-setting. The + following tags are pre-declared for certain classes of commands, and serve + as default markup for certain kinds of commands: + + \<^medskip> + \begin{tabular}{ll} + \document\ & document markup commands \\ + \theory\ & theory begin/end \\ + \proof\ & all proof commands \\ + \ML\ & all commands involving ML code \\ + \end{tabular} + \<^medskip> The Isabelle document preparation system @{cite "isabelle-system"} allows tagged command regions to be presented specifically, e.g.\ to fold proof texts, or drop parts of the text completely. - For example ``@{command "by"}~\%invisible auto\'' causes that piece of proof - to be treated as \invisible\ instead of \proof\ (the default), which may be - shown or hidden depending on the document setup. In contrast, ``@{command - "by"}~\%visible auto\'' forces this text to be shown invariably. + For example ``\<^theory_text>\by auto\~\\<^marker>\tag invisible\\'' causes that piece of proof to + be treated as \invisible\ instead of \proof\ (the default), which may be + shown or hidden depending on the document setup. In contrast, ``\<^theory_text>\by + auto\~\\<^marker>\tag visible\\'' forces this text to be shown invariably. Explicit tag specifications within a proof apply to all subsequent commands - of the same level of nesting. For example, ``@{command "proof"}~\%visible - \\~@{command "qed"}'' forces the whole sub-proof to be typeset as \visible\ - (unless some of its parts are tagged differently). + of the same level of nesting. For example, ``\<^theory_text>\proof\~\\<^marker>\tag invisible\ + \\~\<^theory_text>\qed\'' forces the whole sub-proof to be typeset as \visible\ (unless + some of its parts are tagged differently). \<^medskip> Command tags merely produce certain markup environments for type-setting.