I am writing using Sphinx. While editing a file in the reStructuredText format in Emacs: I would like to highlight the contents of the code block in a different major mode from rst-mode, but how can I do it well?
Hello, world
==============
- baldness
.. code-block::python
# This block is not in rst-mode, but in python-mode.
# Syntax highlights and indentations.
def hello():
print("Hello, world!")
hello()
I don't know if it will work because I haven't tried it myself, but mumamo or mmm-mode allows you to switch between different modes in one buffer depending on the code type (see also MultipleModes in EmacsWiki).
In mmm-mode, what you're doing is the opposite (editing rst in Python code), but this answer or this code may help you set it up.
574 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
925 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
585 PHP ssh2_scp_send fails to send files as intended
624 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.