1[/ 2 Copyright 2002,2004,2006 Joel de Guzman, Eric Niebler 3 Copyright 2010-2013 Daniel James 4 5 Distributed under the Boost Software License, Version 1.0. 6 (See accompanying file LICENSE_1_0.txt or copy at 7 http://www.boost.org/LICENSE_1_0.txt) 8] 9 10[section:1_6 Quickbook 1.6] 11 12[section:docinfo Includes with docinfo] 13 14In quickbook 1.5 if you include a file which starts with a docinfo block, it's 15ignored and the file is expanded in place. In quickbook 1.6 it's treated as a 16document nested in the current position. So if it has an 'article' docinfo block, 17boostbook 'article' tags are used. 18 19It also mostly generates the same markup as if the file was converted separately - 20so for example, the same ids are generated, the document is processed using the 21language version specified in the docinfo block. If no language is specified it 22uses the default (1.1) not the version of the document that included it. This 23might seem surprising, but is requried so that quickbook will convert it the same 24way as if it was converted separately. 25 26So for the most part, includes with a docinfo are like an `xinclude`, apart from 27a couple of differences. Templates and macros defined in the parent document are 28used in the included document, and the id generator rewrites ids that clash 29between multiple documents. 30 31If an included document doesn't have a docinfo block, it's just included as 32before. 33 34[endsect:docinfo] 35 36[section:doc_info_macros Macros in docinfo block] 37 38You can now expand macros in text fields in the docinfo block. In the top 39docinfo block only the predefined macros are available, but in nested documents 40macros defined in the parent document are also available. 41 42There's a small bug here - this leaks into older versions for the `license` 43and `purpose` fields, but since only the predefined macros are available, it's 44unlikely to break any existing documents. So I'd rather not complicate the code 45further by fixing that. 46 47[endsect:doc_info_macros] 48 49[section:scope Scoping templates and macros] 50 51A long standing quickbook bug is that macros are scoped by file, but templates 52aren't. So you can define templates in a separate file and include them, but not 53macros. This has been fixed so that templates defined in one file won't 'leak' 54into another. 55 56But this means there's no way to define templates in a separate file - a useful 57feature. To do this the `import` element has been adapted to also support 58quickbook files. If a quickbook file is imported, the templates and macros 59defined in it are added to the current scope, but nothing else contained in that 60file is used. This could be used to create template and macro library files. 61This matches the existing semantics of importing code snippets. 62 63When importing templates, they're bound to the language version of the file 64they were defined in. This means that if you import them into a file with 65a different version it won't change the way they're interpreted. Although, 66as we'll see [link compatibility later], the generated boostbook is slightly 67different. 68 69[endsect:scope] 70 71[section:include Including C++ and python files] 72 73As `import` now supports quickbook files, `include` also supports source files. 74It includes any quickbook contained in comments outside of code snippets. 75Code snippets in the file are available to be expanded within the file but 76are scoped to the file. In exactly the same manner as when templates and macros 77are scoped in an included quickbook file. 78 79[endsect:include] 80 81[section:ids Id Generation] 82 83Id generation in quickbook 1.5 is a bit buggy, but that can't be fixed without a 84version switch as it will break existing documents. For example in quickbook 1.5 85when you include a quickbook file, it stops using the explicit id from the 86documentation info and generates a new id from the document title to use instead. 87 88The id generator in quickbook 1.6 has been improved in some other ways to. When 89generating ids from section titles, table titles etc. it always uses the 90quickbook source rather than the generated boostbook to generate the id. It then 91cleans up the id slightly, trimming leading and trailing underscores and replacing 92multiple underscores with a single underscore. Then if the newly generated part 93of the id is longer than 32 characters it truncates it. 94 95While the new id generator generally creates better ids, it's more likely to 96generate duplicates so quickbook needs to handle duplicates better. When there 97are multiple identical ids, quickbook chooses one to use based on a priority 98list - anchors are preferred, then explicit document and section ids, then other 99explicit ids, followed by the generated ids. Then any other explicit ids in the 100document have numbers added to avoid duplicates - first the explicit ids in the 101order they appear and then the generated ids. A generated id which accidentally 102clashes with an explicit id should never change the explicit id. 103 104Older language versions still generate the same ids they always have, with the 105exception of duplicate ids which are handled using the new mechanism - this 106is not a breaking change since duplicate ids can't be linked to. 107 108[endsect:ids] 109 110[#compatibility] 111[section:compatibility Compatibility Mode] 112 113As mentioned before, changing the id generator will break links in documents 114written using an old language version. So to ease the transition a 115'compatibility mode' is used, this just requires an extra attribute in the 116docinfo, for example if you're converting a 1.5 document to 1.6: 117 118 [article Document 119 [quickbook 1.6] 120 [compatibility-mode 1.5] 121 ] 122 123This means the document will be parsed as 1.6, using all the new features, but 124ids (and possibly other markup) will generated as they were for a 1.5 document. 125 126Compatibility mode is also implicitly used when generating templates written 127in a different language version to the current document. So the template is 128parsed in the version it was written for, but generates boostbook that's 129compatible with the current document. 130 131[endsect:compatibility] 132 133[section:version Version info outside of document info block] 134 135Can now use `quickbook` and `compatibility-mode` tags at the beginning of the 136file. Either before or without a document info block. This is useful for 137files just containing templates, which don't really need a document info 138block. 139 140If you don't specify `compatibility-mode`, the behaviour depends on whether or 141not you have a docinfo block. If you do it uses the file's quickbook version, 142if you don't it inherits the parent's compatibility mode even if you specify 143a quickbook version. This is the right thing to do - mixing compatibility modes 144within documents is problematic. It might actually be a mistake to allow them 145to specified outside docinfo blocks. 146 147This change is also backdated to older versions. So when including from an 148older version, the included file's version can be set (older versions 149ignore document info in included files). 150 151[endsect:version] 152 153[section:heading_ids Explicit Heading Ids] 154 155Headings can now be given explicit ids: 156 157 [heading:id A heading with an explicit id] 158 159[endsect:heading_ids] 160 161[section:escapes Punctuation changes] 162 163In 1.6, quickbook is more consistent about how it parses punctuation. 164Escapes are now supported in links, anchors, table titles, image 165attributes etc. The flip side of this is that quickbook is now stricter 166about unescaped brackets. They can still be used, but need to match up, 167otherwise there's an error. 168 169Since quickbook now matches up square brackets it will fix some 170mis-parses. For example `[*[bold]]` used to parse as [*\[bold]\] - note 171that the closing square bracket isn't bold, now it parses as 172[*\[bold\]]. In this case it's just a subtle visual difference, but it 173could cause odd problems, for example when nested in a table cell. 174 175[endsect:escapes] 176 177[section:table Table Titles] 178 179Table titles are now parsed as phrases, so some markup is allowd: 180 181 [table [*bold title]] 182 183Which is an empty table with a bold title. The title is no longer ended 184by a newline, but by either a closing square bracket, or two opening 185square brackets - which you get at the start of the table cells, so 186this now works: 187 188 [table Simple[[heading 1][heading 2]][[cell 1][cell 2]]] 189 190[endsect:table] 191 192[section:xmlbase XML base] 193 194A problem when using `xi:include` tags in escaped boostbook is that you 195typically don't know which directory the boostbook file will be in, so 196it's impossible to use relative links. This can be fixed by adding an 197`xml:base` attribute to the document tag. To do this use the new 198`xmlbase` attribute in your document's docinfo block. For example to 199make escaped `xi:include`s be relative to the directory of the file: 200 201 [library Library documentation 202 [quickbook 1.6] 203 [xmlbase .] 204 ] 205 206Any paths in `xinclude` elements will be rewritten accordingly. Note that 207most documents won't need this, and probably shouldn't use it. Only use it 208if you're totally sure that you will need it. 209 210[endsect:xmlbase] 211 212[section:template_parser Improved template parser] 213 214There's a new parser for template declarations and parameters which does 215a better job of understanding escaped and bracketed text. Unfortunately 216it does not understand element names so there are some cases where it 217could go wrong. For example: 218 219 [template doesnt_work[] 220 [ordered_list 221 [`code phrase`] 222 ] 223 ] 224 225In this case it will think the `[\`` is a template call and give a parse 226error. To work around this put an escaped space before the code phrase: 227 228 [template works[] 229 [ordered_list 230 [\ `code phrase`] 231 ] 232 ] 233 234[endsect:template_parser] 235 236[section:elements New Elements] 237 238New elements added in quickbook 1.6: 239 240* [link quickbook.ref.block `block`] 241* [link quickbook.ref.list_tags `ordered_list` and `itemized_list`] 242* [link quickbook.ref.role `role`] 243 244[endsect:elements] 245 246[endsect:1_6] 247