Ulysses Style Reference


Defining Styles

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:

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:

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.

Style Selectors

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.

Relative Selectors

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:

The following relations can be used for relative style selectors:

RelationExampleDescription
DefinitionstrongThe style class matches all nodes using a certain Definition.
Definition_ + _SuccessorDefinitionheading1 + all-paragraphsThe style class matches all nodes using SuccessorDefinition that follow immediately a node using Definition.
ParentDefinition_ _ChildDefinitionarea-footnotes imageThe style class matches all nodes using ChildDefinition that are somewhere nested under a node using ParentDefinition.
ParentDefinition_ > _ChildDefinitionorderedList > unorderedListThe style class matches all nodes using ChildDefinition that are immediately nested under a node using ParentDefinition.

Pseudoclasses

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:

It is also possible to specify multiple pseudoclasses at once:

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:

NameAvailabilityDescription
:first-pageHeaders and FootersThe style will be only applied to headers or footers that are on the first page of a section.
:left-pageHeaders and FootersThe style will be only applied to headers or footers that are on the left page of a section.
:right-pageHeaders and FootersThe style will be only applied to headers or footers that are on the right page of a section.
:anchorFootnotes AreaThe style of the anchor inside the footnote area. See Inline Class. Defaults to superscript text.
:firstInline, Headers and Footers, Footnotes Area, Media, Footnotes, Paragraph, Figures, Figure Captions, Divider, Block, List, Table, Table Cell, Syntax Highlight, TechnicalThe style matches any node that is the first child of its parent.
:lastInline, Headers and Footers, Footnotes Area, Media, Footnotes, Paragraph, Figures, Figure Captions, Divider, Block, List, Table, Table Cell, Syntax Highlight, TechnicalThe style matches any node that is the last child of its parent.
:anchorFootnotesUsed for styling referencing anchor of an annotation separated from the annotated content. See Inline Class. Defaults to superscript text.
:enumeratorListThe style of the enumerator of a list. Supports all Inline style settings.
:bodyTable Cell, TableThe style will be applied to all cells of a table that are not part of the header.
:headerTable Cell, TableThe style will be applied to all header cells of a table.
:header-rowTable Cell, TableThe style will be applied to all header cells of a table that form a continuous row.
:header-row-boundaryTable Cell, TableThe 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-columnTable Cell, TableThe style will be applied to all header cells of a table that form a continuous column.
:header-column-boundaryTable Cell, TableThe 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-topTable Cell, TableThe style will be applied to all header cells are place in the topmost header rows of the table.
:header-top-boundaryTable Cell, TableThe 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-leftTable Cell, TableThe style will be applied to all header cells are place in the leftmost header columns of the table.
:header-left-boundaryTable Cell, TableThe 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-bottomTable Cell, TableThe style will be applied to all header cells are place in the bottommost header rows of the table.
:header-bottom-boundaryTable Cell, TableThe 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-rightTable Cell, TableThe style will be applied to all header cells are place in the rightmost header columns of the table.
:header-right-boundaryTable Cell, TableThe 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-*.

Evaluation Order

In some cases multiple styles may match your content like the following example shows:

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:

Inheritance

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:

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:

Mixins

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:

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:

Using Style Settings

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

Types

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 nameExamplesDescription
booleanYES, NO, true, falseA 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.141A decimal number. Negative or positive values are possible. The decimal point is optional.
length5pt, 10cm, 30%, 4emAn 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).
symbolbold, italicA 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).

Expressions

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.

Variables

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:

Operators

In general, any expression may contain arithmetic operators (+, -, *, /) that combine values and variables. To group expressions it is possible to use round brackets:

However, not every type supports any kind of operator. The following table shows you all possible combinations:

Left Operand TypeRight Operand TypeAllowed operation
NumberNumber+, -, *, /
LengthNumber*, /
NumberLength*
ColorNumber*, /
NumberColor*
LengthLength+, -
ColorColor+, -

Class Reference

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

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 GroupDescription
Document SettingsUsed to describe all settings regarding the appearance of the exported document.
Headers and FootersDescribes 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 AreaDescribes 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

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 ClassesSelectorsDescription
Inlineinline-stronginline-emphasisinline-codeinline-citationinline-commentinline-rawinline-markinline-deleteinline-linkInline classes are used for definitions typically applied to inline contents. The style settings of all parent elements (e.g. paragraphslists) will be also inherited to inline elements.
Mediamedia-imageMedia 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.
Footnotesinline-footnoteinline-annotationFootnote 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.
Paragraphparagraphheading-1heading-2heading-3heading-4heading-5heading-6heading-alldefaultsParagraph 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.
Figuresparagraph-figureThis 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 Captionsfigure-captionThis 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.
Dividerparagraph-dividerThe 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.
Blockblock-quoteblock-codeblock-rawblock-commentblock-allBlock 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.
Listlist-orderedlist-unorderedlist-allLists 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.
TabletableThe 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 Celltable-cellEvery 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 Highlightsyntax-allsyntax-commentsyntax-constantsyntax-entitysyntax-parametersyntax-tagsyntax-keywordsyntax-stringsyntax-variablesyntax-errorsyntax-escapesyntax-headingsyntax-italicsyntax-boldsyntax-deletedsyntax-insertedsyntax-changedsyntax-listsyntax-linkSyntax 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.
Technicalulysses-tagulysses-whitespaceulysses-escape-characterulysses-escapeTechnical styles can be used for exporting Ulysses documents with full markup and whitespaces. Besides ulysses-escape, all technical styles are hidden by default.

Settings Reference

This section gives you a detailed reference on any available style settings.

Overview

Document Settings

Style SettingDescription
column-countThe number of text columns used for output.
column-spacing-widthThe spacing between two text columns for multi-column layouts.
footnote-enumerationSpecifies how to enumerate footnotes.
footnote-placementSpecifies where to place footnotes in the document.
footnote-styleThe style that should be used for enumerating footnotes.
localeThe locale that should be used for hyphenation if language detection fails.
page-bindingThe position of the page binding.
page-heightThe height of the page.
page-inset-bottomThe spacing between the bottom border of a page and the page content.
page-inset-innerThe spacing between the inner border of a page and the page content. Depends on page-binding and two-sided.
page-inset-outerThe spacing between the outer border of a page and the page content. Depends on page-binding and two-sided.
page-inset-topThe spacing between the top border of a page and the page content.
page-number-formatThe format string that should be used for page numbers.
page-number-resetSpecifies whether page numbers should be reset on each section.
page-number-styleThe style that should be used for generating page numbers.
page-orientationThe orientation of a page.
page-widthThe width of the page.
section-breakSpecifies whether headings or dividers will introduce a section break.
two-sidedSpecifies whether the output should be generated for two-sided printing or not.

Headers and Footers

Style SettingDescription
bottom-spacingThe spacing on the bottom of a header / footer.
contentThe content that should be filled in to the header / footer.
top-spacingThe spacing on the top of a header / footer.

Footnotes Area

Style SettingDescription
anchor-alignmentThe horizontal alignment of a footnote anchor.
anchor-insetThe inset of a footnote anchor inside the footnote area.
divider-lengthThe length of the divider line of a footnote.
divider-positionThe horizontal position of the divider line of a footnote.
divider-spacingThe spacing between the separator line of a footnote and its contents.
divider-widthThe width of the divider line of a footnote.
text-insetThe inset of the text of the footnote area.
top-spacingThe spacing before the separator line of a footnote.

Inline

Style SettingDescription
background-colorThe background color of the text.
baseline-shiftThe text position relative to the baseline.
character-spacingAdditional character spacing.
font-colorThe foreground color of the text.
font-familyThe family name of a font.
font-sizeThe size of the font used for styling text.
font-slantThe obliqueness of a font.
font-styleThe typographic style of a font.
font-weightThe weight of a font.
strikethroughThe strikethrough style of the text.
strikethrough-colorThe color of the text strikethrough.
style-titleThe name of the style used for format templates in DOCX files.
underlineThe underline style of the text.
underline-colorThe color of the text underline.
visibilityThe visibility of an element.

Media

Style SettingDescription
margin-leftThe left margin of the element.
margin-rightThe right margin of the element.

Footnotes

Style SettingDescription
footnote-visibilitySpecifies whether the element should be actually treated as footnote or as ordinary inline text.

Paragraph

Style SettingDescription
default-tab-intervalThe default length of the spacing between the beginning of two tab stops.
first-line-indentThe indentation of the first line of a paragraph.
hyphenationWhether hyphenation shold be applied to a paragraph.
justify-line-breaksWhether text should be justified on line breaks.
keep-with-followingKeep the paragraph with the following paragraphs if a page break occurs.
line-heightThe distance between the baselines of two adjacent lines of a paragraph.
margin-bottomThe bottom margin of a paragraph.
margin-leftThe left margin of a paragraph.
margin-rightThe right margin of a paragraph.
margin-topThe top margin of a paragraph.
orphans-and-widowsThe handling of orphans and widows in paragraphs.
page-breakSpecifies, whether a page break should occur before or after a paragraph.
tab-alignmentsThe horizontal text alignments for each tabulator.
tab-positionsThe start positions for each tabulators.
text-alignmentThe horizontal alignment of a paragraph’s text.

Divider

Style SettingDescription
contentThe content of a divider.

List

Style SettingDescription
enumeration-formatThe format string that should be used for generating an enumerator.
enumeration-styleThe style that should be used for generating an enumerator.
item-spacingThe spacing between two items of the list.
itemizationSpecifies whether a list should be treated as ordinary block.
text-insetThe position of the text inside a text list.

Table

Style SettingDescription
border-colorThe color of any border line around the table.
border-styleThe styling of any border line around the table.
border-widthThe width of any border line around the table.
caption-placementThe placement of the table caption.
padding-collapseWhether paddings of adjacent cells should collapse if there is no separator.

Table Cell

Style SettingDescription
alternate-column-colorAn alternate background color that should be applied on all cells in even numbered column.
alternate-row-colorAn alternate background color that should be applied on all cells in even numbered rows.
cell-colorThe background color of a table cell.
paddingThe padding between a cell’s border and its contents.
separator-colorThe color of the row and column separator of a table cell.
separator-styleThe styling of the row and column separator of a table cell.
separator-widthThe width of the row and column separator of a table cell.

Editor Plugins

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

TextMate 2 is a free text editor for OS X. To add support for ULSS syntax highlighting, follow these steps:

  1. Download the plugin and extract it

  2. Double-click the bundle file to install it

  3. Restart TextMate 2

TextMate will now open .ulss files with our syntax highlighting and provide a (limited) auto-completion.

Sublime Text

With Sublime, you will get full syntax highlighting. The plugin is available on package control.

BBEdit and TextWrangler

We’ve also created a simple syntax highlighting plugin for BBEdit and TextWrangler. You may install it by the following steps:

  1. Download the plugin and extract it

  2. 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

  3. Copy the file ULSS.plist inside this folder

  4. Restart BBEdit / TextWrangler

Visual Studio Code

The Visual Studio Code package offers syntax highlighting and simple support for auto-completion. To install the plugin, follow these steps:

  1. Visit the package’s marketplace site (don’t worry, it’s free).

  2. Click install.

For more information on installing packages in Visual Studio Code, visit the getting stared guide.