Consolidated WTF - https://davidblue.wtf/ulysses/style
Ulysses Style ReferenceDefining StylesStyle SelectorsRelative SelectorsPseudoclassesEvaluation OrderInheritanceMixinsUsing Style SettingsTypesExpressionsVariablesOperatorsClass ReferenceGeneral ClassesDefinition ClassesSettings ReferenceOverviewDocument SettingsHeaders and FootersFootnotes AreaInlineMediaFootnotesParagraphDividerListTableTable CellEditor PluginsTextMate 2Sublime TextBBEdit and TextWranglerVisual Studio Code
With Ulysses Style Sheets you are able to create custom rich text styles for exporting your Ulysses documents. In order to assign a style to a certain definition in Ulysses, you just write a so-called style class. A style class consists of a style selector and some style settings:
xxxxxxxxxx
inline-strong {
font-family: "Cochin"
font-weight: bold
}
Style settings are written as key-value pairs, like font-family: "Cochin"
. A style setting ends on a line break. To place multiple settings in a line a semicolon ';'
can be also used:
xxxxxxxxxx
inline-strong { font-family: "Cochin"; font-weight: bold; }
Ulysses style sheets provide you a many flexible way to re-use style settings through variables and expressions. We give a more detailed overview on style settings later. You will find an overview on all style settings in the Settings Reference.
A style selector specifies when a style should be applied. The most simple style selector is a definition selector, like inline-strong
or heading-1
. However, if you want to create a style for an entire class of definitions, you may also use definition class selector, like list-all
. These selectors match any contents of a certain type: For example the selector list-all
matches all lists: e.g. list-ordered
and list-unordered
.
Besides the definitions used in your Ulysses document, there are also some general class selectors that describe settings regarding the visual appearance of the entire exported document. For example, the selector area-header
and area-footer
can be used to style of the header or footer area of any page in your document. The class document-settings
contains general settings of the document, like the paper format. The setting defaults
describe the base style for any node inside your document.
You will find a comprehensive overview of all possible definitions and their settings in the Class Reference.
Style selectors can be used in a very flexible way: with a relative style selector, you can specify that a style should be only used for content placed in a special position relative to other content. For example you can declare a style that should be only used for paragraphs following a heading1 in your document:
xxxxxxxxxx
heading-1 + paragraph {
margin-top: 0pt
}
The following relations can be used for relative style selectors:
Relation | Example | Description |
---|---|---|
Definition | strong | The style class matches all nodes using a certain Definition. |
Definition_ + _SuccessorDefinition | heading1 + all-paragraphs | The style class matches all nodes using SuccessorDefinition that follow immediately a node using Definition. |
ParentDefinition_ _ChildDefinition | area-footnotes image | The style class matches all nodes using ChildDefinition that are somewhere nested under a node using ParentDefinition. |
ParentDefinition_ > _ChildDefinition | orderedList > unorderedList | The style class matches all nodes using ChildDefinition that are immediately nested under a node using ParentDefinition. |
Further refinements on a style selector can be done with pseudoclasses. Some pseudoclasses may be used to determine the position of a node inside its parent node. For example, by using the :first
pseudoclass you can specify that a certain style may be only applied to the first paragraph of a block quote:
xxxxxxxxxx
block-quote > paragraph :first {
first-line-indent:0pt
}
It is also possible to specify multiple pseudoclasses at once:
xxxxxxxxxx
block-quote > paragraph :first :last {
first-line-indent:0pt
}
There are also pseudoclasses that match depending on the position on the generated output. For example, the pseudoclasses :left-page
, :right-page
can be used to specify the format of a header or footer when exporting the left or right pages of a two-sided document. Finally, there are pseudoclasses used to specify a certain aspect of a style. For example the :enumerator
pseudoclass is used to style the enumerator of an ordered list (e.g. to make a bullet point bold).
Currently, the following pseudoclasses exist:
Name | Availability | Description |
---|---|---|
:first-page | Headers and Footers | The style will be only applied to headers or footers that are on the first page of a section. |
:left-page | Headers and Footers | The style will be only applied to headers or footers that are on the left page of a section. |
:right-page | Headers and Footers | The style will be only applied to headers or footers that are on the right page of a section. |
:anchor | Footnotes Area | The style of the anchor inside the footnote area. See Inline Class. Defaults to superscript text. |
:first | Inline, Headers and Footers, Footnotes Area, Media, Footnotes, Paragraph, Figures, Figure Captions, Divider, Block, List, Table, Table Cell, Syntax Highlight, Technical | The style matches any node that is the first child of its parent. |
:last | Inline, Headers and Footers, Footnotes Area, Media, Footnotes, Paragraph, Figures, Figure Captions, Divider, Block, List, Table, Table Cell, Syntax Highlight, Technical | The style matches any node that is the last child of its parent. |
:anchor | Footnotes | Used for styling referencing anchor of an annotation separated from the annotated content. See Inline Class. Defaults to superscript text. |
:enumerator | List | The style of the enumerator of a list. Supports all Inline style settings. |
:body | Table Cell, Table | The style will be applied to all cells of a table that are not part of the header. |
:header | Table Cell, Table | The style will be applied to all header cells of a table. |
:header-row | Table Cell, Table | The style will be applied to all header cells of a table that form a continuous row. |
:header-row-boundary | Table Cell, Table | The style will be applied to all cells that are on the boundary between regular cells and cells around one or multiple header rows. I.e. it will style all cells before the first row and on the last row of any continuous header row area. This is especially useful to style the separators enclosing multiple continuous header rows using row-separator-* . |
:header-column | Table Cell, Table | The style will be applied to all header cells of a table that form a continuous column. |
:header-column-boundary | Table Cell, Table | The style will be applied to all cells that are on the boundary between regular cells and cells around one or multiple header columns. I.e. it will style all cells before the first column and on the last column of any continuous header column area. This is especially useful to style the separators enclosing multiple continuous header columns using column-separator-* . |
:header-top | Table Cell, Table | The style will be applied to all header cells are place in the topmost header rows of the table. |
:header-top-boundary | Table Cell, Table | The style will be applied to the cells of the lowest row among the topmost headers. This is especially useful to style the separator between the topmost header rows and the rest of the table using row-separator-* . |
:header-left | Table Cell, Table | The style will be applied to all header cells are place in the leftmost header columns of the table. |
:header-left-boundary | Table Cell, Table | The style will be applied to the cells of the last column among the leftmost header columns. This is especially useful to style the separator dividing the leftmost header columns and the rest of the table using column-separator-* . |
:header-bottom | Table Cell, Table | The style will be applied to all header cells are place in the bottommost header rows of the table. |
:header-bottom-boundary | Table Cell, Table | The style will be applied to the cells of the row before the bottommost header rows. This is especially useful to style the separator dividing the bottommost header rows and the rest of the table using row-separator-* . |
:header-right | Table Cell, Table | The style will be applied to all header cells are place in the rightmost header columns of the table. |
:header-right-boundary | Table Cell, Table | The style will be applied to the cells of the columns before the rightmost header columns. This is especially useful to style the separator dividing the rightmost header columns and the rest of the table using column-separator-* . |
In some cases multiple styles may match your content like the following example shows:
xxxxxxxxxx
list-all {
margin-top:5pt
margin-left:10pt
}
list-ordered {
margin-left:20pt
}
defaults {
font-size:14pt
}
In this case, styles are applied in the order of their occurrence. For example, if a node of the type list-ordered
should be styled first list-all
will be applied, then list-ordered
and finally defaults
. Thus, the computed style will be:
xxxxxxxxxx
margin-top:5pt// from list-all
margin-left:20pt// from list-ordered
font-size:14pt// from defaults
If you are exporting nodes that are nested in other nodes, the nested contents inherits all styles of higher level that it does not define by itself. Consider, you have the following Markdown document and the following Ulysses Style Sheet:
xxxxxxxxxx
> # Heading with **strong text**
> Normal text inside quote
block-quote {
font-family:"Cochin"
font-slant:italic
}
heading-1 {
font-family:"Futura"
font-size:24pt
}
inline-strong {
font-weight:bold
}
The style of “strong text” will be derived by mixing the style of block-quote
with heading-1
and inline-strong
. Whereas the settings of inner elements overwrite the settings of outer elements. Thus, the computed style will be:
xxxxxxxxxx
font-family:"Futura"// heading-1 overwrites the font-family of block-quote
font-slant:italic// Inherited form block-quote
font-size:24pt// Set by heading-1
font-weight:bold// Set by inline-strong
Sometimes it is useful to create general presets that can be shared around multiple styles. For example the style inline-code
and code-block
may share the same font settings. This can be done by using mixins. A mixin is a set of predefined settings that can be embedded into other styles. The following example shows how a mixin @general-code-style
is defined and how it is embedded to a style:
xxxxxxxxxx
@general-code-style {
font-family: "Courier"
font-size: 12pt
}
inline-code : @general-code-style {
font-color: #0000ff
}
block-code : @general-code-style {
font-color: #ffffff
background-color: #0000ff
}
A mixin identifier always starts with an “@
” character. A mixin identifier may contain any alphanumeric character. Multiple words are typically separated by dashes: @my-mixin-name
. It is applied to a style definition after the style selector using a colon “:
”. To apply multiple mixins to a style, just use a comma separated list:
xxxxxxxxxx
some-style : @first-mixin, @second-mixin, @third-mixin {
}
Any style consists of style settings describing all the visual details used for exporting a document. Typically, style settings consists of simple values - like assigning a setting font-weight
the value bold
xxxxxxxxxx
inline-strong {
font-weight: bold;
}
Every style setting has a type that defines the valid values you may use for it. The type of each settings is documented in the Settings Reference. Currently, the following types exists:
Type name | Examples | Description |
---|---|---|
boolean | YES , NO , true , false | A boolean value indicating that a setting is true or false. Allowed values are case-insenstive variants of: YES , NO and TRUE , FALSE . Whereas there is no difference between YES and true , or NO and false . |
number | -3.141 | A decimal number. Negative or positive values are possible. The decimal point is optional. |
length | 5pt , 10cm , 30% , 4em | An absolute or relative length value. Absolute values can be specified in pt , mm , cm , in . Relative values are typically relative to the current font size. They can be specified in em , en , ex , % . |
string | "Arial" | A string value. Must be set into quotes. May contain also whitespaces. Used for any user-defined string values (e.g. font names or placeholder strings). |
symbol | bold , italic | A symbolic setting. Possible values depend on the concrete style setting. |
color | #ff0000 , rgb(255,0,0) | An RGB color value. Can be either specified as 8-digit hex (#ff0000 ) or as sequence of three decimal numbers between 0 and 255 (rgb(255,0,42) . |
array | [5pt, 3pt, 2pt] | An array of values. Typically the elements of an array must have a certain type, too (e.g. an array of length values or symbols). |
Ulysses Style Sheets allow you to use more complex expressions, employing arithmetic operators (+
, -
, *
, /
) and even variables containing present values. In the following example a variable $base-size
is defined that is used as base value for styling heading1
and heading2
.
xxxxxxxxxx
$base-size = 12pt
heading-1 {
font-size: $base-size * 2
}
heading-2 {
font-size: $base-size * 0.5
}
Variable names begin with a dollar sign “$
“ and consists of any alphanumeric characters and dashes. They are declared by assignment statements using the form $variable-name = VALUE
. Whereas variable values may contain arbitrary expressions and variables themselves. For example, you may create a variable $heading-size
that is calculated from the value of $base-size
:
xxxxxxxxxx
$base-size = 12pt
$heading-size = $base-size * 2
In general, any expression may contain arithmetic operators (+
, -
, *
, /
) that combine values and variables. To group expressions it is possible to use round brackets:
xxxxxxxxxx
$some-variable = 4 * (5 / (2 + 3))
However, not every type supports any kind of operator. The following table shows you all possible combinations:
Left Operand Type | Right Operand Type | Allowed operation |
---|---|---|
Number | Number | + , - , * , / |
Length | Number | * , / |
Number | Length | * |
Color | Number | * , / |
Number | Color | * |
Length | Length | + , - |
Color | Color | + , - |
This section describes all available classes that can be used to style the export of an Ulysses document. We distinguish between two major types of style classes: General classes and Definition classes.
General classes are all style classes used to define the visual appearance of the entire exported document (e.g. document-settings
or header
). Currently, the following general classes can be used:
Class Group | Description |
---|---|
Document Settings | Used to describe all settings regarding the appearance of the exported document. |
Headers and Footers | Describes the layout and the content of the header/footer of a page. Can be used to setup running headlines or page numbers. Inherits all inline and paragraph style settings. Provides special pseudo-classes :first-page , :left-page and :right-page that allow to style headers/footers on two-sided documents differently for first, left and right pages. |
Footnotes Area | Describes the layout and the content of the area containing the footnotes of a page or the endnotes of a section/document (see footnote-placement ). Please note that some styling options are only available to PDF export. Elements inside a footnote can be styled by using a relative style selector on inline-footnote , such as inline-footnote paragraph { … } . |
Definition classes are all style classes that can be used to style content with a concrete definition in your Ulysses document (e.g. strong
or headline
). You may currently use the following definition classes:
Definition Classes | Selectors | Description |
---|---|---|
Inline | inline-strong , inline-emphasis , inline-code , inline-citation , inline-comment , inline-raw , inline-mark , inline-delete , inline-link | Inline classes are used for definitions typically applied to inline contents. The style settings of all parent elements (e.g. paragraphs, lists) will be also inherited to inline elements. |
Media | media-image | Media classes are used to style image-like contents. To style figure-like images there is a special paragraph style paragraph-figures that also allows to style the caption of figure-like images. |
Footnotes | inline-footnote , inline-annotation | Footnote classes are used to style any footnote-like content, like footnotes or annotations. Footnote classes have a special pseudoclass :anchor that allows the styling of the anchor. This is especially useful for annotations, to style the annotated content differently from the anchor. |
Paragraph | paragraph , heading-1 , heading-2 , heading-3 , heading-4 , heading-5 , heading-6 , heading-all , defaults | Paragraph classes are used for definitions typically applied to paragraph-level nodes. The style settings of all parent elements (e.g. lists) will be also inherited to the paragraph style. Inline-style settings specified in a paragraph class will be applied to all child nodes, if not overwritten. |
Figures | paragraph-figure | This style will be applied to all paragraphs that only contain images (besides whitespaces and comments). Images inside such a paragraph will be exported as figures with an optional caption. See media-image for more information on image styling. |
Figure Captions | figure-caption | This style will be applied to the caption of a Figure or a Table. The caption inherits the style settings of the surrounding figure or table. It is possible to style figure and table captions individually by using a relative style selector. |
Divider | paragraph-divider | The divider class is used to separate parts of the document logically. It may be either used to add a styled separator or to add a page break. |
Block | block-quote , block-code , block-raw , block-comment , block-all | Block classes are used for any contents grouping multiple paragraphs, such as blockquotes or lists. They provide the same settings as paragraph classes. The top and bottom margins of a block will be applied to its first and last paragraph. |
List | list-ordered , list-unordered , list-all | Lists are special blocks that consists of a list of items. Each item has an enumerator that may be counted. Lists have a special pseudoclass :enumerator that allows the styling of the enumerator of each item. |
Table | table | The table class is used for styling an entire table. It provides default settings for cells of the table as well as settings that apply to the table as whole (e.g. borders and margins of the table). The caption of a table is placed above it and uses the figure-caption style. |
Table Cell | table-cell | Every table consists of multiple table cells that are arranged in rows and columns. Table cell styles allow you to define the visual appearance of cells. Cells can be surrounded by separators, whereas each cell has a row separator on its bottom side and a column separator on its right side. You can define the background colors of cells using the cell-color setting and even define alternative row / column colors using alternate-row-color and alternate-column-color . There are also various pseudoclasses for styling the headers of a table, such as :header for styling all headers and :header-top for styling all headers bound to the top of the table. You can also style cells that are at the boundary between headers and non-header areas using separator pseudoclasses (e.g. :header-top-boundary or :header-bottom-boundary ). |
Syntax Highlight | syntax-all , syntax-comment , syntax-constant , syntax-entity , syntax-parameter , syntax-tag , syntax-keyword , syntax-string , syntax-variable , syntax-error , syntax-escape , syntax-heading , syntax-italic , syntax-bold , syntax-deleted , syntax-inserted , syntax-changed , syntax-list , syntax-link | Syntax classes are used for styling the highlighted text inside code blocks. Ulysses applies these syntax classes to the contents of a code block depending on the selected programming language. You can also download an example document that contains all available syntax classes. |
Technical | ulysses-tag , ulysses-whitespace , ulysses-escape-character , ulysses-escape | Technical styles can be used for exporting Ulysses documents with full markup and whitespaces. Besides ulysses-escape , all technical styles are hidden by default. |
This section gives you a detailed reference on any available style settings.
Style Setting | Description |
---|---|
column-count | The number of text columns used for output. |
column-spacing-width | The spacing between two text columns for multi-column layouts. |
footnote-enumeration | Specifies how to enumerate footnotes. |
footnote-placement | Specifies where to place footnotes in the document. |
footnote-style | The style that should be used for enumerating footnotes. |
locale | The locale that should be used for hyphenation if language detection fails. |
page-binding | The position of the page binding. |
page-height | The height of the page. |
page-inset-bottom | The spacing between the bottom border of a page and the page content. |
page-inset-inner | The spacing between the inner border of a page and the page content. Depends on page-binding and two-sided . |
page-inset-outer | The spacing between the outer border of a page and the page content. Depends on page-binding and two-sided . |
page-inset-top | The spacing between the top border of a page and the page content. |
page-number-format | The format string that should be used for page numbers. |
page-number-reset | Specifies whether page numbers should be reset on each section. |
page-number-style | The style that should be used for generating page numbers. |
page-orientation | The orientation of a page. |
page-width | The width of the page. |
section-break | Specifies whether headings or dividers will introduce a section break. |
two-sided | Specifies whether the output should be generated for two-sided printing or not. |
Style Setting | Description |
---|---|
bottom-spacing | The spacing on the bottom of a header / footer. |
content | The content that should be filled in to the header / footer. |
top-spacing | The spacing on the top of a header / footer. |
Style Setting | Description |
---|---|
anchor-alignment | The horizontal alignment of a footnote anchor. |
anchor-inset | The inset of a footnote anchor inside the footnote area. |
divider-length | The length of the divider line of a footnote. |
divider-position | The horizontal position of the divider line of a footnote. |
divider-spacing | The spacing between the separator line of a footnote and its contents. |
divider-width | The width of the divider line of a footnote. |
text-inset | The inset of the text of the footnote area. |
top-spacing | The spacing before the separator line of a footnote. |
Style Setting | Description |
---|---|
background-color | The background color of the text. |
baseline-shift | The text position relative to the baseline. |
character-spacing | Additional character spacing. |
font-color | The foreground color of the text. |
font-family | The family name of a font. |
font-size | The size of the font used for styling text. |
font-slant | The obliqueness of a font. |
font-style | The typographic style of a font. |
font-weight | The weight of a font. |
strikethrough | The strikethrough style of the text. |
strikethrough-color | The color of the text strikethrough. |
style-title | The name of the style used for format templates in DOCX files. |
underline | The underline style of the text. |
underline-color | The color of the text underline. |
visibility | The visibility of an element. |
Style Setting | Description |
---|---|
margin-left | The left margin of the element. |
margin-right | The right margin of the element. |
Style Setting | Description |
---|---|
footnote-visibility | Specifies whether the element should be actually treated as footnote or as ordinary inline text. |
Style Setting | Description |
---|---|
default-tab-interval | The default length of the spacing between the beginning of two tab stops. |
first-line-indent | The indentation of the first line of a paragraph. |
hyphenation | Whether hyphenation shold be applied to a paragraph. |
justify-line-breaks | Whether text should be justified on line breaks. |
keep-with-following | Keep the paragraph with the following paragraphs if a page break occurs. |
line-height | The distance between the baselines of two adjacent lines of a paragraph. |
margin-bottom | The bottom margin of a paragraph. |
margin-left | The left margin of a paragraph. |
margin-right | The right margin of a paragraph. |
margin-top | The top margin of a paragraph. |
orphans-and-widows | The handling of orphans and widows in paragraphs. |
page-break | Specifies, whether a page break should occur before or after a paragraph. |
tab-alignments | The horizontal text alignments for each tabulator. |
tab-positions | The start positions for each tabulators. |
text-alignment | The horizontal alignment of a paragraph’s text. |
Style Setting | Description |
---|---|
content | The content of a divider. |
Style Setting | Description |
---|---|
enumeration-format | The format string that should be used for generating an enumerator. |
enumeration-style | The style that should be used for generating an enumerator. |
item-spacing | The spacing between two items of the list. |
itemization | Specifies whether a list should be treated as ordinary block. |
text-inset | The position of the text inside a text list. |
Style Setting | Description |
---|---|
border-color | The color of any border line around the table. |
border-style | The styling of any border line around the table. |
border-width | The width of any border line around the table. |
caption-placement | The placement of the table caption. |
padding-collapse | Whether paddings of adjacent cells should collapse if there is no separator. |
Style Setting | Description |
---|---|
alternate-column-color | An alternate background color that should be applied on all cells in even numbered column. |
alternate-row-color | An alternate background color that should be applied on all cells in even numbered rows. |
cell-color | The background color of a table cell. |
padding | The padding between a cell’s border and its contents. |
separator-color | The color of the row and column separator of a table cell. |
separator-style | The styling of the row and column separator of a table cell. |
separator-width | The width of the row and column separator of a table cell. |
To support you editing ULSS styles, we’ve created plugins for TextMate 2 and Sublime Text 2. You may download and freely use them!
TextMate 2 is a free text editor for OS X. To add support for ULSS syntax highlighting, follow these steps:
Download the plugin and extract it
Double-click the bundle file to install it
Restart TextMate 2
TextMate will now open .ulss
files with our syntax highlighting and provide a (limited) auto-completion.
With Sublime, you will get full syntax highlighting. The plugin is available on package control.
We’ve also created a simple syntax highlighting plugin for BBEdit and TextWrangler. You may install it by the following steps:
Download the plugin and extract it
In Finder select the menu Go > Go to Folder and enter the following path:
BBEdit: ~/Library/Application Support/BBEdit/Language Modules
TextWrangler: ~/Library/Application Support/TextWrangler/Language Modules
Copy the file ULSS.plist inside this folder
Restart BBEdit / TextWrangler
The Visual Studio Code package offers syntax highlighting and simple support for auto-completion. To install the plugin, follow these steps:
Visit the package’s marketplace site (don’t worry, it’s free).
Click install.
For more information on installing packages in Visual Studio Code, visit the getting stared guide.