Prose

The prose component provides proper styling for rendered Markdown.

Class Output
.s-prose Adds proper styling for rendered Markdown.
.s-prose__xs Our most compact version with the smallest font size and line height.
.s-prose__sm Decreases the base font size and line height.
.s-prose__md Increases the base font size and line height.

We modified this test document from the folks at Tailwind to demonstrate and explain our design choices.

Stacks adds a new s-prose class that you can slap on any block of vanilla HTML content and turn it into a beautiful, well-formatted document:

<article class="s-prose">
  <h1>Garlic bread with cheese: What the science tells us</h1>
  <p>
    For years parents have espoused the health benefits of eating garlic bread with cheese to their
    children, with the food earning such an iconic status in our culture that kids will often dress
    up as warm, cheesy loaf for Halloween.
  </p>
  <p>
    But a recent study shows that the celebrated appetizer may be linked to a series of rabies cases
    springing up around the country.
  </p>
  <!-- ... -->
</article>

What to expect from here on out

What follows from here is just a bunch of absolute nonsense we’ve written to dogfood the component itself. It includes every sensible typographic element we could think of, like bold text, unordered lists, ordered lists, code blocks, block quotes, and even italics.

It’s important to cover all of these use cases for a few reasons:

  1. We want everything to look good out of the box.
  2. Really just the first reason, that’s the whole point of the plugin.
  3. Here’s a third pretend reason though a list with three items looks more realistic than a list with two items.

Now we’re going to try out another header style.

Typography should be easy

So that’s a header for you—with any luck if we’ve done our job correctly that will look pretty reasonable.

Something a wise person once told me about typography is:

Typography is pretty important if you don’t want your stuff to look like trash. Make it good then it won’t be bad.

It’s probably important that images look okay here by default as well:

Now I’m going to show you an example of an unordered list to make sure that looks good, too:

  • So here is the first item in this list.
  • In this example we’re keeping the items short.
  • Later, we’ll use longer, more complex list items.

And that’s the end of this section.

What if we stack headings?

We should make sure that looks good, too.

Sometimes you have headings directly underneath each other. In those cases you often have to undo the top margin on the second heading because it usually looks better for the headings to be closer together than a paragraph followed by a heading should be.

When a heading comes after a paragraph …

When a heading comes after a paragraph, we need a bit more space, like I already mentioned above. Now let’s see what a more complex list would look like.

  • I often do this thing where list items have headings.

    For some reason I think this looks cool which is unfortunate because it’s pretty annoying to get the styles right.

    I often have two or three paragraphs in these list items, too, so the hard part is getting the spacing between the paragraphs, list item heading, and separate list items to all make sense. Pretty tough honestly, you could make a strong argument that you just shouldn’t write this way.

  • Since this is a list, I need at least two items.

    I explained what I’m doing already in the previous list item, but a list wouldn’t be a list if it only had one item, and we really want this to look realistic. That’s why I’ve added this second list item so I actually have something to look at when writing the styles.

  • It’s not a bad idea to add a third item either.

    I think it probably would’ve been fine to just use two items but three is definitely not worse, and since I seem to be having no trouble making up arbitrary things to type, I might as well include it.

After this sort of list I usually have a closing statement or paragraph, because it kinda looks weird jumping right to a heading.

Code should look okay by default.

Here’s what a default tailwind.config.js file looks like at the time of writing:

module.exports = {
  purge: [],
  theme: {
    extend: {},
  },
  variants: {},
  plugins: [],
}

Hopefully that looks good enough to you.

What about nested lists?

Nested lists basically always look bad which is why editors like Medium don’t even let you do it, but I guess since some of you goofballs are going to do it we have to carry the burden of at least making it work.

  1. Nested lists are rarely a good idea.
    • You might feel like you are being really “organized” or something but you are just creating a gross shape on the screen that is hard to read.
    • Nested navigation in UIs is a bad idea too, keep things as flat as possible.
    • Nesting tons of folders in your source code is also not helpful.
  2. Since we need to have more items, here’s another one.
    • I’m not sure if we’ll bother styling more than two levels deep.
    • Two is already too much, three is guaranteed to be a bad idea.
    • If you nest four levels deep you belong in prison.
  3. Two items isn’t really a list, three is good though.
    • Again please don’t nest lists if you want people to actually read your content.
    • Nobody wants to look at this.
    • I’m upset that we even have to bother styling this.

The most annoying thing about lists in Markdown is that <li> elements aren’t given a child <p> tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too.

  • For example, here’s another nested list.

    But this time with a second paragraph.

    • These list items won’t have <p> tags
    • Because they are only one line each
  • But in this second top-level list item, they will.

    This is especially annoying because of the spacing on this paragraph.

    • As you can see here, because I’ve added a second line, this list item now has a <p> tag.

      This is the second line I’m talking about by the way.

    • Finally here’s another list item so it’s more like a list.

  • A closing list item, but with no nested list, because why not?

And finally a sentence to close off this section.

There are other elements we need to style

I almost forgot to mention links, like Stack Overflow.

We even included table styles, check it out:

Wrestler Origin Finisher
Bret "The Hitman" Hart Calgary, AB Sharpshooter
Stone Cold Steve Austin Austin, TX Stone Cold Stunner
Randy Savage Sarasota, FL Elbow Drop
Vader Boulder, CO Vader Bomb
Razor Ramon Chuluota, FL Razor’s Edge

We also need to make sure inline code looks good, like if I wanted to talk about <span> elements.

Sometimes I even use code in headings

Another thing I’ve done in the past is put a code tag inside of a link, like if I wanted to tell you about the stackexchange/stacks repository. I don’t love that there is an underline below the backticks but it is absolutely not worth the madness it would require to avoid it.

We still need to think about stacked headings though.

Let’s make sure we don’t screw that up with h4 elements, either.

Phew, with any luck we have styled the headings above this text and they look pretty good.

We should also make sure we're styling h5 elements as well.

Let’s add a closing paragraph here so things end with a decently sized block of text. I can’t explain why I want things to end that way but I have to assume it’s because I think things will look weird or unbalanced if there is a heading too close to the end of the document.

And, finally, an h6.

Ultimately, though, we also want to support the h6 headers.

What I’ve written here is probably long enough, but adding this final sentence can’t hurt.

The following is a real-world answer taken from Stack Overflow

Executive Summary

$ git push -d <remote_name> <branch_name>
$ git branch -d <branch_name>

Note that in most cases the remote name is origin. In such a case you'll have to use the command like so.

$ git push -d origin <branch_name>

Delete Local Branch

To delete the local branch use one of the following:

$ git branch -d branch_name
$ git branch -D branch_name

Note: The -d option is an alias for --delete, which only deletes the branch if it has already been fully merged in its upstream branch. You could also use -D, which is an alias for --delete --force, which deletes the branch "irrespective of its merged status." [Source: man git-branch]

Delete Remote Branch

As of Git v1.7.0, you can delete a remote branch using

$ git push <remote_name> --delete <branch_name>

which might be easier to remember than

$ git push <remote_name> :<branch_name>

which was added in Git v1.5.0 "to delete a remote branch or a tag."

Starting on Git v2.8.0 you can also use git push with the -d option as an alias for --delete.

Therefore, the version of Git you have installed will dictate whether you need to use the easier or harder syntax.

Delete Remote Branch

From Chapter 3 of Pro Git by Scott Chacon:

Deleting Remote Branches

Suppose you’re done with a remote branch — say, you and your collaborators are finished with a feature and have merged it into your remote’s master branch (or whatever branch your stable code-line is in). You can delete a remote branch using the rather obtuse syntax git push [remotename] :[branch]. If you want to delete your server-fix branch from the server, you run the following:

$ git push origin :serverfix
To git@github.com:schacon/simplegit.git
 - [deleted]         serverfix

Boom. No more branches on your server. You may want to dog-ear this page, because you’ll need that command, and you’ll likely forget the syntax. A way to remember this command is by recalling the git push [remotename] [localbranch]:[remotebranch] syntax that we went over a bit earlier. If you leave off the [localbranch] portion, then you’re basically saying, “Take nothing on my side and make it be [remotebranch].”

I issued git push origin: bugfix and it worked beautifully. Scott Chacon was right—I will want to dog ear that page (or virtually dog ear by answering this on Stack Overflow).

Then you should execute this on other machines

# Fetch changes from all remotes and locally delete 
# remote deleted branches/tags etc
# --prune will do the job :-;
git fetch --all --prune

to propagate changes.

Let’s see what a link preview looks like within the prose component.

This example includes the full kitchen-sink collection of everything the Markdown spec includes.

<div class="s-prose">

</div>

The Comprehensive Formatting Test

Code Formatting

  • Inline code formatting or code spans
    • Normal backticks System.out.println("Hello World!");.
    • Escaped backticks: for line in `someCommand`
    • A single backtick character in a line won't form a code block '`'.
    • There are two backtick characters ('`') in this line ('`').
  • Block code formatting
System.out.println("Hello World!");
System.out.println("Code Block!");
<div class="s-progress s-progress__stepped">
    <div class="s-progress--step is-complete">
        <a href="…" class="s-progress--stop">
            @Svg.CheckmarkSm
        </a>
        <div class="s-progress--bar s-progress--bar__right"></div>
        <a class="s-progress--label"></a>
    </div>

    <div class="s-progress--step is-complete">
        <a href="…" class="s-progress--stop">
            @Svg.CheckmarkSm
        </a>
        <div class="s-progress--bar s-progress--bar__left"></div>
        <div class="s-progress--bar s-progress--bar__right"></div>
        <a class="s-progress--label"></a>
    </div>

    <div class="s-progress--step is-active">
        <div class="s-progress--stop"></div>
        <div class="s-progress--bar s-progress--bar__left"></div>
        <div class="s-progress--bar s-progress--bar__right"></div>
        <div class="s-progress--label"></div>
    </div>

    <div class="s-progress--step">
        <div class="s-progress--stop"></div>
        <div class="s-progress--bar s-progress--bar__left"></div>
        <div class="s-progress--label"></div>
    </div>
</div>
  • HTML and other markdown are not supported within code spans or code blocks.

    ```
    </code> *Not in code!* <code>
    ```
    
    </code> *Not in code!* <code>
    

Line Breaks

  • This is one line. This was intended to be on the next line, but it appears on the same line.

  • This is one paragraph. It has some sentences.

    This is intended to be a second paragraph.

  • This is one line.
    This is intended to be on the next line.

Italics and Bold

  • This is italic text. This is italic too.

  • This is bold text. This is bold too.

  • underscores only and asterisks only and underscore and asterisk and asterisk and underscore.

  • Four!

  • Five!

  • Two and Two!

  • One and One!

Links

Images

  • Inline images, similar to links but with leading !:
    • A normal image
      An image of a unicorn
    • An image with a tooltip
      An image of a unicorn
    • Escaped image so as to not render the actual image
      ![An image of a unicorn](https://i.stack.imgur.com/7I1jg.jpg (Unicorn!))
  • Reference images:
    • image of a unicorn
  • Image links - surround an image with a link. An image of a unicorn
  • A bunch of images in a row

Headers

  • Heading 1

  • Heading 2

  • Heading 3

  • Heading 4

  • Heading 5
  • Heading 6
  • Escaped # # Not a heading
  • Italic Header

Horizontal Rules


Blockquotes

A general quote With multiple lines

First level!

Second level!

Third level!

Need blank line and one less Spanning a blank line

  • A quote within a list item

  • One can nest blockquotes with multiple > characters.

    First level!

    Second level!

    Third level!

    Need blank line and one less < to go back to second.

    Same idea for back to first.

  • Escape a > character with a backslash.

    > I want a >!

  • Markdown within a blockquote

    Enjoy this unicorn!

    image of a unicorn

  • Code formatting works within a blockquote. Indenting requires 5 spaces: 1 for the blockquote, and 4 for the code indention.

    System.out.println("Hello World!");
    

    Inline: System.out.println("Hello World!");

    Code fence:

    System.out.println("Hello World!");
    

Lists

  • Unordered Lists
    • One
    • Two
    • Three
  1. Ordered Lists
    1. One
    2. Two
    3. Three
  • Multiple lines within list items: indent 4 spaces, or do we need to?
  1. Same line Continuation of the same line
  2. Next line Not indented
  3. Next line Continuation of the same line
  • Nested lists: indent 4 spaces.
  1. Top level
    • Mid level
      1. Bottom level
    • Mid level
      • Bottom level
  2. Top level
    1. Mid level
      • Bottom level
  • List item

    List paragraph

  • List item

    List paragraph

    • Subitem
    • Subitem

    List paragraph

  • Code within list items: indention requires blank line then 4 additional spaces beyond list indention level.
  1. Top level

    System.out.println("Code fence");
    

    Inline: System.out.println("Inline");

  • Blockquote within list items: blank line then indent 4 spaces.
  1. Top level

    Quote is indented.

Markdown Escapes

\ ` * _ { } [ ] ( ) # + - . !

Tables

Syntax Whatever
Title Title
Title Title

Strikethrough

Incorrect

Spoilers

  • Create a spoiler with >!:

Tyler Durden is Luke Skywalker’s father.

Keyser Söze was dead the whole time.

image of unicorn

Allowed HTML

Only some basic HTML elements are whitelisted. Also, only some attributes within those tags are whitelisted as well. If specified, they must be in order! Those that don't meet these requirements are completely stripped from the content.

  • <a>: href then title

    Meta Stack Exchange

  • <b> or <strong>: no attributes

    Bold and Strong

  • <blockquote>: no attributes

    To be or not to be, that is the question.
  • <br>: no attributes

    You can
    break to
    the next line.

  • <del> or <strike>: no attributes

    That's not right. That's not even wrong. Correct.

  • <dl>, <dt>, and <dd>: no attributes

    SO
    Stack Overflow
    SE
    Stack Exchange
  • <em> or <i>: no attributes

    Emphasis and Italic

  • <h1>, <h2>, and <h3>: no attributes

    Header One

    Header Two

    Header Three

    Header Four

    Header Five
    Header Six
  • <hr>: no attributes


  • <img>: src then width then height then alt then title

    image of unicorn
    • Specifying one of width or height scales the image; must specify both to change the aspect ratio. They can't be px and they max out at 999.

      • Animated gifs are supported

  • <kbd>: no attributes

    abcdefghijklmnopqrstuvwxyz!@#$%^&*()-_=+`~[{]}|;:'",<.>/?0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ

    • Nested <kbd> elements are allowed.

      OuterNested

  • <ol> or <ul> with <li>: <ol> can have start

    <ol><li>First</li><li>Second</li></ol> <ul><li>Something</li><li>Else</li></ul>
    
    1. First
    2. Second
    • Something
    • Else
    • Start at desired number up to 231 - 1.

      <ol start="2147483647"><li>First</li></ol>
      
      1. First
  • <p>: no attributes

    <p>Paragraph1</p><p>Paragraph2</p>
    

    Paragraph1

    Paragraph2

  • <pre>: no attributes

    <pre>System.out.println("Hello World!");</pre>
    
    System.out.println("Hello World!");
  • <sup> and <sub>: no attributes

    x<sup>2</sup> + A<sub>0</sub>
    

    x2 + A0

    • They can be nested.

      a<sup>b<sup>c<sup>d<sub>e<sup>f</sup></sub></sup></sup></sup>
      

      abcdef

  • Escape your <>

    HashMap<String, Object>
    

    HashMap<String, Object>

    `HashMap<String, Object>`
    

    HashMap<String, Object>

    HashMap&lt;String, Object&gt;
    

    HashMap<String, Object>

Unicode

Emojis

☺🐉

Right-to-left

‮ABCDEF

Superscript, subscript, strikeout

ᵃᵉⁱᵒᵘ ₐₑᵢₒᵤ s̶t̶r̶i̶k̶e̶o̶u̶t̶

Zalgo

Z̸̧̦̥͔̻̞̟͔͒̓̄̓͐͆͋̃̅͆̓͘̚͝͝à̷̛̜͇̺̖̯̭͓̱̱̣̺̲̪̰l̷̢̳̤̮͈͎̩̱̳̱̱̞͆͂̽̀̃͒̿̄̅͊͘͘̚͠͝ͅg̷͙͋o̶̧̩̓̓͌̄͊͐̓̇̏͝ ̶̛͚͖͍̦͕̞͈͆̋̓̈̏̈̓̊̅͆͘͜t̸̬̮̖̖͙͔̮͊̔͊͌́̈́͒̇͒̽̑̎̚̕͠ė̶̖̰̬͙͙̇̈͌͘͜͜x̴͔̎t̶̖́̒̏͒͌̈́̏͊̒̉ͅ ̵̨͍̬͔̼̣̘̖͍͖̘͍͋̑͛̂̾̋ḧ̸̡̘̬̲̣̺́́̿̀̈ͅé̷̦̰̻̤̲̺̠̏͒̉͛̍͌̍ͅr̶̩̯̱̜͆̌̾͌̑̇̊͒̃̀̽̍̚é̴̜̉̇̿̈́͌̕.̸̢̱͔̲̫̇͌̽̌͂͊͊̈́̇

<div class="s-prose s-prose__xs">

</div>

Stacks

Stacks is Stack Overflow’s design system. It includes the resources needed to create consistent, predictable interfaces and workflows that conform to Stack Overflow’s principles, design language, and best practices.

Our documentation is built with Stacks itself, using its immutable, atomic classes and components.

The Stacks website documents:

Product

  • Semantic and accessible component markup
  • Cross-browser compatible Less / CSS
  • An icon library

In ancilliary content like comments or side-discussions, it may be appropriate to add the small variation.

<div class="s-prose s-prose__sm">

</div>

Stacks

Stacks is Stack Overflow’s design system. It includes the resources needed to create consistent, predictable interfaces and workflows that conform to Stack Overflow’s principles, design language, and best practices.

Our documentation is built with Stacks itself, using its immutable, atomic classes and components.

The Stacks website documents:

Product

  • Semantic and accessible component markup
  • Cross-browser compatible Less / CSS
  • An icon library
<div class="s-prose">

</div>

Stacks

Stacks is Stack Overflow’s design system. It includes the resources needed to create consistent, predictable interfaces and workflows that conform to Stack Overflow’s principles, design language, and best practices.

Our documentation is built with Stacks itself, using its immutable, atomic classes and components.

The Stacks website documents:

Product

  • Semantic and accessible component markup
  • Cross-browser compatible Less / CSS
  • An icon library

Depending on the context for displaying the prose component, it may be appropriate to size text up to maintain readability.

<div class="s-prose s-prose__md">

</div>

Stacks

Stacks is Stack Overflow’s design system. It includes the resources needed to create consistent, predictable interfaces and workflows that conform to Stack Overflow’s principles, design language, and best practices.

Our documentation is built with Stacks itself, using its immutable, atomic classes and components.

The Stacks website documents:

Product

  • Semantic and accessible component markup
  • Cross-browser compatible Less / CSS
  • An icon library