mirror of
https://github.com/moparisthebest/xeps
synced 2024-11-28 12:12:22 -05:00
346 lines
12 KiB
XML
346 lines
12 KiB
XML
<?xml version='1.0' encoding='UTF-8'?>
|
|
<!DOCTYPE xep SYSTEM 'xep.dtd' [
|
|
<!ENTITY % ents SYSTEM 'xep.ent'>
|
|
%ents;
|
|
<!ENTITY rfc7764 "<span class='ref'><link url='http://tools.ietf.org/html/rfc7764'>RFC 7764</link></span> <note>RFC 7764: Guidance on Markdown: Design Philosophies, Stability Strategies, and Select Registrations <<link url='http://tools.ietf.org/html/rfc7764'>http://tools.ietf.org/html/rfc7764</link>>.</note>" >
|
|
<!ENTITY uax9 "<span class='ref'>Unicode Standard Annex #9</span> <note>Unicode Standard Annex #9, "Unicode Bidirectional Algorithm", edited by Mark Davis, Aharon Lanin, and Andrew Glass. An integral part of The Unicode Standard, <<link url='http://unicode.org/reports/tr9/'>http://unicode.org/reports/tr9/</link>>.</note>" >
|
|
]>
|
|
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
|
|
<xep>
|
|
<header>
|
|
<title>Message Styling</title>
|
|
<abstract>
|
|
This specification defines a formatted text syntax for use in instant
|
|
messages with simple text styling.
|
|
</abstract>
|
|
&LEGALNOTICE;
|
|
<number>xxxx</number>
|
|
<status>ProtoXEP</status>
|
|
<type>Standards Track</type>
|
|
<sig>Standards</sig>
|
|
<approver>Council</approver>
|
|
<dependencies>
|
|
<spec>XMPP Core</spec>
|
|
<spec>XEP-0001</spec>
|
|
</dependencies>
|
|
<supersedes/>
|
|
<supersededby/>
|
|
<shortname>styling</shortname>
|
|
&sam;
|
|
<revision>
|
|
<version>0.0.1</version>
|
|
<date>2017-10-28</date>
|
|
<initials>ssw</initials>
|
|
<remark><p>First draft.</p></remark>
|
|
</revision>
|
|
</header>
|
|
<section1 topic='Introduction' anchor='intro'>
|
|
<p>
|
|
Historically, XMPP has had no system for simple text styling.
|
|
Instead, specifications like &xep0071; that require full layout engines have
|
|
been used, leading to numerous security issues with implementations.
|
|
Some entities have also performed their own styling based on identifiers in
|
|
the body.
|
|
While this has worked well in the past, it is not interoperable and leads to
|
|
entities each supporting their own informal styling languages.
|
|
</p>
|
|
<p>
|
|
This specification aims to provide a single, interoperable formatted text
|
|
syntax that can be used by entities that do not require full layout engines.
|
|
</p>
|
|
</section1>
|
|
<section1 topic='Requirements' anchor='reqs'>
|
|
<ul>
|
|
<li>
|
|
Clients that do not support this specification MUST still be able to
|
|
receive messages sent by clients using this specification and display them
|
|
in a human-readable form.
|
|
</li>
|
|
<li>
|
|
Clients that support this specification MUST NOT be required to use a
|
|
layout engine such as HTML or LaTeX.
|
|
</li>
|
|
<li>
|
|
Messages formatted using this specification MUST NOT hinder readability on
|
|
receiving clients regardless of client background color, contrast, or
|
|
window size.
|
|
</li>
|
|
<li>
|
|
Messages formatted using this specification MUST NOT hinder readability by
|
|
users with color vision deficiency or impaired vision.
|
|
</li>
|
|
<li>
|
|
Messages formatted with this specification MUST render correctly in
|
|
locales with right-to-left (RTL) layouts without causing confusion.
|
|
</li>
|
|
<li>
|
|
Clients that support this specification MUST NOT be required to extract
|
|
metadata unrelated to formatting or text style from the message.
|
|
</li>
|
|
<li>
|
|
Servers MUST NOT need to implement any new functionality for this
|
|
specification to be supported.
|
|
</li>
|
|
</ul>
|
|
</section1>
|
|
<section1 topic='Glossary' anchor='glossary'>
|
|
<p>
|
|
Many important terms used in this document are defined in &unicode;.
|
|
The terms "left-to-right" (LTR) and "right-to-left" (RTL) are defined in
|
|
&uax9;.
|
|
The term "formatted text" is defined in &rfc7764;.
|
|
</p>
|
|
<dl>
|
|
<di>
|
|
<dt>Formal markup language</dt>
|
|
<dd>
|
|
A structured markup language such as LaTeX, SGML, HTML, or XML that is
|
|
formally defined and may include metadata unrelated to formatting or
|
|
text style.
|
|
</dd>
|
|
</di>
|
|
<di>
|
|
<dt>Plain text</dt>
|
|
<dd>
|
|
Text that does not convey any particular formatting or interpretation of
|
|
the text by computer programs.
|
|
</dd>
|
|
</di>
|
|
<di>
|
|
<dt>Whitespace character</dt>
|
|
<dd>
|
|
Any Unicode scalar value which has the property "White_Space" or is in
|
|
category Z in the Unicode Character Database.
|
|
</dd>
|
|
</di>
|
|
</dl>
|
|
</section1>
|
|
<section1 topic='Use Cases' anchor='usecases'>
|
|
<ul>
|
|
<li>
|
|
As a user sending an instant message to a friend, I want to be able to
|
|
emphasize an important part of my message.
|
|
</li>
|
|
<li>
|
|
As a software developer, I want to be able to send pre-formatted,
|
|
monospace, block or inline text to another developer.
|
|
</li>
|
|
<li>
|
|
As a multi-user chat user I want to quote something someone said earlier
|
|
in the chat and make it evident that the text is a quotation.
|
|
</li>
|
|
</ul>
|
|
</section1>
|
|
<section1 topic='Business Rules' anchor='rules'>
|
|
<section2 topic='Blocks' anchor='block'>
|
|
<p>
|
|
A block is any chunk of text that can be parsed unambiguously in one pass.
|
|
</p>
|
|
<ul>
|
|
<li>A single line of text containing only inline spans</li>
|
|
<li>A block quotation comprising one or more lines</li>
|
|
<li>A preformatted code block</li>
|
|
</ul>
|
|
</section2>
|
|
<section2 topic='Spans' anchor='span'>
|
|
<p>
|
|
A span are groups of text that do not result in a line break when rendered
|
|
(they are rendered inline) and where the entire group is rendered in the
|
|
same manner and in the same block.
|
|
Spans may be either plain text with no formatting applied, or may be
|
|
formatted text that is enclosed by two styling directives.
|
|
The following are all single spans:
|
|
</p>
|
|
<ul>
|
|
<li>plain span</li>
|
|
<li><strong>*emphasized span*</strong></li>
|
|
</ul>
|
|
<p>
|
|
Matches of spans between two styling directives MUST contain some text
|
|
between the two styling directives and the opening styling directive MUST
|
|
be located at the beginning of the line, or after a whitespace character.
|
|
The opening styling directive MUST also not be followed by a whitespace
|
|
character.
|
|
Spans are always parsed from the beginning of the byte stream to the end
|
|
and are lazily matched.
|
|
</p>
|
|
<p>
|
|
For example, the word "emphasized" would be styled in each of the
|
|
following messages:
|
|
</p>
|
|
<ul>
|
|
<li><strong>*emphasized*</strong></li>
|
|
<li>foo <strong>*emphasized*</strong> bar</li>
|
|
<li><strong>*emphasized*</strong>foo<strong>*emphasized*</strong></li>
|
|
<li><strong>*emphasized*</strong>foo*</li>
|
|
<li>* foo <strong>*emphasized*</strong></li>
|
|
</ul>
|
|
<p>
|
|
Nothing would be styled in the following messages (where \n represents a
|
|
new line):
|
|
</p>
|
|
<ul>
|
|
<li>not emphasized*</li>
|
|
<li>*not emphasized</li>
|
|
<li>*not \n emphasized*</li>
|
|
<li>**</li>
|
|
<li>****</li>
|
|
</ul>
|
|
</section2>
|
|
<section2 topic='Bold' anchor='bold'>
|
|
<p>
|
|
Text enclosed by '*' (U+002A ASTERISK) SHOULD be displayed with a greater
|
|
weight than the surrounding text (bold face).
|
|
</p>
|
|
<example caption='Bold'><![CDATA[
|
|
<body>
|
|
The full title is *Twelfth Night, or What You Will* but
|
|
*most* people shorten it.
|
|
</body>
|
|
]]></example>
|
|
</section2>
|
|
<section2 topic='Italic' anchor='italic'>
|
|
<p>
|
|
Text enclosed by '_' (U+005F LOW LINE) SHOULD be displayed in italics.
|
|
</p>
|
|
<example caption='Italic'><![CDATA[
|
|
<body>
|
|
The full title is _Twelfth Night, or What You Will_ but
|
|
_most_ people shorten it.
|
|
</body>
|
|
]]></example>
|
|
</section2>
|
|
<section2 topic='Strike through' anchor='strike'>
|
|
<p>
|
|
Text enclosed by '~' (U+007E TILDE) SHOULD be displayed with a horizontal
|
|
line through the middle (strike through).
|
|
</p>
|
|
<example caption='Strike through'><![CDATA[
|
|
<body>
|
|
Everyone ~dis~likes cake.
|
|
</body>
|
|
]]></example>
|
|
</section2>
|
|
<section2 topic='Inline Preformatted Text' anchor='pre-inline'>
|
|
<p>
|
|
Text enclosed by a '`' (U+0060 GRAVE ACCENT) SHOULD be displayed inline in
|
|
a monospace font.
|
|
Inline formatting directives inside the inline preformatted text are not
|
|
rendered.
|
|
For example, in the following the word "monospace" is valid pre-formatted
|
|
inline text:
|
|
</p>
|
|
<ul>
|
|
<li>This is <tt>`monospace`</tt></li>
|
|
<li>This is <tt>`*monospace*`</tt></li>
|
|
<li>This is <strong><tt>*`monospace and bold`*</tt></strong></li>
|
|
</ul>
|
|
<example caption='Monospace text'><![CDATA[
|
|
<body>
|
|
Wow, I can write in `monospace`!
|
|
</body>
|
|
]]></example>
|
|
</section2>
|
|
<section2 topic='Preformatted Block Text' anchor='pre-block'>
|
|
<p>
|
|
A block of text surrounded by lines consisting of a sequence of three
|
|
backticks, "```" (U+0060 GRAVE ACCENT), is preformatted text and should be
|
|
displayed exactly as it was entered including whitespace.
|
|
If no closing "```" sequence exists, the preformatted block extends to the
|
|
end of the input stream or the end of the parent block (whichever comes
|
|
first).
|
|
No other formatting described in this document should be rendered inside a
|
|
preformatted text block.
|
|
</p>
|
|
<example caption='Preformatted block text'><![CDATA[
|
|
<body>
|
|
```
|
|
(println "Hello, world!")
|
|
```
|
|
|
|
This should show up as monospace, preformatted text ⤴
|
|
</body>
|
|
]]></example>
|
|
<example caption='No closing preformatted text sequence'><![CDATA[
|
|
<body>
|
|
> ```
|
|
> (println "Hello, world!")
|
|
|
|
The entire blockquote is a preformatted text block, but this line is
|
|
plaintext!
|
|
</body>
|
|
]]></example>
|
|
</section2>
|
|
<section2 topic='Quotations' anchor='quote'>
|
|
<p>
|
|
A quotation is indicated by one or more lines with a byte stream beginning
|
|
with a '>' (U+003E GREATER-THAN SIGN).
|
|
Block quotes may contain any child block, including other quotations.
|
|
Lines inside the block quote MUST have leading spaces trimmed before
|
|
parsing the child block.
|
|
</p>
|
|
<example caption='Quotation (LTR)'><![CDATA[
|
|
<body>
|
|
> That that is, is.
|
|
|
|
Said the old hermit of Prague.
|
|
</body>
|
|
]]></example>
|
|
<example caption='Nested Quotation'><![CDATA[
|
|
<body>
|
|
>> That that is, is.
|
|
> Said the old hermit of Prague.
|
|
|
|
Who?
|
|
</body>
|
|
]]></example>
|
|
</section2>
|
|
</section1>
|
|
<section1 topic='Implementation Notes' anchor='impl'>
|
|
<p>
|
|
This document does not define a regular grammar and thus styling cannot be
|
|
matched by a regular expression.
|
|
Instead, a predictive recursive descent or LALR parser may be constructed.
|
|
For instance, a simple parser can be constructed by first parsing all text
|
|
into blocks and then recursively parsing the child-blocks inside block
|
|
quotations, the spans inside plain lines, and by returning the text inside
|
|
preformatted blocks without modification.
|
|
</p>
|
|
<p>
|
|
It is RECOMMENDED that formatting characters be displayed and formatted in
|
|
the same manner as the text they apply to.
|
|
For example, the string "*emphasis*" would be rendered as
|
|
"<strong>*emphasis*</strong>".
|
|
</p>
|
|
</section1>
|
|
<section1 topic='Accessibility Considerations' anchor='access'>
|
|
<p>
|
|
When displaying text with formatting, developers should take care to ensure
|
|
sufficient contrast exists between styled and unstyled text so that users
|
|
with vision deficiencies are able to distinguish between the two.
|
|
</p>
|
|
<p>
|
|
Formatted text may also be rendered poorly by screen readers.
|
|
When applying formatting it may be desirable to include directives to
|
|
exclude formatting characters from being read.
|
|
</p>
|
|
</section1>
|
|
<section1 topic='Internationalization Considerations' anchor='i18n'>
|
|
<p>OPTIONAL.</p>
|
|
</section1>
|
|
<section1 topic='Security Considerations' anchor='security'>
|
|
<p>REQUIRED.</p>
|
|
</section1>
|
|
<section1 topic='IANA Considerations' anchor='iana'>
|
|
<p>
|
|
This document requires no interaction with &IANA;.
|
|
</p>
|
|
</section1>
|
|
<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
|
|
<p>This specification requires no interaction with the ®ISTRAR;</p>
|
|
</section1>
|
|
<section1 topic='XML Schema' anchor='schema'>
|
|
<p>This document does not define any new XML structure requiring a schema.</p>
|
|
</section1>
|
|
</xep>
|