Skip to content

Commit ea647bc

Browse files
[TASK] Create chapter for inline markup (#495)
* [TASK] Create chapter for inline markup Move the content away from the mix-up with the inline-code roles. Link to related elements like links and inline code. * [DOCS] Language checkss --------- Co-authored-by: Sarah McCarthy <sarahmccarthy123@yahoo.com>
1 parent 621d4e9 commit ea647bc

9 files changed

Lines changed: 138 additions & 208 deletions

File tree

Documentation/Reference/ReStructuredText/Code/Codeblocks.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:navigation-title: Code blocks
2+
13
.. include:: /Includes.rst.txt
24
.. index::
35
reST; Code blocks
@@ -8,10 +10,11 @@
810
Code blocks with syntax highlighting
911
====================================
1012

13+
.. contents:: Table of contents
1114

1215
.. _codeblock-quick-reference:
1316

14-
Quick Reference
17+
Quick reference
1518
===============
1619

1720
A code block consists of a `code-block` directive and the actual code indented
Lines changed: 33 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -1,215 +1,58 @@
1+
:navigation-title: Inline Code
12

23
.. include:: /Includes.rst.txt
3-
.. index::
4-
reST; Inline code
5-
.. _Inline-Code:
6-
7-
========================
8-
Inline code & text roles
9-
========================
4+
.. _inline-code:
105

6+
====================================
7+
Inline code with or without overlays
8+
====================================
119

1210
.. hint::
1311

14-
Too much inline code can make the information on a page highly
15-
unreadable. If this is the case, consider using
16-
:ref:`writing-rest-codeblocks-with-syntax-highlighting`.
17-
18-
19-
.. index:: reST; Markup
20-
21-
How to semantically mark up specific text
22-
=========================================
23-
24-
There are several ways to semantically mark specific parts of the text. The main goal is to be able to use
25-
a consistent style for specific parts of the text, for example code fragments, file names and GUI
26-
elements.
27-
28-
.. index:: reST; Text roles
29-
.. _text-roles:
30-
31-
Using text roles
32-
----------------
33-
34-
1. **Preferred:** Use `Sphinx interpreted text roles <http://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html>`__
35-
to explicitly specify what kind of text / code (text role) it is. This shows
36-
the semantics and in the output there may be a a special coloring or highlighting:
37-
38-
================ ================================================= ============================================= ====
39-
Role Source Output Note
40-
================ ================================================= ============================================= ====
41-
(default) ```result = (1 + x) * 32``` `result = (1 + x) * 32` This works because in :file:`Includes.rst.txt` we set the default role to ``:code:`...```
42-
43-
aspect ``:aspect:`Description:``` :aspect:`Description:` For better optics
44-
bash ``:bash:`find . -type d | grep typo3``` :bash:`find . -type d | grep typo3`
45-
css ``:css:`.h1 {font-size:150%}``` :css:`.h1 {font-size:150%}`
46-
html ``:html:`<a href="#">``` :html:`<a href="#">`
47-
issue ``:issue:`12345``` :issue:`12345` To link to a TYPO3 issue.
48-
js ``:js:`var f = function () {return 1;}``` :js:`var f = function () {return 1;}`
49-
php ``:php:`$result = $a + 23;``` :php:`$result = $a + 23;`
50-
rst ``:rst:`.. image:: /path/to/img.jpg``` :rst:`.. image:: /path/to/img.jpg`
51-
sep ``:sep:`|``` :sep:`|` To give the separator '\|' a special style in some contexts like :ref:`Styled-Definition-Lists`
52-
sql ``:sql:`SELECT * FRAM pages WHERE hidden=0;``` :sql:`SELECT * FRAM pages WHERE hidden=0;`
53-
typoscript ``:typoscript:`lib.hello.value = Hello World!``` :typoscript:`lib.hello.value = Hello World!`
54-
xml ``:xml:`<?xml version="1.0" encoding="UTF-8"?>``` :xml:`<?xml version="1.0" encoding="UTF-8"?>`
55-
yaml ``:yaml:`- {name: John Smith, age: 33}``` :yaml:`- {name: John Smith, age: 33}`
56-
================ ================================================= ============================================= ====
57-
58-
59-
60-
61-
62-
`Standard Sphinx interpreted text roles
63-
<http://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#other-semantic-markup>`__:
64-
65-
================ ================================================= ============================================ ===
66-
Role Source Output Note
67-
================ ================================================= ============================================ ===
68-
abbr ``:abbr:`LIFO (last-in, first-out)``` :abbr:`LIFO (last-in, first-out)` An abbreviation. If the role content contains a parenthesized explanation, it will be treated specially: it will be shown in a tool-tip in HTML, and output only once in LaTeX.
69-
code ``:code:`result = (1 + x) * 32``` :code:`result = (1 + x) * 32`
70-
command ``:command:`rm``` :command:`rm` The name of an OS-level command, such as rm.
71-
dfn ``:dfn:`something``` :dfn:`something` Mark the defining instance of a term in the text. (No index entries are generated.)
72-
file ``:file:`/etc/passwd``` :file:`/etc/passwd`
73-
guilabel ``:guilabel:`&Cancel```, :guilabel:`&Cancel`, Labels presented as part of an interactive user interface should be marked using guilabel. This includes labels from text-based interfaces such as those created using curses or other text-based libraries. Any label used in the interface should be marked with this role, including button labels, window titles, field names, menu and menu selection names, and even values in selection lists.
74-
``:guilabel:`O&k```, :guilabel:`O&k`,
75-
``:guilabel:`&Reset```, :guilabel:`&Reset`,
76-
``:guilabel:`F&&Q``` :guilabel:`F&&Q`
77-
kbd ``Press :kbd:`ctrl` + :kbd:`s``` Press :kbd:`ctrl` + :kbd:`s` Mark a sequence of keystrokes. What form the key sequence takes may depend on platform- or application-specific conventions. When there are no relevant conventions, the names of modifier keys should be spelled out, to improve accessibility for new users and non-native speakers. For example, an xemacs key sequence may be marked like :kbd:`C` + :kbd`x`, :kbd:`C` + :kbd:`f`, but without reference to a specific application or platform, the same sequence should be marked as :kbd:`ctrl` + :kbd:`x`, :kbd:`ctrl` + :kbd:`f`.
78-
mailheader ``:mailheader:`Content-Type``` :mailheader:`Content-Type` The name of an RFC 822-style mail header. This markup does not imply that the header is being used in an email message, but can be used to refer to any header of the same “style.” This is also used for headers defined by the various MIME specifications. The header name should be entered in the same way it would normally be found in practice, with the camel-casing conventions being preferred where there is more than one common usage.
79-
ref ``:ref:`Inline-Code``` :ref:`Inline-Code` Sphinx cross-referencing
80-
================ ================================================= ============================================ ===
81-
82-
`Standard Docutils interpreted text roles
83-
<http://docutils.sourceforge.net/docs/ref/rst/roles.html#standard-roles>`__:
84-
85-
.. tip::
86-
87-
For more information about the `ref` directive, see :ref:`how-to-document-hyperlinks`.
88-
89-
================== ================================================= ============================================ ===
90-
Role Source Output Note
91-
================== ================================================= ============================================ ===
92-
emphasis ``:emphasis:`text`, *text*`` :emphasis:`text`, *text*
93-
literal ``:literal:`\ \ abc``` :literal:`\ \ abc`
94-
literal ``:literal:`text`, ''text''`` (backticks!) :literal:`text`, ``text``
95-
math ``:math:`A_\text{c} = (\pi/4) d^2``` :math:`A_\text{c} = (\pi/4) d^2` The math role marks its content as mathematical notation (inline formula). The input format is LaTeX math syntax without the “math delimiters“ ($ $).
96-
rfc, rfc-reference ``:RFC:`2822``` :RFC:`2822`
97-
strong ``:strong:`text`, **text**`` :strong:`text`, **text** Implements strong emphasis.
98-
subscript ``:subscript:`subscripted``` :subscript:`subscripted`
99-
superscript ``:superscript:`superscripted``` :superscript:`superscripted`
100-
t, title-reference ``:t:`Design Patterns``` :t:`Design Patterns` The :title-reference: role is used to describe the titles of books, periodicals, and other materials.
101-
================== ================================================= ============================================ ===
102-
103-
104-
2. As an alternative, you can use the default text role for small inline
105-
code snippets, but it is better to use specific text roles. However, if no
106-
text role exists, you may use this to mark the text.
107-
108-
Surround the code by *single backticks* and don't start or end
109-
the code with whitespace. Example: Type ```2 + 2 = 4``` to get `2 + 2 = 4`
110-
as result.
111-
112-
3. Just write the code as it is. This may make the text more difficult to read.
113-
Use your common sense.
114-
115-
.. index:: reST; Literal code
116-
117-
When to use literal code \`\`...``
118-
----------------------------------
119-
120-
Things get tricky if your inline code already contains single backquotes (backticks).
121-
122-
4. In many cases you can still use the *interpreted text role* as described in 1. to 3.
123-
For example we can write ``:code:`:html:`<br>```` to get :code:`:html:`<br>``
124-
125-
This is possible if (a) your code doesn't start with a backtick and (b) if no backtick in
126-
your code has a trailing whitespace.
127-
128-
5. **But:** To be really free to include inline any code containing backticks you will want to use
129-
`inline literals`_. Again: Don't escape or double anything, whitespace is maintained.
130-
*Example:*
131-
132-
Write::
133-
134-
SQL-example code: ``SELECT `tt_content` . `bodytext` AS `t1` . `text`;``
135-
136-
to get:
137-
138-
SQL-example code: ``SELECT `tt_content` . `bodytext` AS `t1` . `text`;``
139-
140-
**The drawbacks** of literal inline code notation are:
141-
142-
* there is no way to semantically classify the kind of code
143-
* there is no special coloring or highlighting
144-
* the raw reST code looks less beautiful and is less readable
145-
146-
.. _interpreted text roles: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#interpreted-text
147-
.. _inline literals: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-literals
148-
149-
Inline code versus code blocks
150-
==============================
151-
152-
The name for - very - small code snippets that occur within normal text flow
153-
within sentences is *inline code*.
154-
155-
*inline code*
12+
Too much inline code can make the information on a page
13+
unreadable. If this is the case, consider using
14+
`Code blocks with syntax highlighting <https://docs.typo3.org/permalink/h2document:writing-rest-codeblocks-with-syntax-highlighting>`_.
15615

157-
* is styled somewhat differently,
158-
* has **no** syntax highlighting,
159-
* does **not** need to be syntactically correct,
160-
* can be compared to `<span>...</span>` tags in html
16+
Any text inside single or double backticks is printed as inline code. Double
17+
backticks allow unescaped backticks to be used in the code:
16118

162-
In contrast, *code-blocks*
19+
.. tabs::
16320

164-
* appear "as a box",
165-
* can have syntax highlighting,
166-
* need to be syntactically correct in order to have highlighting,
167-
* can be compared to `<pre>...</pre>` blocks in html,
168-
* use predefined names for the different languages that come with Pygments,
169-
the syntax highlighter.
21+
.. group-tab:: Output
17022

23+
.. include:: _snippets/_inline-code.rst.txt
17124

172-
Definition of text roles
173-
========================
25+
.. group-tab:: reST
17426

175-
For all officials TYPO3 manuals `php` is set as default highlight
176-
language with the exception of the TypoScript manuals, where `typoscript` is
177-
the default.
27+
.. literalinclude:: _snippets/_inline-code.rst.txt
17828

179-
You need a custom text role?
180-
----------------------------
29+
By convention single backticks are used unless double are needed.
18130

182-
You need another 'language' to mark up inline?
31+
.. _inline-code-language:
18332

184-
You are free to define additional text roles *in your project* or even
185-
*on an individual page* as you like. Make use of the `role directive
186-
<http://docutils.sourceforge.net/docs/ref/rst/directives.html#role>`__.
187-
Example: You want 'haskell'? Define that role as derivative of 'code':
33+
Code roles with language information and overlay
34+
================================================
18835

189-
.. code-block:: rst
36+
You can also use text roles with one of the predefined languages to display more
37+
information to the user. For the most common languages, automatic
38+
detection provides more context for the user.
19039

191-
.. role:: haskell(code)
40+
.. tabs::
19241

193-
You may then write:
42+
.. group-tab:: Output
19443

195-
.. code-block:: rst
44+
.. include:: _snippets/_inline-code-languages.rst.txt
19645

197-
Here is some :haskell:`haskell inline code` in the sentence.
46+
.. group-tab:: reST
19847

199-
The immediate advantage will be that you can explicitly markup your source
200-
code semantically and declare snippets to be 'Haskell'. The visual appearance
201-
will be that of 'code' until a special css class has been defined. Feel free to
202-
open a request `here
203-
<https://github.com/TYPO3-Documentation/t3SphinxThemeRtd/issues>`__. Look at
204-
this html to understand the technical background:
48+
.. literalinclude:: _snippets/_inline-code-languages.rst.txt
20549

50+
PHP classes from the TYPO3 Core are automatically linked to https://api.typo3.org
51+
and display the PHP doc comment (if any) in the overlay.
20652

207-
.. code-block:: html
53+
All named inline code roles show an overlay where the code can be conveniently
54+
copied and information on the language of the code.
20855

209-
<code class="code haskell docutils literal">
210-
<span class="pre">haskell inline code</span>
211-
</code>
56+
.. seealso::
21257

213-
A default styling for :html:`class="code"` exists and is in effect until
214-
overridden by a special styling :html:`class="code.haskell"` that needs to
215-
be defined.
58+
* `API links: More information on TYPO3 PHP classes <https://docs.typo3.org/permalink/h2document:links-api>`_
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
* :php:`$variable = 'Some general PHP'`
2+
* :php:`\TYPO3\CMS\Core\Core\Environment` TYPO3 class with fully qualified name
3+
* :php-short:`\TYPO3\CMS\Core\Core\Environment` TYPO3 class with short name
4+
* :php:`\Symfony\Component\Dotenv\Dotenv` External class
5+
* :php:`$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport']` configuration values
6+
* :typoscript:`page = PAGE`
7+
* :tsconfig:`TCAdefaults.pages.hidden`
8+
* :fluid:`<f:debug>{myVariable}</f:debug>`
9+
* :html:`<code>`
10+
* :css:`code#mycode {font-family: courier}`
11+
* :js:`alert('test')`
12+
* :bash:`./vendor/bin/typo3 help`
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is `$someCode` and that is ``some ` code``.

Documentation/Reference/ReStructuredText/Content/Index.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
:navigation-title: Directives
2+
13
.. include:: /Includes.rst.txt
24
.. _rest-content:
35

4-
===================================
5-
Content styles and content elements
6-
===================================
6+
==================================
7+
Directives (reST Content elements)
8+
==================================
79

810
.. toctree::
911
:titlesonly:
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
:navigation-title: Inline Markup
2+
3+
.. include:: /Includes.rst.txt
4+
.. _rest-inline-markup:
5+
6+
====================================
7+
Inline Markup in TYPO3 Documentation
8+
====================================
9+
10+
In general we support any inline markup in reStructuredText that was previously
11+
supported by Sphinx.
12+
13+
For example, use one asterix for *italics* `*italic*` and two for **bold** `**bold**`.
14+
15+
Links are described in depth in chapter
16+
`Links in ReStructured Text <https://docs.typo3.org/permalink/h2document:how-to-document-hyperlinks>`_
17+
and are also classed as inline text roles.
18+
19+
All `named inline text roles <https://docs.typo3.org/permalink/h2document:text-roles>`_
20+
have the following syntax: ``:text-role-name:`Some Text```.
21+
Some text roles expect the text inside backticks to have a particular syntax.
22+
23+
.. seealso::
24+
25+
* `Links in ReStructured Text <https://docs.typo3.org/permalink/h2document:how-to-document-hyperlinks>`_
26+
* `Inline code text roles <https://docs.typo3.org/permalink/h2document:inline-code>`_
27+
* `Docutils: Inline Markup <https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#inline-markup>`_
28+
* `Docutils: Interpreted Text Roles <http://docutils.sourceforge.io/docs/ref/rst/roles.html>`_
29+
30+
.. toctree::
31+
:titlesonly:
32+
:glob:
33+
34+
*/Index

Documentation/Reference/ReStructuredText/Content/BoldItalic.rst renamed to Documentation/Reference/ReStructuredText/InlineMarkup/InlineMarkup/Index.rst

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
:navigation-title: Bold, Italic etc.
2+
13
.. include:: /Includes.rst.txt
2-
.. index:: reST; Font styles
34
.. _rest-bold-italic:
45

5-
=================
6-
Bold, Italic etc.
7-
=================
6+
=======================================
7+
Basic inline markup (bold, italic etc.)
8+
=======================================
89

10+
.. contents:: Table of contents
911

10-
.. index:: reST; Bold
12+
.. _rest-bold:
1113

1214
Bold
1315
====
@@ -20,8 +22,7 @@ How it looks:
2022

2123
This is normal text. **This is bold text**
2224

23-
24-
.. index:: reST; Italic
25+
.. _rest-italic:
2526

2627
Italic
2728
======
@@ -36,10 +37,3 @@ This is normal text. *This is italic text.*
3637

3738
.. hint::
3839
Make sure there is no space between the markup and the styled text.
39-
40-
41-
Additional Information
42-
======================
43-
44-
* `Text syntax: bold, italic, verbatim and special characters
45-
<http://openalea.gforge.inria.fr/doc/openalea/doc/_build/html/source/sphinx/rest_syntax.html#text-syntax-bold-italic-verbatim-and-special-characters>`__

0 commit comments

Comments
 (0)