From 2ef1219109c9e7b3b51ed0fd058a35b4768b97ec Mon Sep 17 00:00:00 2001 From: "Antoine Vandevenne (anv)" Date: Tue, 8 Nov 2022 14:56:03 +0100 Subject: [PATCH] [IMP] odoo_theme: add the class `o_code` on literals The SCSS that styles the `literal`, `code`, `file`, and `command` roles is excessively complex because the traduction from RST to HTML is not consistent from one role to another: some use `` elements, some have the `code` class, some wrap the literal with a `span` element. This commit sets the `o_code` class on all of these roles' parent node at translation time to allow simplifying the SCSS target. --- extensions/odoo_theme/translator.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/extensions/odoo_theme/translator.py b/extensions/odoo_theme/translator.py index 311f70283..8b12e6acf 100644 --- a/extensions/odoo_theme/translator.py +++ b/extensions/odoo_theme/translator.py @@ -137,6 +137,17 @@ class BootstrapTranslator(HTML5Translator): else: super().depart_title(node) + def visit_literal(self, node): + """ Override to add the class `o_code` to all `literal`, `code`, and `file` roles. """ + node['classes'].append('o_code') + return super().visit_literal(node) + + def visit_literal_strong(self, node): + """ Override to add the class `o_code` to all `command` roles. """ + if 'command' in node['classes']: + node['classes'].append('o_code') + return super().visit_literal_strong(node) + # overwritten # Ensure table class is present for tables def visit_table(self, node):