1 /** \file fb2def.h
2     \brief FictionBook2 format defitions
3 
4     When included w/o XS_IMPLEMENT_SCHEME defined,
5     declares enums for element, attribute and namespace names.
6 
7     When included with XS_IMPLEMENT_SCHEME defined,
8     defines fb2_elem_table, fb2_attr_table and fb2_ns_table tables
9     which can be passed to document to define schema.
10     Please include it with XS_IMPLEMENT_SCHEME only into once in project.
11 
12     CoolReader Engine
13 
14     (c) Vadim Lopatin, 2000-2006
15     This source code is distributed under the terms of
16     GNU General Public License.
17 
18     See LICENSE file for details.
19 
20 */
21 
22 #if !defined(__FB2_DEF_H_INCLUDED__) || defined(XS_IMPLEMENT_SCHEME)
23 #define __FB2_DEF_H_INCLUDED__
24 
25 #include "dtddef.h"
26 
27 //=====================================================
28 // el_ definitions
29 //=====================================================
30 XS_BEGIN_TAGS
31 
32 // Boxing elements (inserted in the DOM tree between original parent and children):
33 //
34 // Internal element for block wrapping inline elements (without a proper parent
35 // block container) among proper block siblings (would be better named "blockBox")
36 XS_TAG1T( autoBoxing )
37 // Internal element for tabular elements added to complete incomplete tables
38 XS_TAG1T( tabularBox )
39 // Internal element for ruby wrapping completion (so we can render them as inline-table with tweaks)
40 XS_TAG1I( rubyBox )
41 // Internal element for float rendering
42 XS_TAG1T( floatBox )
43 // Internal element for inline-block and inline-table rendering
44 XS_TAG1I( inlineBox )
45 
46 // Internal element created for CSS pseudo elements ::before and ::after :
47 //  - defaults to "display: none", but will be set to "inline" when style is applied
48 //  - it doesn't have a text node child, the content will be fetched from
49 //    its style->content when rendering and drawing text.
50 // It does not box anything and has no child, so it's not considered a boxing node.
51 XS_TAG1D( pseudoElem, false, css_d_none, css_ws_inherit )
52 
53 // Internal element for EPUB, containing each individual HTML file
54 XS_TAG1( DocFragment )
55 
56 XS_TAG2( xml, "?xml" )
57 XS_TAG2( xml_stylesheet, "?xml-stylesheet" )
58 
59 // Classic HTML / EPUB elements
60 XS_TAG1( html )
61 XS_TAG1( head )
62 XS_TAG1D( title, true, css_d_block, css_ws_inherit )
63 XS_TAG1D( style, true, css_d_none, css_ws_inherit )
64 XS_TAG1D( script, true, css_d_none, css_ws_inherit )
65 XS_TAG1D( base, false, css_d_none, css_ws_inherit ) // among crengine autoclose elements
66 XS_TAG1D( basefont, false, css_d_none, css_ws_inherit )
67 XS_TAG1D( bgsound, false, css_d_none, css_ws_inherit )
68 XS_TAG1D( meta, false, css_d_none, css_ws_inherit )
69 XS_TAG1D( link, false, css_d_none, css_ws_inherit )
70 XS_TAG1T( body )
71 
72 // Limits for head handling by our HTML Parser (ldomDocumentWriterFilter)
73 // (if met before any HEAD or BODY, HTML/HEAD might be auto-inserted)
74 #define EL_IN_HEAD_START el_head
75 #define EL_IN_HEAD_END   el_link
76 #define EL_IN_BODY_START el_body
77 
78                 // HTML5: start of special tags, closing all
79                 // the way, and closing any <P>
80 // Block elements
81 XS_TAG1T( hr )
82 XS_TAG1T( svg )
83 XS_TAG1T( form )
84 XS_TAG1D( pre, true, css_d_block, css_ws_pre )
85 XS_TAG1T( blockquote )
86 XS_TAG1T( div )
87 XS_TAG1T( h1 )
88 XS_TAG1T( h2 )
89 XS_TAG1T( h3 )
90 XS_TAG1T( h4 )
91 XS_TAG1T( h5 )
92 XS_TAG1T( h6 )
93 XS_TAG1T( p )
94 XS_TAG1T( output )
95 XS_TAG1T( section )
96 
97 // Lists
98 XS_TAG1T( ol )
99 XS_TAG1T( ul )
100 XS_TAG1D( li, true, css_d_list_item_block, css_ws_inherit )
101 
102 // Definitions
103 XS_TAG1T( dl )
104 XS_TAG1T( dt )
105 XS_TAG1T( dd )
106 
107 // Tables
108 XS_TAG1D( table, false, css_d_table, css_ws_inherit )
109 XS_TAG1D( caption, true, css_d_table_caption, css_ws_inherit )
110 XS_TAG1D( colgroup, false, css_d_table_column_group, css_ws_inherit )
111 XS_TAG1D( col, false, css_d_table_column, css_ws_inherit )
112 XS_TAG1D( thead, false, css_d_table_header_group, css_ws_inherit )
113 XS_TAG1D( tbody, false, css_d_table_row_group, css_ws_inherit )
114 XS_TAG1D( tfoot, false, css_d_table_footer_group, css_ws_inherit )
115 XS_TAG1D( tr, false, css_d_table_row, css_ws_inherit )
116 XS_TAG1D( th, true, css_d_table_cell, css_ws_inherit )
117 XS_TAG1D( td, true, css_d_table_cell, css_ws_inherit )
118 
119 // Added 20180528
120 // Keep this block starting with "address" and ending with "xmp" as we
121 // are using: if (id >= el_address && id <= el_xmp) in lvrend.cpp
122 // Additional semantic block elements
123 XS_TAG1T( address )
124 XS_TAG1T( article )
125 XS_TAG1T( aside )
126 XS_TAG1T( canvas ) // no support for canvas, but keep it block
127 XS_TAG1T( fieldset )
128 XS_TAG1T( figcaption )
129 XS_TAG1T( figure )
130 XS_TAG1T( footer )
131 XS_TAG1T( header )
132 XS_TAG1T( hgroup )
133 XS_TAG1T( legend ) // child of fieldset, rendered as block by most browsers
134 XS_TAG1T( main )
135 XS_TAG1T( nav )
136 XS_TAG1T( noscript )
137 XS_TAG1T( video ) // no support for video, but keep it block
138 // Additional obsoleted block elements
139 XS_TAG1T( center )
140 XS_TAG1T( dir )    // similar to "ul"
141 XS_TAG1T( menu )   // similar to "ul"
142 // Other non-inline elements present in html5.css
143 XS_TAG1T( noframes )
144 XS_TAG1D( listing, true, css_d_block, css_ws_pre ) // similar to "pre"
145 XS_TAG1D( textarea, true, css_d_block, css_ws_pre ) // similar to "pre"
146 XS_TAG1D( plaintext, true, css_d_block, css_ws_pre ) // start of raw text (no end tag), not supported
147 XS_TAG1D( xmp, true, css_d_block, css_ws_pre ) // similar to "pre"
148 
149 // Added 20200824
150 // Keep this block starting with "details" and ending with "wbr" as we
151 // are using: if (id >= el_details && id <= el_wbr) in lvrend.cpp
152 // Additional semantic block elements
153 XS_TAG1T( details )
154 XS_TAG1T( dialog )
155 XS_TAG1T( summary )
156 // Additional "special" elements mentioned in the HTML standard,
157 // not supposed to close any P, but let's consider them similarly,
158 // and be block elements, so their content is shown.
159 XS_TAG1T( frame )
160 XS_TAG1T( frameset )
161 XS_TAG1T( iframe )
162 XS_TAG1T( noembed )
163 XS_TAG1T( template )
164 XS_TAG1T( select )
165 // BUTTON should not close a P, so we could have P > BUTTON > P,
166 // and other elements close a P "in button scope" - but we want to
167 // avoid nested Ps - so for our HTML parser, a BUTTON closes a P)
168 XS_TAG1T( button )
169 // HTML5: these 3 are special tags, that should not close any <P>,
170 // but they start a new "scope" that should not be crossed when
171 // other special tags are closing a P. As they are rare, we make
172 // them close a P too, just so that we'll never have nested Ps.
173 XS_TAG1T( marquee )
174 XS_TAG1( applet )
175 XS_TAG1( object )
176                 // HTML5: end of special tags, closing all
177                 // the way, and closing any <P>
178 // Other HTML elements with usually no content or no usable content
179 XS_TAG1T( optgroup ) // shown as block
180 XS_TAG1I( option )   // shown as inline
181 XS_TAG1T( map )
182 XS_TAG1( area )
183 XS_TAG1( track )
184 XS_TAG1( embed )
185 XS_TAG1( input )
186 XS_TAG1( keygen )
187 XS_TAG1( param )
188 XS_TAG1( audio )
189 XS_TAG1( source )
190 XS_TAG1I( picture ) // may contain one <img>, and multiple <source>
191 XS_TAG1I( wbr )
192 
193 // Limits for special handling by our HTML Parser (ldomDocumentWriterFilter)
194 #define EL_SPECIAL_START           el_html
195 #define EL_SPECIAL_END             el_wbr
196 #define EL_SPECIAL_CLOSING_P_START el_hr
197 #define EL_SPECIAL_CLOSING_P_END   el_object
198 
199 // Inline elements
200 XS_TAG1OBJ( img ) /* inline and specific handling as 'object' */
201 
202                 // HTML5: start of "active formatting elements"
203 XS_TAG1I( a )
204 XS_TAG1I( b )
205 XS_TAG1I( big )
206 XS_TAG1I( code ) // should not be css_ws_pre according to specs
207 XS_TAG1I( em )
208 XS_TAG1I( font )
209 XS_TAG1I( i )
210 XS_TAG1I( nobr )
211 XS_TAG1I( s )
212 XS_TAG1I( small )
213 XS_TAG1I( strike )
214 XS_TAG1I( strong )
215 XS_TAG1I( tt )
216 XS_TAG1I( u )
217                 // HTML5: end of "active formatting elements"
218                 // This is just for refence: we don't handle them specifically
219                 // (in HTML5, when mis-nested tags would close one of these,
220                 // they are re-opened when leaving the mis-nested tag container)
221 
222 XS_TAG1I( acronym )
223 XS_TAG1I( bdi )
224 XS_TAG1I( bdo )
225 XS_TAG1I( br )
226 XS_TAG1I( cite ) // conflict between HTML (inline) and FB2 (block): default here to inline (fb2.css puts it back to block)
227 XS_TAG1I( del )
228 XS_TAG1I( dfn )
229 XS_TAG1I( emphasis )
230 XS_TAG1I( ins )
231 XS_TAG1I( kbd )
232 XS_TAG1I( q )
233 XS_TAG1I( samp )
234 XS_TAG1I( span )
235 XS_TAG1I( sub )
236 XS_TAG1I( sup )
237 XS_TAG1I( var )
238 
239 // Ruby elements (defaults to inline)
240 XS_TAG1D( ruby, true, css_d_ruby, css_ws_inherit )
241 XS_TAG1I( rbc ) // no more in HTML5, but in 2001's https://www.w3.org/TR/ruby/
242 XS_TAG1I( rb )
243 XS_TAG1I( rtc )
244 XS_TAG1I( rt )
245 XS_TAG1I( rp )
246 
247 // EPUB3 elements (in ns_epub - otherwise set to inline like any unknown element)
248 XS_TAG1I( switch )  // <epub:switch>
249 XS_TAG1I( case )    // <epub:case required-namespace="...">
250 XS_TAG1I( default ) // <epub:default>
251 
252 // FB2 elements
253 XS_TAG1( FictionBook )
254 XS_TAG1( annotation )
255 XS_TAG1( author )
256 XS_TAG1( coverpage )
257 XS_TAG1( epigraph )
258 XS_TAG1( part )
259 XS_TAG1( poem )
260 XS_TAG1( stanza )
261 XS_TAG1D( binary, true, css_d_none, css_ws_inherit )
262 XS_TAG1D( description, false, css_d_none, css_ws_inherit )
263 XS_TAG1D( genre, true, css_d_none, css_ws_inherit )
264 XS_TAG1D( stylesheet, true, css_d_none, css_ws_inherit )
265 XS_TAG1I( spacing )
266 XS_TAG1I( strikethrough )
267 XS_TAG1I( underline )
268 XS_TAG1OBJ( image )
269 XS_TAG1T( city )
270 XS_TAG1T( date )
271 XS_TAG1T( email )
272 XS_TAG1T( history )
273 XS_TAG1T( id )
274 XS_TAG1T( isbn )
275 XS_TAG1T( keywords )
276 XS_TAG1T( lang )
277 XS_TAG1T( nickname )
278 XS_TAG1T( publisher )
279 XS_TAG1T( sequence )
280 XS_TAG1T( subtitle )
281 XS_TAG1T( v )
282 XS_TAG1T( version )
283 XS_TAG1T( year )
284 XS_TAG2( document_info, "document-info" )
285 XS_TAG2( empty_line, "empty-line" )
286 XS_TAG2( publish_info, "publish-info" )
287 XS_TAG2( src_title_info, "src-title-info" )
288 XS_TAG2( title_info, "title-info" )
289 XS_TAG2I( first_name, "first-name" )
290 XS_TAG2I( last_name, "last-name" )
291 XS_TAG2I( middle_name, "middle-name" )
292 XS_TAG2T( book_name, "book-name" )
293 XS_TAG2T( book_title, "book-title" )
294 XS_TAG2T( custom_info, "custom-info" )
295 XS_TAG2T( home_page, "home-page" )
296 XS_TAG2T( program_used, "program-used" )
297 XS_TAG2T( src_lang, "src-lang" )
298 XS_TAG2T( src_ocr, "src-ocr" )
299 XS_TAG2T( src_url, "src-url" )
300 XS_TAG2T( text_author, "text-author" )
301 
302 XS_END_TAGS
303 
304 
305 //=====================================================
306 // attr_ definitions
307 //=====================================================
308 XS_BEGIN_ATTRS
309 
310 XS_ATTR( id )
311 XS_ATTR( class )
312 XS_ATTR( value )
313 XS_ATTR( name )
314 XS_ATTR( number )
315 XS_ATTR( href )
316 XS_ATTR( type )
317 XS_ATTR( mode )
318 XS_ATTR( price )
319 XS_ATTR( style )
320 XS_ATTR( width )
321 XS_ATTR( height )
322 XS_ATTR( colspan )
323 XS_ATTR( rowspan )
324 XS_ATTR( rbspan )
325 XS_ATTR( align )
326 XS_ATTR( valign )
327 XS_ATTR( currency )
328 XS_ATTR( version )
329 XS_ATTR( encoding )
330 XS_ATTR( l )
331 XS_ATTR( xmlns )
332 XS_ATTR( genre )
333 XS_ATTR( xlink )
334 XS_ATTR( link )
335 XS_ATTR( xsi )
336 XS_ATTR( schemaLocation )
337 XS_ATTR( include )
338 XS_ATTR2( include_all, "include-all" )
339 XS_ATTR2( content_type, "content-type" )
340 XS_ATTR( StyleSheet )
341 XS_ATTR( title )
342 XS_ATTR( subtitle )
343 XS_ATTR( suptitle )
344 XS_ATTR( start )
345 XS_ATTR( reversed )
346 XS_ATTR( role )
347 XS_ATTR( dir )
348 XS_ATTR( lang )
349 XS_ATTR( recindex ) // used with mobi images
350 // Note that attributes parsed in the HTML are lowercased, unlike the ones
351 // we explicitely set while building the DOM. So, for our internal elements
352 // needs, let's use some uppercase to avoid conflicts with HTML content
353 // and the risk to have them matched by publishers CSS selectors.
354 XS_ATTR( T )      // to flag subtype of boxing internal elements if needed
355 XS_ATTR( Before ) // for pseudoElem internal element
356 XS_ATTR( After )  // for pseudoElem internal element
357 XS_ATTR( ParserHint )   // HTML parser hints (used for Lib.ru support)
358 XS_ATTR( NonLinear )    // for non-linear items in EPUB
359 // Other classic attributes present in html5.css
360 XS_ATTR2( accept_charset, "accept-charset" )
361 XS_ATTR( alt )
362 XS_ATTR( background )
363 XS_ATTR( bgcolor )
364 XS_ATTR( border )
365 XS_ATTR( cellpadding )
366 XS_ATTR( cellspacing )
367 XS_ATTR( clear )
368 XS_ATTR( color )
369 XS_ATTR( cols )
370 XS_ATTR( disabled )
371 XS_ATTR( face )
372 XS_ATTR( hidden )
373 XS_ATTR( hspace )
374 XS_ATTR2( http_equiv, "http-equiv" )
375 XS_ATTR( nowrap )
376 XS_ATTR( readonly )
377 XS_ATTR( rel )
378 XS_ATTR( rows )
379 XS_ATTR( rules )
380 XS_ATTR( scheme )
381 XS_ATTR( selected )
382 XS_ATTR( src )
383 XS_ATTR( tabindex )
384 XS_ATTR( target )
385 XS_ATTR( vspace )
386 XS_ATTR( wrap )
387 
388 XS_END_ATTRS
389 
390 
391 //=====================================================
392 // ns_ definitions
393 //=====================================================
394 XS_BEGIN_NS
395 
396 XS_NS( l )
397 XS_NS( xsi )
398 XS_NS( xmlns )
399 XS_NS( xlink )
400 XS_NS( xs )
401 XS_NS( epub )
402 
403 XS_END_NS
404 
405 
406 #endif // __FB2_DEF_H_INCLUDED__
407