Common use of Using a Template Configuration File Clause in Contracts

Using a Template Configuration File. A template configuration file can be specified when rendering using the command-line rinoh tool by passing it to the --template command-line option. When using the Sphinx_builder, you can set the rinoh_template option in conf.py. To render a document using this template configuration programatically, load the template file using TemplateConfigurationFile: from pathlib import Path from rinoh.frontend.rst import ReStructuredTextReader from rinoh.template import TemplateConfigurationFile # the parser builds a rinohtype document tree parser = ReStructuredTextReader() with open('my_document.rst') as file: document_tree = parser.parse(file) # load the article template configuration file script_path = Path(sys.path[0]).resolve() config = TemplateConfigurationFile(script_path / 'my_article.rtt') # render the document to 'my_document.pdf' document = config.document(document_tree) document.render('my_document') The TemplateConfigurationFile.document() method creates a document instance with the template configuration applied. So if you want to render your document using a different template configuration, it suffices to load the new configuration file. Refer to the Article documentation to discover all of the options accepted by it and the docu- ment part and page templates. Element Styling This section describes how styles defined in a style sheet are applied to document elements. Understanding how this works will help you when designing a custom style sheet.‌ rinohtype’s style sheets are heavily inspired by CSS, but add some additional functionality. Similar to CSS, rinohtype makes use of so-called selectors to select document elements in the document tree to style. Unlike CSS however, these selectors are not directly specified in a style sheet. Instead, all selectors are collected in a matcher where they are mapped to descriptive labels for the selected elements. A style sheet assigns style properties to these labels. Besides the usefulness of having these labels instead of the more cryptic selectors, a matcher can be reused by multiple style sheets, avoiding duplication. This section currently assumes some Python or general object-oriented programming knowl- edge. A future update will move Python-specific details to another section, making things more accessible for non-programmers.

Appears in 2 contracts

Sources: User Manual, User Manual

Using a Template Configuration File. A template configuration file configuration file can be specified specified when rendering using the command-line rinoh tool by passing it to the --template command-line option. When using the Sphinx_builder, you can set the rinoh_template option in conf.py. To render a document using this template configuration configuration programatically, load the template file file using TemplateConfigurationFile: from pathlib import Path from rinoh.frontend.rst import ReStructuredTextReader from rinoh.template import TemplateConfigurationFile # the parser builds a rinohtype document tree parser = ReStructuredTextReader() with open('my_document.rst') as file: document_tree = parser.parse(file) # load the article template configuration file script_path = Path(sys.path[0]).resolve() config = TemplateConfigurationFile(script_path / 'my_article.rtt') # render the document to 'my_document.pdf' document = config.document(document_tree) document.render('my_document') The TemplateConfigurationFile.document() method creates a document instance with the template configuration configuration applied. So if you want to render your document using a different template configurationconfiguration, it suffices suffices to load the new configuration fileconfiguration file. Refer to the Article documentation to discover all of the options accepted by it and the docu- ment part and page templates. Element Styling This section describes how styles defined defined in a style sheet are applied to document elements. Understanding how this works will help you when designing a custom style sheet.‌ rinohtype’s style sheets are heavily inspired by CSS, but add some additional functionality. Similar to CSS, rinohtype makes use of so-called selectors to select document elements in the document tree to style. Unlike CSS however, these selectors are not directly specified specified in a style sheet. Instead, all selectors are collected in a matcher where they are mapped to descriptive labels for the selected elements. A style sheet assigns style properties to these labels. Besides the usefulness of having these labels instead of the more cryptic selectors, a matcher can be reused by multiple style sheets, avoiding duplication. This section currently assumes some Python or general object-oriented programming knowl- edge. A future update will move Python-specific specific details to another section, making things more accessible for non-programmers.

Appears in 1 contract

Sources: User Manual