diff --git a/documentation/ref-manual/classes.rst b/documentation/ref-manual/classes.rst
index 130cbea321e1..49c48b5e5990 100644
--- a/documentation/ref-manual/classes.rst
+++ b/documentation/ref-manual/classes.rst
@@ -679,7 +679,11 @@ See :oe_git:`devicetree.bbclass sources
 for further variables controlling this class.
 
 Here is an excerpt of an example ``recipes-kernel/linux/devicetree-acme.bb``
-recipe inheriting this class::
+recipe inheriting this class:
+
+.. Shown as text: the Pygments BitBake lexer misreads this block.
+
+.. code-block:: text
 
    inherit devicetree
    COMPATIBLE_MACHINE = "^mymachine$"
diff --git a/documentation/ref-manual/variables.rst b/documentation/ref-manual/variables.rst
index 2a14a663bf51..9e956a42f0f0 100644
--- a/documentation/ref-manual/variables.rst
+++ b/documentation/ref-manual/variables.rst
@@ -1690,7 +1690,11 @@ system and gives an overview of their function and contents.
       with the current machine.
 
       If one wants to have a recipe only available for some architectures
-      (here ``aarch64`` and ``mips64``), the following can be used::
+      (here ``aarch64`` and ``mips64``), the following can be used:
+
+      .. Shown as text: the Pygments BitBake lexer misreads this block.
+
+      .. code-block:: text
 
          COMPATIBLE_MACHINE = "^$"
          COMPATIBLE_MACHINE:arch64 = "^(aarch64)$"
@@ -1705,7 +1709,11 @@ system and gives an overview of their function and contents.
       The third is for matching all machines whose :term:`MACHINEOVERRIDES`
       contains one override which is exactly ``mips64``.
 
-      The same could be achieved with::
+      The same could be achieved with:
+
+      .. Shown as text: the Pygments BitBake lexer misreads this block.
+
+      .. code-block:: text
 
          COMPATIBLE_MACHINE = "^(aarch64|mips64)$"
 
@@ -9728,7 +9736,11 @@ system and gives an overview of their function and contents.
 
       By default this variable is empty, meaning no files are excluded.
 
-      Example usage::
+      Example usage:
+
+      .. Shown as text: the Pygments BitBake lexer misreads this block.
+
+      .. code-block:: text
 
          SPDX_FILE_EXCLUDE_PATTERNS = "\\.patch$ \\.diff$ /test/ \\.pyc$ \\.o$"
 
@@ -11580,7 +11592,11 @@ system and gives an overview of their function and contents.
       are not conflicting and that they are supported.
 
       The BitBake configuration file (``meta/conf/bitbake.conf``) defines
-      :term:`TUNE_FEATURES` as follows::
+      :term:`TUNE_FEATURES` as follows:
+
+      .. Shown as text: the Pygments BitBake lexer misreads this block.
+
+      .. code-block:: text
 
          TUNE_FEATURES ??= "${TUNE_FEATURES:tune-${DEFAULTTUNE}}"
 
@@ -12574,7 +12590,11 @@ system and gives an overview of their function and contents.
 
       For recipes with dot-separated versions, inherit the
       :ref:`ref-classes-upstream-stable-release-point` class to generate this
-      variable automatically. For other versioning schemes, set it directly::
+      variable automatically. For other versioning schemes, set it directly:
+
+      .. Shown as text: the Pygments BitBake lexer misreads this block.
+
+      .. code-block:: text
 
          UPSTREAM_STABLE_RELEASE_REGEX = "^10\.2p\d+$"
 
