From: <pau...@us...> - 2011-02-17 04:51:13
|
Author: paultremblay Date: 2011-02-17 05:51:04 +0100 (Thu, 17 Feb 2011) New Revision: 6870 Modified: trunk/sandbox/paultremblay/docutilsToFo/docutils_fo_dicts.py trunk/sandbox/paultremblay/docutilsToFo/make_stylesheet.py Log: Got rid of old, unneeded dicts; reorganized dicts and make_stylesheet.py to make handling of special cases much easier and straightforward; added dicts for bibliographic fields. Modified: trunk/sandbox/paultremblay/docutilsToFo/docutils_fo_dicts.py =================================================================== --- trunk/sandbox/paultremblay/docutilsToFo/docutils_fo_dicts.py 2011-02-17 04:48:31 UTC (rev 6869) +++ trunk/sandbox/paultremblay/docutilsToFo/docutils_fo_dicts.py 2011-02-17 04:51:04 UTC (rev 6870) @@ -242,9 +242,10 @@ 'warning-block': 'block', 'warning-title-block': 'block'} +#=========================================================== - short_cut_att_sets = { +'bibliographic-field':'bibliographic-fields-item-label-block', 'bibliographic-fields': 'bibliographic-fields-list-block', 'body': 'default-flow', 'bullet-list': 'bullet-list-block', @@ -271,905 +272,8 @@ - -att_set_dict_old = { -'abstract-block':['abstract-block', 'block'], -'abstract-paragraph-block':['abstract-paragraph-block', 'block'], -'abstract-title-block':['abstract-title-block', 'block'], -'address-value-block':['address-value-block', 'block'], -'admonition-custom-block':['admonition-custom-block', 'block'], -'admonition-custorm-title-block':['admonition-custorm-title-block', 'block'], -'admonition-first-paragraph-block':['admonition-first-paragraph-block', 'block'], -'admonition-paragraph-block':['admonition-paragraph-block', 'block'], -'attention-block':['attention-block', 'block'], -'attention-title-block':['attention-title-block', 'block'], -'basic-link-inline':['basic-link-inline', 'inline'], -'bibliographic-fields-block':['bibliographic-fields-block', 'block'], -'bibliographic-fields-front-list-block':['bibliographic-fields-front-list-block', 'list-block'], -'bibliographic-fields-item-body':['bibliographic-fields-item-body', 'item-body'], -'bibliographic-fields-item-label-block':['bibliographic-fields-item-label-block', 'block'], -'bibliographic-fields-list-block':['bibliographic-fields-list-block', 'list-block'], -'bibliographic-fields-list-item':['bibliographic-fields-list-item', 'list-item'], -'bibliographic-fields-list-item-label':['bibliographic-fields-list-item-label', 'item-label'], -'block-quote-attribution-block':['block-quote-attribution-block', 'block'], -'block-quote-first-paragraph-block':['block-quote-first-paragraph-block', 'block'], -'block-quote-outer-block':['block-quote-outer-block', 'block'], -'block-quote-paragraph-block':['block-quote-paragraph-block', 'block'], -'body-flow':['body-flow', 'flow'], -'body-page-sequence':['body-page-sequence', 'page-sequence'], -'body-simple-page-master':['body-simple-page-master', 'simple-page-master'], -'bullet-first-list-item':['bullet-first-list-item', 'list-item'], -'bullet-level2-list-block':['bullet-level2-list-block', 'list-block'], -'bullet-list-block':['bullet-list-block', 'list-block'], -'bullet-list-item':['bullet-list-item', 'list-item'], -'bullet-list-item-body':['bullet-list-item-body', 'item-body'], -'bullet-list-item-body-block':['bullet-list-item-body-block', 'block'], -'bullet-list-item-label':['bullet-list-item-label', 'item-label'], -'bullet-list-item-label-block':['bullet-list-item-label-block', 'block'], -'caption-block':['caption-block', 'block'], -'caution-block':['caution-block', 'block'], -'caution-title-block':['caution-title-block', 'block'], -'cell-block':['cell-block', 'block'], -'classifier-inline':['classifier-inline', 'inline'], -'container-first-paragraph-block':['container-first-paragraph-block', 'block'], -'container-outer-block':['container-outer-block', 'block'], -'container-paragraph-block':['container-paragraph-block', 'block'], -'danger-block':['danger-block', 'block'], -'danger-title-block':['danger-title-block', 'block'], -'dedication-block':['dedication-block', 'block'], -'dedication-paragraph-block':['dedication-paragraph-block', 'block'], -'dedication-title-block':['dedication-title-block', 'block'], -'default-admonition-outer-block':['default-admonition-outer-block', 'block'], -'default-admonition-title-block':['default-admonition-title-block', 'block'], -'default-cell':['default-cell', 'cell'], -'default-flow':['default-flow', 'flow'], -'default-footnote-label-inline':['default-footnote-label-inline', 'inline'], -'default-page-sequence':['default-page-sequence', 'page-sequence'], -'default-section-title-block':['default-section-title-block', 'block'], -'default-simple-page-master':['default-simple-page-master', 'simple-page-master'], -'definition-first-paragraph-block':['definition-first-paragraph-block', 'block'], -'definition-list-block':['definition-list-block', 'list-block'], -'definition-list-item-block':['definition-list-item-block', 'block'], -'definition-list-item-first-block':['definition-list-item-first-block', 'block'], -'definition-paragraph-block':['definition-paragraph-block', 'block'], -'definition-term-block':['definition-term-block', 'block'], -'definition-term-inline':['definition-term-inline', 'inline'], -'document-subtitle-block':['document-subtitle-block', 'block'], -'document-title-block':['document-title-block', 'block'], -'document-title-page-block':['document-title-page-block', 'block'], -'emphasis-inline':['emphasis-inline', 'inline'], -'endnote-block':['endnote-block', 'block'], -'endnote-first-block':['endnote-first-block', 'block'], -'endnotes-block':['endnotes-block', 'block'], -'endnotes-title-block':['endnotes-title-block', 'block'], -'enumerated-first-list-item':['enumerated-first-list-item', 'list-item'], -'enumerated-level2-list-block':['enumerated-level2-list-block', 'list-block'], -'enumerated-list-block':['enumerated-list-block', 'list-block'], -'enumerated-list-item':['enumerated-list-item', 'list-item'], -'enumerated-list-item-body':['enumerated-list-item-body', 'item-body'], -'enumerated-list-item-body-block':['enumerated-list-item-body-block', 'block'], -'enumerated-list-item-label':['enumerated-list-item-label', 'item-label'], -'epigraph-attribution-block':['epigraph-attribution-block', 'block'], -'epigraph-first-paragraph-block':['epigraph-first-paragraph-block', 'block'], -'epigraph-outer-block':['epigraph-outer-block', 'block'], -'epigraph-paragraph-block':['epigraph-paragraph-block', 'block'], -'error-block':['error-block', 'block'], -'error-title-block':['error-title-block', 'block'], -'even-simple-page-master':['even-simple-page-master', 'simple-page-master'], -'field-body-block':['field-body-block', 'block'], -'field-first-list-item':['field-first-list-item', 'list-item'], -'field-list-block':['field-list-block', 'list-block'], -'field-list-item':['field-list-item', 'list-item'], -'field-list-item-body':['field-list-item-body', 'item-body'], -'field-list-item-label':['field-list-item-label', 'item-label'], -'field-list-item-label-block':['field-list-item-label-block', 'block'], -'figure-block':['figure-block', 'block'], -'figure-caption-block':['figure-caption-block', 'block'], -'figure-legend-block':['figure-legend-block', 'block'], -'first-paragraph-block':['first-paragraph-block', 'bold'], -'first-simple-page-master':['first-simple-page-master', 'simple-page-master'], -'footer-block':['footer-block', 'block'], -'footer-first-block':['footer-first-block', 'block'], -'footer-region-after':['footer-region-after', 'region-after'], -'footer-second-block':['footer-second-block', 'block'], -'footer-third-block':['footer-third-block', 'block'], -'footnote':['footnote', 'footnote'], -'footnote-body':['footnote-body', 'footnote-body'], -'footnote-body-label-inline':['footnote-body-label-inline', 'inline'], -'footnote-first-paragraph-block':['footnote-first-paragraph-block', 'block'], -'footnote-item-body':['footnote-item-body', 'item-body'], -'footnote-item-label':['footnote-item-label', 'item-label'], -'footnote-label-block':['footnote-label-block', 'block'], -'footnote-label-inline':['footnote-label-inline', 'inline'], -'footnote-list-block':['footnote-list-block', 'list-block'], -'footnote-paragraph-block':['footnote-paragraph-block', 'block'], -'footnote-separator-block':['footnote-separator-block', 'block'], -'footnote-separator-flow':['footnote-separator-flow', 'flow'], -'front-body-simple-page-master':['front-body-simple-page-master', 'simple-page-master'], -'front-even-simple-page-master':['front-even-simple-page-master', 'simple-page-master'], -'front-first-simple-page-master':['front-first-simple-page-master', 'simple-page-master'], -'front-flow':['front-flow', 'flow'], -'front-matter-region-body':['front-matter-region-body', 'region-body'], -'front-odd-simple-page-master':['front-odd-simple-page-master', 'simple-page-master'], -'front-page-sequence':['front-page-sequence', 'page-sequence'], -'front-simple-page-master':['front-simple-page-master', 'simple-page-master'], -'header-block':['header-block', 'block'], -'header-first-block':['header-first-block', 'block'], -'header-region-before':['header-region-before', 'region-before'], -'header-second-block':['header-second-block', 'block'], -'header-third-block':['header-third-block', 'block'], -'highlights-first-paragraph-block':['highlights-first-paragraph-block', 'block'], -'highlights-outer-block':['highlights-outer-block', 'block'], -'highlights-paragraph-block':['highlights-paragraph-block', 'block'], -'hint-block':['hint-block', 'block'], -'hint-title-block':['hint-title-block', 'block'], -'image-block':['image-block', 'block'], -'important-block':['important-block', 'block'], -'important-title-block':['important-title-block', 'block'], -'legend-first-paragraph-block':['legend-first-paragraph-block', 'block'], -'legend-paragraph-block':['legend-paragraph-block', 'block'], -'level1-line-block':['level1-line-block', 'block'], -'level2-line-block':['level2-line-block', 'block'], -'level3-line-block':['level3-line-block', 'block'], -'level4-line-block':['level4-line-block', 'block'], -'level5-line-block':['level5-line-block', 'block'], -'literal-block':['literal-block', 'block'], -'literal-inline':['literal-inline', 'inline'], -'note-block':['note-block', 'block'], -'note-title-block':['note-title-block', 'block'], -'odd-simple-page-master':['odd-simple-page-master', 'simple-page-master'], -'option-argument-inline':['option-argument-inline', 'inline'], -'option-first-list-item':['option-first-list-item', 'list-item'], -'option-group-block':['option-group-block', 'block'], -'option-inline':['option-inline', 'inline'], -'option-list-block':['option-list-block', 'list-block'], -'option-list-definition-block':['option-list-definition-block', 'block'], -'option-list-description-block':['option-list-description-block', 'block'], -'option-list-description-first-block':['option-list-description-first-block', 'block'], -'option-list-first-item-block':['option-list-first-item-block', 'block'], -'option-list-item':['option-list-item', 'list-item'], -'option-list-item-block':['option-list-item-block', 'block'], -'option-list-item-body':['option-list-item-body', 'item-body'], -'option-list-item-body-block':['option-list-item-body-block', 'block'], -'option-list-item-label':['option-list-item-label', 'item-label'], -'option-list-item-label-block':['option-list-item-label-block', 'block'], -'outer-line-block':['outer-line-block', 'block'], -'paper-size-simple-page-master':['paper-size-simple-page-master', 'simple-page-master'], -'paragraph-block':['paragraph-block', 'block'], -'pull-quote-attribution-block':['pull-quote-attribution-block', 'block'], -'pull-quote-first-paragraph-block':['pull-quote-first-paragraph-block', 'block'], -'pull-quote-outer-block':['pull-quote-outer-block', 'block'], -'pull-quote-paragraph-block':['pull-quote-paragraph-block', 'block'], -'region-body':['region-body', 'region-body'], -'rubric-block':['rubric-block', 'block'], -'sidebar-block':['sidebar-block', 'block'], -'sidebar-first-paragraph-block':['sidebar-first-paragraph-block', 'block'], -'sidebar-paragraph-block':['sidebar-paragraph-block', 'block'], -'sidebar-subtitle-block':['sidebar-subtitle-block', 'block'], -'sidebar-title-block':['sidebar-title-block', 'block'], -'simple-page-master':['simple-page-master', 'simple-page-master'], -'strong-inline':['strong-inline', 'inline'], -'table':['table', 'table'], -'table-block-container':['table-block-container', 'block-container'], -'table-body':['table-body', 'table-body'], -'table-cell':['table-cell', 'cell'], -'table-row':['table-row', 'table-row'], -'thead-block':['thead-block', 'block'], -'thead-borderless-cell':['thead-borderless-cell', 'cell'], -'thead-cell':['thead-cell', 'cell'], -'thead-header':['thead-header', 'header'], -'tip-block':['tip-block', 'block'], -'tip-title-block':['tip-title-block', 'block'], -'title-level1-block':['title-level1-block', 'block'], -'title-level2-block':['title-level2-block', 'block'], -'title-level3-block':['title-level3-block', 'block'], -'title-level4-block':['title-level4-block', 'block'], -'title-level5-block':['title-level5-block', 'block'], -'title-level6-block':['title-level6-block', 'block'], -'title-level7-block':['title-level7-block', 'block'], -'title-level8-block':['title-level8-block', 'block'], -'title-level9-block':['title-level9-block', 'block'], -'title-number-inline':['title-number-inline', 'inline'], -'title-reference-inline':['title-reference-inline', 'inline'], -'toc-body-simple-page-master':['toc-body-simple-page-master', 'simple-page-master'], -'toc-entry-defaults-block':['toc-entry-defaults-block', 'block'], -'toc-even-simple-page-master':['toc-even-simple-page-master', 'simple-page-master'], -'toc-first-simple-page-master':['toc-first-simple-page-master', 'simple-page-master'], -'toc-flow':['toc-flow', 'flow'], -'toc-level1-block':['toc-level1-block', 'block'], -'toc-level2-block':['toc-level2-block', 'block'], -'toc-level3-block':['toc-level3-block', 'block'], -'toc-level4-block':['toc-level4-block', 'block'], -'toc-level5-block':['toc-level5-block', 'block'], -'toc-odd-simple-page-master':['toc-odd-simple-page-master', 'simple-page-master'], -'toc-page-sequence':['toc-page-sequence', 'page-sequence'], -'toc-simple-page-master':['toc-simple-page-master', 'simple-page-master'], -'toc-title-block':['toc-title-block', 'block'], -'topic-block':['topic-block', 'block'], -'topic-first-paragraph-block':['topic-first-paragraph-block', 'block'], -'topic-paragraph-block':['topic-paragraph-block', 'block'], -'topic-title-block':['topic-title-block', 'block'], -'transition-block':['transition-block', 'block'], -'warning-block':['warning-block', 'block'], -'warning-title-block':['warning-title-block', 'block'], -} -# ======================================================= -# CUSTOMIZE ATT SETS -# ======================================================= -added_att_sets = { -'bullet-list':['bullet-list-block', 'list-block'], -'document':['default-page-sequence', 'page-sequence'], -'page':['default-simple-page-master', 'simple-page-master'], -'even-page':['even-simple-page-master', 'simple-page-master'], -'first-page':['first-simple-page-master', 'simple-page-master'], -'odd-page':['odd-simple-page-master', 'simple-page-master'], -'paper-size':['paper-size-simple-page-master', 'simple-page-master'], -'paragraph':['paragraph-block', 'block'], -'first-paragraph':['first-paragraph-block', 'block'], -'body':['default-flow', 'flow'], -'header':['header-block', 'block'], -'header-first-paragraph':['header-first-block', 'block'], -'header-second-paragraph':['header-second-block', 'block'], -'header-third-paragraph':['header-third-block', 'block'], -'footer-first-paragraph':['footer-first-block', 'block'], -'footer-second-paragraph':['footer-second-block', 'block'], -'footer-third-paragraph':['footer-third-block', 'block'], -'title-subtitle':['document-title-page-block', 'block'], -'title':['document-title-block', 'block'], -'subtitle':['document-subtitle-block', 'block'], -'bibliographic-fields':['bibliographic-fields-list-block', 'list-block'], -} - -att_set_dict.update(added_att_sets) - -# ===================================================================== -# ATTS -# ===================================================================== -padding_dict = { -'padding-after': 'padding-after', -'padding-before': 'padding-before', -'padding-bottom': 'padding-bottom', -'padding-end': 'padding-end', -'padding-left': 'padding-left', -'padding-right': 'padding-right', -'padding-start': 'padding-start', -'padding-top': 'padding-top', -} - -margin_dict = { -'margin-bottom': 'margin-bottom', -'margin-left': 'margin-left', -'margin-right': 'margin-right', -'margin-top': 'margin-top', -} - -font_dict = { -'color': 'color', -'font-family': 'font-family', -'font-selection-strategy': 'font-selection-strategy', -'font-size': 'font-size', -'font-size-adjust': 'font-size-adjust', -'font-stretch': 'font-stretch', -'font-style': 'font-style', -'font-variant': 'font-variant', -'font-weight': 'font-weight', -} -keep_with_dict = { -'keep-together': 'keep-together', -'keep-with-next': 'keep-with-next', -'keep-with-previous': 'keep-with-previous', -} - -# common items for block and inline, minus azimuth -block_inline_dict = { -'color': 'color', -'font-family': 'font-family', -'font-selection-strategy': 'font-selection-strategy', -'font-size': 'font-size', -'font-size-adjust': 'font-size-adjust', -'font-stretch': 'font-stretch', -'font-style': 'font-style', -'font-variant': 'font-variant', -'font-weight': 'font-weight', -'keep-together': 'keep-together', -'keep-with-next': 'keep-with-next', -'keep-with-previous': 'keep-with-previous', -'line-height': 'line-height', -'visibility': 'visibility', -'wrap-option': 'wrap-option' -} - -sound_dict = { -'azimuth': 'azimuth', -'cue-after': 'cue-after', -'cue-before': 'cue-before', -'elevation': 'elevation', -'pause-after': 'pause-after', -'pause-before': 'pause-before', -'pitch': 'pitch', -'pitch-range': 'pitch-range', -'play-during': 'play-during', -'relative-position': 'relative-position', -'richness': 'richness', -'speak': 'speak', -'speak-header': 'speak-header', -'speak-numeral': 'speak-numeral', -'speak-punctuation': 'speak-punctuation', -'speech-rate': 'speech-rate', -'stress': 'stress', -'voice-family': 'voice-family', -'volume': 'volume'} - -common_dict1 = { -'background-attachment': 'background-attachment', -'background-color': 'background-color', -'background-image': 'background-image', -'background-position-horizontal': 'background-position-horizontal', -'background-position-vertical': 'background-position-vertical', -'background-repeat': 'background-repeat', -'border-after-color': 'border-after-color', -'border-after-style': 'border-after-style', -'border-after-width': 'border-after-width', -'border-before-color': 'border-before-color', -'border-before-style': 'border-before-style', -'border-before-width': 'border-before-width', -'border-bottom-color': 'border-bottom-color', -'border-bottom-style': 'border-bottom-style', -'border-bottom-width': 'border-bottom-width', -'border-end-color': 'border-end-color', -'border-end-style': 'border-end-style', -'border-end-width': 'border-end-width', -'border-left-color': 'border-left-color', -'border-left-style': 'border-left-style', -'border-left-width': 'border-left-width', -'border-right-color': 'border-right-color', -'border-right-style': 'border-right-style', -'border-right-width': 'border-right-width', -'border-start-color': 'border-start-color', -'border-start-style': 'border-start-style', -'border-start-width': 'border-start-width', -'border-top-color': 'border-top-color', -'border-top-style': 'border-top-style', -'border-top-width': 'border-top-width', -'bottom': 'bottom', -'id': 'id', -'left': 'left', -'right': 'right', -'role': 'role', -'source-document': 'source-document', -'top': 'top', -} - -just_block_dict = { -'break-after': 'break-after', -'break-before': 'break-before', -'country': 'country', -'end-indent': 'end-indent', -'hyphenate': 'hyphenate', -'hyphenation-character': 'hyphenation-character', -'hyphenation-keep': 'hyphenation-keep', -'hyphenation-ladder-count': 'hyphenation-ladder-count', -'hyphenation-push-character-count': 'hyphenation-push-character-count', -'hyphenation-remain-character-count': 'hyphenation-remain-character-count', -'intrusion-displace': 'intrusion-displace', -'language': 'language', -'last-line-end-indent': 'last-line-end-indent', -'line-height-shift-adjustment': 'line-height-shift-adjustment', -'line-stacking-strategy': 'line-stacking-strategy', -'linefeed-treatment': 'linefeed-treatment', -'orphans': 'orphans', -'script': 'script', -'space-after': 'space-after', -'space-before': 'space-before', -'span': 'span', -'start-indent': 'start-indent', -'text-align': 'text-align', -'text-align-last': 'text-align-last', -'text-altitude': 'text-altitude', -'text-depth': 'text-depth', -'text-indent': 'text-indent', -'white-space-collapse': 'white-space-collapse', -'white-space-treatment': 'white-space-treatment', -'widows': 'widows' -} - -just_block_container_dict = { -'absolute-position': 'absolute-position', -'break-after': 'break-after', -'break-before': 'break-before', -'clip': 'clip', -'display-align': 'display-align', -'end-indent': 'end-indent', -'height': 'height', -'inline-progression-dimension': 'inline-progression-dimension', -'intrusion-displace': 'intrusion-displace', -'keep-on-same-page': 'keep-on-same-page', -'keep-together': 'keep-together', -'keep-with-next': 'keep-with-next', -'keep-with-previous': 'keep-with-previous', -'overflow': 'overflow', -'reference-orientation': 'reference-orientation', -'space-after': 'space-after', -'space-before': 'space-before', -'span': 'span', -'start-indent': 'start-indent', -'width': 'width', -'writing-mode': 'writing-mode', -'z-index': 'z-index' -} - -# properties unique to inline, minus azimuth and block_inline -just_inline_dict = { -'alignment-adjust': 'alignment-adjust', -'alignment-baseline': 'alignment-baseline', -'baseline-shift': 'baseline-shift', -'block-progression-dimension': 'block-progression-dimension', -'dominant-baseline': 'dominant-baseline', -'height': 'height', -'inline-progression-dimension': 'inline-progression-dimension', -'space-end': 'space-end', -'space-start': 'space-start', -'text-decoration': 'text-decoration', -'width': 'width' -} - -# properties unique to cell, minus azimuth -just_cell_dict = { -'block-progression-dimension': 'block-progression-dimension', -'border-after-precedence': 'border-after-precedence', -'border-before-precedence': 'border-before-precedence', -'border-end-precedence': 'border-end-precedence', -'border-start-precedence': 'border-start-precedence', -'column-number': 'column-number', -'display-align': 'display-align', -'empty-cells': 'empty-cells', -'ends-row': 'ends-row', -'height': 'height', -'inline-progression-dimension': 'inline-progression-dimension', -'number-columns-spanned': 'number-columns-spanned', -'number-rows-spanned': 'number-rows-spanned', -'starts-row': 'starts-row', -'width': 'width' -} - -just_header_dict = { -'border-after-precedence': 'border-after-precedence', -'border-before-precedence': 'border-before-precedence', -'border-collapse': 'border-collapse', -'border-end-precedence': 'border-end-precedence', -'border-separation': 'border-separation', -'border-start-precedence': 'border-start-precedence', -'visibility': 'visibility' -} - -just_list_item_dict = { -'break-after': 'break-after', -'break-before': 'break-before', -'end-indent': 'end-indent', -'intrusion-displace': 'intrusion-displace', -'keep-on-same-page': 'keep-on-same-page', -'keep-together': 'keep-together', -'keep-with-next': 'keep-with-next', -'keep-with-previous': 'keep-with-previous', -'relative-align': 'relative-align', -'space-after': 'space-after', -'space-before': 'space-before', -'start-indent': 'start-indent'} - -just_list_block_dict = { -'provisional-distance-between-starts': 'provisional-distance-between-starts', -'provisional-label-separation': 'provisional-label-separation', -} -just_table_dict = { -'block-progression-dimension': 'block-progression-dimension', -'border-after-precedence': 'border-after-precedence', -'border-before-precedence': 'border-before-precedence', -'border-collapse': 'border-collapse', -'border-end-precedence': 'border-end-precedence', -'border-separation': 'border-separation', -'border-start-precedence': 'border-start-precedence', -'break-after': 'break-after', -'break-before': 'break-before', -'end-indent': 'end-indent', -'height': 'height', -'inline-progression-dimension': 'inline-progression-dimension', -'intrusion-displace': 'intrusion-displace', -'keep-on-same-page': 'keep-on-same-page', -'keep-together': 'keep-together', -'keep-with-next': 'keep-with-next', -'keep-with-previous': 'keep-with-previous', -'space-after': 'space-after', -'space-before': 'space-before', -'start-indent': 'start-indent', -'table-layout': 'table-layout', -'table-omit-footer-at-break': 'table-omit-footer-at-break', -'table-omit-header-at-break': 'table-omit-header-at-break', -'width': 'width', -'writing-mode': 'writing-mode' -} - -just_table_row_dict = { -'block-progression-dimension': 'block-progression-dimension', -'border-after-precedence': 'border-after-precedence', -'border-before-precedence': 'border-before-precedence', -'border-collapse': 'border-collapse', -'border-end-precedence': 'border-end-precedence', -'border-separation': 'border-separation', -'border-start-precedence': 'border-start-precedence', -'break-after': 'break-after', -'break-before': 'break-before', -'height': 'height', -'keep-on-same-page': 'keep-on-same-page', -'keep-together': 'keep-together', -'keep-with-next': 'keep-with-next', -'keep-with-previous': 'keep-with-previous', -'visibility': 'visibility'} - -just_region_body_dict = { -'bottom': 'bottom', -'clip': 'clip', -'column-count': 'column-count', -'column-gap': 'column-gap', -'display-align': 'display-align', -'end-indent': 'end-indent', -'id': 'id', -'left': 'left', -'overflow': 'overflow', -'reference-orientation': 'reference-orientation', -'region-name': 'region-name', -'right': 'right', -'role': 'role', -'source-document': 'source-document', -'space-after': 'space-after', -'space-before': 'space-before', -'top': 'top', -'writing-mode': 'writing-mode'} - -just_region_after_dict = { -'bottom': 'bottom', -'clip': 'clip', -'display-align': 'display-align', -'extent': 'extent', -'id': 'id', -'left': 'left', -'overflow': 'overflow', -'precedence': 'precedence', -'reference-orientation': 'reference-orientation', -'region-name': 'region-name', -'right': 'right', -'role': 'role', -'source-document': 'source-document', -'top': 'top', -'writing-mode': 'writing-mode'} -# ====================================================================== -# put dicts together -block_dict = {} -block_dict.update(block_inline_dict) -block_dict.update(margin_dict) -block_dict.update(padding_dict) -block_dict.update(common_dict1) -block_dict.update(sound_dict) -block_dict.update(just_block_dict) - -inline_dict = {} -inline_dict.update(block_inline_dict) -inline_dict.update(margin_dict) -inline_dict.update(padding_dict) -inline_dict.update(common_dict1) -inline_dict.update(sound_dict) -inline_dict.update(just_inline_dict) - -cell_dict = {} -cell_dict.update(common_dict1) -cell_dict.update(padding_dict) -cell_dict.update(sound_dict) -cell_dict.update(just_cell_dict) - -header_dict = {} -header_dict.update(common_dict1) -header_dict.update(sound_dict) -header_dict.update(just_header_dict) - -list_item_dict = {} -list_item_dict.update(common_dict1) -list_item_dict.update(margin_dict) -list_item_dict.update(padding_dict) -list_item_dict.update(sound_dict) -list_item_dict.update(just_list_item_dict) - -list_block_dict = {} -list_block_dict.update(list_item_dict) -list_block_dict.update(just_list_block_dict) - -block_container_dict = {} -block_container_dict.update(common_dict1) -block_container_dict.update(margin_dict) -block_container_dict.update(padding_dict) -block_container_dict.update(just_block_container_dict) - -table_dict = {} -table_dict.update(common_dict1) -table_dict.update(margin_dict) -table_dict.update(padding_dict) -table_dict.update(sound_dict) -table_dict.update(just_table_dict) - -table_row_dict = {} -table_row_dict.update(common_dict1) -table_row_dict.update(sound_dict) -table_row_dict.update(just_table_row_dict) - -region_body_dict = {} -region_body_dict.update(common_dict1) -region_body_dict.update(margin_dict) -region_body_dict.update(padding_dict) -region_body_dict.update(just_region_body_dict) -del(region_body_dict['top']) -del(region_body_dict['bottom']) -del(region_body_dict['right']) -del(region_body_dict['left']) -del(region_body_dict['source-document']) - -region_after_dict = {} -region_after_dict.update(common_dict1) -region_after_dict.update(padding_dict) -region_after_dict.update(just_region_after_dict) -del(region_after_dict['top']) -del(region_after_dict['bottom']) -del(region_after_dict['right']) -del(region_after_dict['left']) -del(region_after_dict['source-document']) - -flow_dict = {'flow-name': 'flow-name'} - -footnote_dict = {'role': 'role', 'source-document': 'source-document'} -footnote_body_dict = {} -footnote_body_dict.update(footnote_dict) - -item_body_dict = { -'Property' : 'Property', -'id' : 'id', -'keep-together' : 'keep-together', -'role' : 'role', -'source-document' : 'source-document', -} - -item_label_dict = {} -item_label_dict.update(item_body_dict) - - -page_sequence_dict = { -'Property' : 'Property', -'country' : 'country', -'force-page-count' : 'force-page-count', -'format' : 'format', -'grouping-separator' : 'grouping-separator', -'grouping-size' : 'grouping-size', -'id' : 'id', -'initial-page-number' : 'initial-page-number', -'language' : 'language', -'letter-value' : 'letter-value', -'master-reference' : 'master-reference', -} - - -region_before_dict = { } -region_before_dict.update(region_after_dict) - -simple_page_master_dict = { -'end-indent' : 'end-indent', -'margin-bottom' : 'margin-bottom', -'margin-left' : 'margin-left', -'margin-right' : 'margin-right', -'margin-top' : 'margin-top', -'master-name' : 'master-name', -'page-height' : 'page-height', -'height' : 'page-height', -'page-width' : 'page-width', -'width' : 'page-width', -'reference-orientation' : 'reference-orientation', -'space-after' : 'space-after', -'space-before' : 'space-before', -'start-indent' : 'start-indent', -'writing-mode' : 'writing-mode', -} -table_body_dict = {} -table_body_dict.update(header_dict) - -# ============================================================= -# CUSTOMIZE -# ============================================================= - -custom_margin_dict = { -'bottom-margin' : 'margin-bottom', -'left-margin' : 'margin-left', -'right-margin' : 'margin-right', -'top-margin' : 'margin-top', -} -simple_page_master_dict.update(custom_margin_dict) - -# font family -font_dict = { 'font': 'font-family', } - -# line height-short terms -line_height_dict = {'line-spacing':'line-height'} -page_sequence_dict.update(font_dict) -page_sequence_dict.update({'font-size':'font-size'}) -block_dict.update(font_dict) -inline_dict.update(font_dict) -block_dict.update(line_height_dict) -inline_dict.update(line_height_dict) -flow_dict.update(line_height_dict) - -# block dict short terms -custom_block_atts_dict = { -'first-line-indent': 'text-indent', -'left-indent': 'start-indent', -'right-indent': 'end-indent', -'alignment':'text-align', - } - - -block_dict.update(custom_block_atts_dict) - -keep_together_dict = { -'keep-on-same-page': 'keep-together.within-page', -} -block_dict.update(keep_together_dict) -block_container_dict.update(keep_together_dict) -inline_dict.update(keep_together_dict) -item_body_dict.update(keep_together_dict) -list_item_dict.update(keep_together_dict) -list_block_dict.update(keep_together_dict) -table_dict.update(keep_together_dict) -table_row_dict.update(keep_together_dict) - -border_simple_dict = {'border' : 'border', -'border-bottom' : 'border-bottom', -'border-top' : 'border-top', -'border-left' : 'border-left', -'border-right' : 'border-right', -} -block_dict.update(border_simple_dict) - -# font-style short terms -font_style_dict={'bold': [('font-weight','bold')], -'italic': [('font-style','italic')], -'bold-italic':[('font-weight','bold'), ('font-style','italic')], -'italic-bold':[('font-weight','bold'), ('font-style','italic')], -'normal':[('font-weight', 'normal'), ('font-style', 'normal')], -} - - -special_atts_dict = {'font-style':[True], - 'page-break-before':[True], - 'page-break-after':[True], - 'keep-with-next':[True], - 'keep-with-previous':[True], - 'keep-on-same-page':[True], - } - -special_att_sets_dict = { - 'header':[True], - 'footer':[True], - } - - -# true_of_false -special_values_dict = { - } - - -which_dict = { -'block': block_dict, -'block-container': block_container_dict, -'cell': cell_dict, -'flow': flow_dict, -'footnote-body': footnote_body_dict, -'header': header_dict, -'inline': inline_dict, -'item-body': item_body_dict, -'item-label': item_label_dict, -'list-block':list_block_dict, -'list-item': list_item_dict, -'page-sequence': page_sequence_dict, -'region-after': region_after_dict, -'region-before': region_before_dict, -'region-body': region_body_dict, -'simple-page-master': simple_page_master_dict, -'table': table_dict, -'table-body': table_body_dict, -'table-row': table_row_dict, -} - -# properties that are really params -prop_as_param_dict = { -'page.page-layout':'page-layout', -'title-subtitle.placement': 'title-pagination', -'bibliographic-fields.placement' : 'bibliographic-pagination', -'dedication.placement': 'dedication-pagination', -'abstract.placement': 'abstract-pagination', -'toc.placement': 'toc-pagination', -'front.order': 'font-order', -} - - - -# default params -param_dict = { -'abstract-pagination' : 'with-front', -'address-text' : 'Address: ', -'attention-title' : 'Attention!', -'author-text' : 'Author: ', -'authors-text' : 'Authors: ', -'bibliographic-pagination' : 'with-toc', -'bullet-text' : '•', -'caution-title' : 'Caution!', -'contact-text' : 'Contact: ', -'copyright-text' : 'Copyright: ', -'danger-title' : '!Danger!', -'date-text' : 'Date: ', -'dedication-pagination' : 'with-front', -'error-title' : 'Error', -'footnote-placement' : 'footnote', -'footnote-style' : 'list', -'front-order' : 'title,bibliographic,dedication,abstract,toc', -'hint-title' : 'Hint', -'important-title' : 'Important', -'inherit-section-num' : 'True', -'internal-link-type' : 'link', -'note-title' : 'Note', -'number-section1' : '1', -'number-section2' : '.1', -'number-section3' : '.1', -'number-section4' : '.1', -'number-section5' : '.1', -'number-section6' : '.1', -'number-section7' : '.1', -'number-section8' : '.1', -'number-section9' : '.1', -'number-verse' : '', -'option-list-format' : 'list', -'options-separator' : ', ', -'organization-text' : 'Organization: ', -'page-layout' : 'simple', -'revision-text' : 'Revision: ', -'space-between-footnotes' : '5pt', -'spacing-footer' : '', -'spacing-header' : '', -'status-text' : 'Status: ', -'strict' : '', -'suppress-first-page-footer' : '', -'suppress-first-page-header' : '', -'table-title-placement' : 'bottom', -'test' : '', -'text-before-block-quote-attribution' : '—', -'text-before-epigraph-attribution' : '—', -'text-before-pull-quote-attribution' : '—', -'tip-title' : 'Tip', -'title-pagination' : 'with-front', -'toc-pagination' : 'with-toc', -'transition-text' : '***', -'version-text' : 'Version: ', -'warning-title' : 'Warning!', -} -param_list = param_dict.keys() -true_or_false_dict = {'True':'True', 'true':'True', 'yes':'True', 'Yes': 'True', 'False': 'False', - 'false':'False', 'no': 'False', 'No':'False'} -true_dict = {'true':True, 'True':True, 'yes':True, 'Yes':True} -false_dict = {'false':False, 'False':False, 'none': False, 'None':False, 'no': False, 'No':False} -param_dict_test = {'strict':true_or_false_dict, - 'suppress-first-page-header': true_or_false_dict, - 'suppress-first-page-footer': true_or_false_dict, - } - -commands_list = ['xsl-stylesheet'] - +# ATT LISTS # ========================================================================== -# ========================================================================== -# ========================================================================== -# ========================================================================== -# ========================================================================== accessibility_properties = [ 'source-document', @@ -1714,6 +818,167 @@ 'right-indent': 'end-indent', 'alignment':'text-align', 'keep-on-same-page': 'keep-together.within-page', -# 'font': 'font-family', +'font': 'font-family', # could be problamatic +'space-from-label': 'provisional-distance-between-starts', } +special_atts_dict = { + } + +special_att_sets_dict = { + } + +# att att-sets +special_att_att_set_dict = { +('bold', 'font-style'): [('font-weight','bold')], +('italic', 'font-style'): [('font-style','italic')], +('bold-italic', 'font-style'):[('font-weight','bold'), ('font-style','italic')], +('italic-bold', 'font-style'):[('font-weight','bold'), ('font-style','italic')], +('normal', 'font-style'):[('font-weight', 'normal'), ('font-style', 'normal')] +} + +# att-sets atts +special_att_set_att_dict = { +('bibliographic-fields', 'space-from-field'): [('bibliographic-fields-list-block', 'provisional-distance-between-starts')], +('bibliographic-fields', 'space-between-items'): [('bibliographic-fields-list-item', 'space-before')], +('header' , 'height'):[('header-region-before', 'extent')], +('footer' , 'height'):[('footer-region-after', 'extent')], +} +special_att_value_dict = { +('font-style', 'bold'): [('font-weight','bold')], +('font-style', 'italic'): [('font-style','italic')], +('font-style','bold-italic'):[('font-weight','bold'), ('font-style','italic')], +('font-style','italic-bold' ):[('font-weight','bold'), ('font-style','italic')], +('font-style', 'normal'):[('font-weight', 'normal'), ('font-style', 'normal')], +('page-break-before' , 'True'):[('break-before', 'page')], +('page-break-before' , 'true'):[('break-before', 'page')], +('page-break-before' , 'Yes'):[('break-before', 'page')], +('page-break-before' , 'yes'):[('break-before', 'page')], +('page-break-before' , 'False'):[('break-before', 'auto')], +('page-break-before' , 'ralse'):[('break-before', 'auto')], +('page-break-before' , 'No'):[('break-before', 'auto')], +('page-break-before' , 'no'):[('break-before', 'auto')], +('page-break-after' , 'True'):[('break-after', 'page')], +('page-break-after' , 'true'):[('break-after', 'page')], +('page-break-after' , 'Yes'):[('break-after', 'page')], +('page-break-after' , 'yes'):[('break-after', 'page')], +('page-break-after' , 'False'):[('break-after', 'auto')], +('page-break-after' , 'ralse'):[('break-after', 'auto')], +('page-break-after' , 'No'):[('break-after', 'auto')], +('page-break-after' , 'no'):[('break-after', 'auto')], +('keep-with-next' , 'True'):[('keep-with-next', 'always')], +('keep-with-next' , 'true'):[('keep-with-next', 'always')], +('keep-with-next' , 'Yes'):[('keep-with-next', 'always')], +('keep-with-next' , 'yes'):[('keep-with-next', 'always')], +('keep-with-previous' , 'True'):[('keep-with-previous', 'always')], +('keep-with-previous' , 'true'):[('keep-with-previous', 'always')], +('keep-with-previous' , 'Yes'):[('keep-with-previous', 'always')], +('keep-with-previous' , 'yes'):[('keep-with-previous', 'always')], +('keep-on-same-page' , 'True'):[('keep-together.within-page', 'always')], +('keep-on-same-page' , 'true'):[('keep-together.within-page', 'always')], +('keep-on-same-page' , 'Yes'):[('keep-together.within-page', 'always')], +('keep-on-same-page' , 'yes'):[('keep-together.within-page', 'always')], +} + +special_values_dict = { + } + + +# ================================================================== +# PROPERTIES THAT ARE REALLY PARAMS + +prop_as_param_dict = { +'page.page-layout':'page-layout', +'title-subtitle.placement': 'title-pagination', +'bibliographic-fields.placement' : 'bibliographic-pagination', +'dedication.placement': 'dedication-pagination', +'abstract.placement': 'abstract-pagination', +'toc.placement': 'toc-pagination', +'front.order': 'font-order', +'header.suppress-first-page': 'suppress-first-page-header', +'footer.suppress-first-page': 'suppress-first-page-footer', +'bibliographic-fields.author-text': 'author-text', +'bibliographic-fields.authors-text': 'authors-text', +'bibliographic-fields.organization-text': 'organization-text', +'bibliographic-fields.contact-text': 'contact-text', +'bibliographic-fields.status-text': 'status-text', +'bibliographic-fields.copyright-text': 'copyright-text', +'bibliographic-fields.address-text': 'address-text', +'bibliographic-fields.revision-text': 'revision-text', +'bibliographic-fields.date-text': 'date-text', +} + + +# ======================================================================== +# DEFAULT PARAMS +param_dict = { +'abstract-pagination' : 'with-front', +'address-text' : 'Address: ', +'attention-title' : 'Attention!', +'author-text' : 'Author: ', +'authors-text' : 'Authors: ', +'bibliographic-pagination' : 'with-toc', +'bullet-text' : '•', +'caution-title' : 'Caution!', +'contact-text' : 'Contact: ', +'copyright-text' : 'Copyright: ', +'danger-title' : '!Danger!', +'date-text' : 'Date: ', +'dedication-pagination' : 'with-front', +'error-title' : 'Error', +'footnote-placement' : 'footnote', +'footnote-style' : 'list', +'front-order' : 'title,bibliographic,dedication,abstract,toc', +'hint-title' : 'Hint', +'important-title' : 'Important', +'inherit-section-num' : 'True', +'internal-link-type' : 'link', +'note-title' : 'Note', +'number-section1' : '1', +'number-section2' : '.1', +'number-section3' : '.1', +'number-section4' : '.1', +'number-section5' : '.1', +'number-section6' : '.1', +'number-section7' : '.1', +'number-section8' : '.1', +'number-section9' : '.1', +'number-verse' : '', +'option-list-format' : 'list', +'options-separator' : ', ', +'organization-text' : 'Organization: ', +'page-layout' : 'simple', +'revision-text' : 'Revision: ', +'space-between-footnotes' : '5pt', +'spacing-footer' : '', +'spacing-header' : '', +'status-text' : 'Status: ', +'strict' : '', +'suppress-first-page-footer' : '', +'suppress-first-page-header' : '', +'table-title-placement' : 'bottom', +'test' : '', +'text-before-block-quote-attribution' : '—', +'text-before-epigraph-attribution' : '—', +'text-before-pull-quote-attribution' : '—', +'tip-title' : 'Tip', +'title-pagination' : 'with-front', +'toc-pagination' : 'with-toc', +'transition-text' : '***', +'version-text' : 'Version: ', +'warning-title' : 'Warning!', +} +param_list = param_dict.keys() + +true_or_false_dict = {'True':'True', 'true':'True', 'yes':'True', 'Yes': 'True', 'False': 'False', + 'false':'False', 'no': 'False', 'No':'False'} +true_dict = {'true':True, 'True':True, 'yes':True, 'Yes':True} +false_dict = {'false':False, 'False':False, 'none': False, 'None':False, 'no': False, 'No':False} +param_dict_test = {'strict':true_or_false_dict, + 'suppress-first-page-header': true_or_false_dict, + 'suppress-first-page-footer': true_or_false_dict, + } + +# Commands List +# ========================================================================= +commands_list = ['xsl-stylesheet'] Modified: trunk/sandbox/paultremblay/docutilsToFo/make_stylesheet.py =================================================================== --- trunk/sandbox/paultremblay/docutilsToFo/make_stylesheet.py 2011-02-17 04:48:31 UTC (rev 6869) +++ trunk/sandbox/paultremblay/docutilsToFo/make_stylesheet.py 2011-02-17 04:51:04 UTC (rev 6870) @@ -294,12 +294,27 @@ if special_att_sets_dict.get(user_att_set) and check_special: self.__handle_special_atts(user_att_set, user_att, value) return - + spc_att_set_att_list = special_att_set_att_dict.get((user_att_set, user_att)) + if spc_att_set_att_list and check_special: + for new_pair in spc_att_set_att_list: + att_set = new_pair[0] + att = new_pair[1] + self.__add_attribute(att_set, att, value ) + return att_set = short_cut_att_sets.get(user_att_set) if not att_set: # proper att-set, found in xsl stylesheets att_set = user_att_set fo_element = att_set_dict.get(att_set) - if fo_element: # found a valid att-set + + spc_att_val_list = special_att_value_dict.get((user_att, value)) + if spc_att_val_list and fo_element: + for new_pair in spc_att_val_list: + att = new_pair[0] + value = new_pair[1] + self.__add_attribute(att_set, att, value ) + return + + elif fo_element: # found a valid att-set att = custom_atts.get(user_att) if not att: # valid attriubute, according to FO standards att = user_att @@ -333,58 +348,9 @@ raise FOConfigFileException(msg) def __handle_special_atts(self, user_att_set, user_att, value): - keep_with = ['keep-with-next', 'keep-with-previous', 'keep-together', 'keep-on-same-page'] - if user_att == 'font-style': - set_element = att_set_dict.get(user_att_set) - if not set_element: - self.__error('%s not a valid attribute-set' % (user_att_set)) - return - att_set = set_element[0] - att_list = font_style_dict.get(value) - if not att_list: - self.__error('%s not a valid value for att-set %s' % (value, user_att)) - return - else: - for the_tupple in att_list: - self.__add_attribute(att_set, the_tupple[0], the_tupple[1]) - elif user_att_set == 'footer' or user_att_set == 'header': - if user_att == 'height': - if user_att_set == 'header': - self. __handle_attributes('header-region-before' , 'extent', value) - if user_att_set == 'footer': - self. __handle_attributes('footer-region-after' , 'extent', value) - elif user_att == 'suppress-first-page' : - if user_att_set == 'header': - self.__handle_param(param = 'suppress-first-page-header', value = value) - elif user_att_set == 'footer': - self.__handle_param(param = 'suppress-first-page-footer', value = value) - else: - if user_att_set == 'header': - self. __handle_attributes(user_att_set , user_att, value, check_special = False) - if user_att_set == 'footer': - self. __handle_attributes(user_att_set , user_att, value, check_special = False) - elif user_att == 'page-break-after' or user_att == 'page-break-before': - att = user_att[5:] - true_or_false = true_or_false_dict.get(value) - if true_or_false == 'True': - self. __handle_attributes(user_att_set , att, 'page', check_special = False) - # self.__add_attribute(att_set, 'break-before', 'page') - elif true_or_false == 'False': - self. __handle_attributes(user_att_set , att, 'auto', check_special = False) - else: - self.__error('%s.%s = %s not a valid attribute property\n' % (user_att_set, user_att, value)) + self.__error('%s.%s = %s not a valid attribute property\n' % (user_att_set, user_att, value)) - elif user_att in keep_with: - true_value = true_dict.get(value) - if true_value: - self. __handle_attributes(user_att_set , user_att, 'always', check_special = False) - else: - self. __handle_attributes(user_att_set , user_att, value, check_special = False) - else: - self.__error('%s.%s = %s not a valid attribute property\n' % (user_att_set, user_att, value)) - - def __handle_param(self, param, value): to_test_dict = param_dict_test.get(param) if to_test_dict: |