diff options
author | Stuart Rackham <srackham@methods.co.nz> | 2011-02-10 11:02:01 +1300 |
---|---|---|
committer | Stuart Rackham <srackham@methods.co.nz> | 2011-02-10 11:02:01 +1300 |
commit | 13dec419a694d72e05a90810d85e4b1c4d5cd690 (patch) | |
tree | f4cf35fb66776584d55bbbd2468a477d5ff6c455 | |
parent | 1fa1196e26771824a814ebfefba3aaf2bb488401 (diff) | |
download | asciidoc-13dec419a694d72e05a90810d85e4b1c4d5cd690.tar.gz |
Attribute entries can be used to set configuration markup sections.
-rwxr-xr-x | asciidoc.py | 28 | ||||
-rw-r--r-- | doc/asciidoc.txt | 16 | ||||
-rw-r--r-- | tests/data/testcases.txt | 19 |
3 files changed, 50 insertions, 13 deletions
diff --git a/asciidoc.py b/asciidoc.py index e688f97..a432b85 100755 --- a/asciidoc.py +++ b/asciidoc.py @@ -1741,16 +1741,26 @@ class AttributeEntry: while attr.value.endswith(' +'): if not reader.read_next(): break attr.value = attr.value[:-1] + reader.read().strip() - if AttributeEntry.name2: # The entry is a conf file entry. - section = {} - # Some sections can have name! syntax. - if attr.name in ('attributes','miscellaneous') and attr.name2[-1] == '!': - section[attr.name] = [attr.name2] + if attr.name2 is not None: + # Configuration file attribute. + if attr.name2 != '': + # Section entry attribute. + section = {} + # Some sections can have name! syntax. + if attr.name in ('attributes','miscellaneous') and attr.name2[-1] == '!': + section[attr.name] = [attr.name2] + else: + section[attr.name] = ['%s=%s' % (attr.name2,attr.value)] + config.load_sections(section) + config.load_miscellaneous(config.conf_attrs) else: - section[attr.name] = ['%s=%s' % (attr.name2,attr.value)] - config.load_sections(section) - config.load_miscellaneous(config.conf_attrs) - else: # The entry is an attribute. + # Markup template section attribute. + if attr.name in config.sections: + config.sections[attr.name] = [attr.value] + else: + message.warning('missing configuration section: %s' % attr.name) + else: + # Normal attribute. if attr.name[-1] == '!': # Names like name! undefine the attribute. attr.name = attr.name[:-1] diff --git a/doc/asciidoc.txt b/doc/asciidoc.txt index edea87b..b596730 100644 --- a/doc/asciidoc.txt +++ b/doc/asciidoc.txt @@ -3792,14 +3792,15 @@ Stuart Rackham <srackham@gmail.com> Setting configuration entries ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A variant of the Attribute Entry syntax allows configuration file -entries to be set from within an AsciiDoc document: +section entries and markup template sections to be set from within an +AsciiDoc document: - :<section_name>.<entry_name>: <entry_value> + :<section_name>.[<entry_name>]: <entry_value> Where `<section_name>` is the configuration section name, `<entry_name>` is the name of the entry and `<entry_value>` is the -optional entry value. This example sets the default labeled list style -to 'horizontal': +optional entry value. This example sets the default labeled list +style to 'horizontal': :listdef-labeled.style: horizontal @@ -3808,6 +3809,13 @@ It is exactly equivalent to a configuration file containing: [listdef-labeled] style=horizontal +If the `<entry_name>` is omitted then the entire section is +substituted with the `<entry_value>`. This feature should only be used +to set markup template sections. The following example sets the +'xref2' inline macro markup template: + + :xref2-inlinemacro.: <a href="#{1}">{2?{2}}</a> + No substitution is performed on configuration file attribute entries and they cannot be undefined. diff --git a/tests/data/testcases.txt b/tests/data/testcases.txt index 0281736..05a204b 100644 --- a/tests/data/testcases.txt +++ b/tests/data/testcases.txt @@ -109,6 +109,25 @@ obvious* (``++1\n++'') if (usually ``++-1\n++'') +== Configuration attribute entries == + +:listdef-labeled.style: horizontal +term:: definition + +:listdef-labeled.style: vertical +term:: definition + +ifdef::backend-xhtml11[] +<<link1>> + +:xref2-inlinemacro.: <a href="#{1}">{2?{2}}</a> + +<<link1>> + +:xref2-inlinemacro.: <a href="#{1}">{2=[{1}]}</a> +endif::[] + + == Break list nesting == 1. List 1. 2. List 1. |