> If modifying an rst source file before the rst markup is parsed is an
> adequate solution, then the "source-read" event may be what you need:
>
> http://sphinx.pocoo.org/ext/appapi.html#event-source-read
Thank you for this suggestion. I think this would be possible however
then I lose the advantages of having the rst already parsed once. I
found another solution though. I build a .rst string and parse it
using this function:
def rst_to_nodes(input_string, source_path=None,
destination_path=None,
input_encoding='latin-1', settings_overrides=None):
if settings_overrides:
overrides = settings_overrides.copy()
else:
overrides = {}
overrides['input_encoding'] = input_encoding
output, pub = core.publish_programmatically(
source_class=io.StringInput, source=input_string,
source_path=source_path,
destination_class=io.NullOutput, destination=None,
destination_path=destination_path,
reader=None, reader_name='standalone',
parser=None, parser_name='restructuredtext',
writer=None, writer_name='null',
settings=None, settings_spec=None,
settings_overrides=overrides,
config_section=None, enable_exit_status=None)
return pub.document.children
I took this method from the docutils examples.
Sebastian
--
You received this message because you are subscribed to the Google Groups
"sphinx-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sphinx-dev?hl=en.