Okay, I understand what happened. On your document, `test.rst` is processed twice. The first timing is including time. And another timing is processed as document. Please take a look `test.html` in output document. In the file, inline maths would be recognized as equations. The event you saw is the second one. It was not emitted on included.
It would not be emitted if you rename it to `test.txt`. I think sphinx-core should be improved. Could you file a feature request? Thanks, 2018年9月8日(土) 20:27 <[email protected]>: > > Yes, the source-read event seems to be triggered regardless of wether the > file is included or not. > > The question is then: How can I make an extension do some pre-processing, > like a regex, on included files? > > e.g.; > > index.rst contains > > $some math 1$ > .. include test.rst > > test.rst contains > > $some math 2$ > > My extension has a a regex to replace $(...)$ by a :math: directive based on > source_read, > but only $some math 1$ gets converted to :math:'some math 1', > $some math 2$ is left unchanged. > > Le jeudi 6 septembre 2018 00:23:48 UTC+2, frederik…@gmail.com a écrit : >> >> As proposed in the documentation for the source-read event, >> I am trying to use a regex to replace $...$ by :math: directives. >> >> This works well, except for interactions with the .. include:: file.rst >> directive. >> Included files do seem to trigger source-read events, but the modification >> to the source is not reflected in the output. >> >> What is the correct way of preprocessing included files? >> >> > -- > You received this message because you are subscribed to the Google Groups > "sphinx-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/sphinx-users. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sphinx-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sphinx-users. For more options, visit https://groups.google.com/d/optout.
