3232
3333
3434def _option_name_html (matcher ):
35- parts = matcher .group (1 ). split ( '=' , 1 )
36- if len ( parts ) == 1 :
37- return f'<em> { parts [ 0 ] } </em >'
38- return f"<em> { parts [ 0 ] } </em>=< code class='docutils literal notranslate'> { parts [ 1 ] } </code>"
35+ text = matcher .group (1 )
36+ if '=' not in text and ':' not in text :
37+ return f'<code class="ansible-option literal notranslate"><strong> { text } </strong></code >'
38+ return f'< code class="ansible-option-value literal notranslate"> { text } </code>'
3939
4040
4141def html_ify (text ):
@@ -59,9 +59,9 @@ def html_ify(text):
5959 r"<code class='docutils literal notranslate'>\1</code>" , text )
6060 text , _counts ['option-name' ] = _SEM_OPTION_NAME .subn (_option_name_html , text )
6161 text , _counts ['option-value' ] = _SEM_OPTION_VALUE .subn (
62- r"<code class='docutils literal notranslate'>\1</code>" , text )
62+ r"<code class='ansible-value literal notranslate'>\1</code>" , text )
6363 text , _counts ['environment-var' ] = _SEM_ENV_VARIABLE .subn (
64- r"<code class='docutils literal notranslate'>\1</code>" , text )
64+ r"<code class='xref std std-envvar literal notranslate'>\1</code>" , text )
6565 text , _counts ['ruler' ] = _RULER .subn (r"<hr/>" , text )
6666
6767 text = text .strip ()
@@ -96,15 +96,6 @@ def do_max(seq):
9696# https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#character-level-inline-markup-1
9797# for further information.
9898
99- def _option_name_rst (matcher ):
100- parts = matcher .group (1 ).split ('=' , 1 )
101- start = f"\\ :strong:`{ rst_escape (parts [0 ], escape_ending_whitespace = True )} `\\ "
102- if len (parts ) == 1 :
103- return start
104- end = f"\\ :literal:`{ rst_escape (parts [1 ], escape_ending_whitespace = True )} `\\ "
105- return f'{ start } ={ end } '
106-
107-
10899def _rst_ify_italic (m ):
109100 return f"\\ :emphasis:`{ rst_escape (m .group (1 ), escape_ending_whitespace = True )} `\\ "
110101
@@ -141,6 +132,18 @@ def _rst_ify_const(m):
141132 return f"\\ :literal:`{ rst_escape (m .group (1 ), escape_ending_whitespace = True )} `\\ "
142133
143134
135+ def _rst_ify_option_name (m ):
136+ return f"\\ :ansopt:`{ rst_escape (m .group (1 ), escape_ending_whitespace = True )} `\\ "
137+
138+
139+ def _rst_ify_value (m ):
140+ return f"\\ :ansval:`{ rst_escape (m .group (1 ), escape_ending_whitespace = True )} `\\ "
141+
142+
143+ def _rst_ify_envvar (m ):
144+ return f"\\ :envvar:`{ rst_escape (m .group (1 ), escape_ending_whitespace = True )} `\\ "
145+
146+
144147def rst_ify (text ):
145148 ''' convert symbols like I(this is in italics) to valid restructured text '''
146149
@@ -155,9 +158,9 @@ def rst_ify(text):
155158 text , _counts ['url' ] = _URL .subn (_rst_ify_url , text )
156159 text , _counts ['ref' ] = _REF .subn (_rst_ify_ref , text )
157160 text , _counts ['const' ] = _CONST .subn (_rst_ify_const , text )
158- text , _counts ['option-name' ] = _SEM_OPTION_NAME .subn (_option_name_rst , text )
159- text , _counts ['option-value' ] = _SEM_OPTION_VALUE .subn (_rst_ify_const , text )
160- text , _counts ['environment-var' ] = _SEM_ENV_VARIABLE .subn (_rst_ify_const , text )
161+ text , _counts ['option-name' ] = _SEM_OPTION_NAME .subn (_rst_ify_option_name , text )
162+ text , _counts ['option-value' ] = _SEM_OPTION_VALUE .subn (_rst_ify_value , text )
163+ text , _counts ['environment-var' ] = _SEM_ENV_VARIABLE .subn (_rst_ify_envvar , text )
161164 text , _counts ['ruler' ] = _RULER .subn ('\n \n .. raw:: html\n \n <hr>\n \n ' , text )
162165
163166 flog .fields (counts = _counts ).info ('Number of macros converted to rst equivalents' )
0 commit comments