Skip Navigation
FAQs @geekroom.tech

Lemmy Formatting help

Borrowing from @chaorace@lemmy.sdf.org's post and @pH3ra@lemmy.ml's post:

For anyone interested, here’s the Lemmy markdown configuration. As you can see, Lemmy’s website UI supports the full commonmark spec (tutorial / official spec), plus a bunch of extensions. I don’t think anyone’s fully documented these yet, so I’ll try doing so below. Apologies in advance to mobile users, this is probably gonna get ugly (see included image links for how it should look):

  • URL autolinking (plaintext URLs automatically turn into links)
  • Lemmy autolinking:
  • Typography substitutions:
    • (c) → ©
    • (tm) → ™
    • (r) → ®
    • +-→ → ±
    • ... → …
    • --- → —
    • -- → –
    • ???? (>= 4x) → ???
    • !!!! (>= 4x) → !!!
    • horizontal rule (line between paragraphs) ---

  • **bold**bold
  • *italics* OR _italics_italics
  • # Headings → # Headings (1 for level1 heading, up to 5 's; must be at start of new line) [requires space between the #'s and the text]
  • [Link text](https://link.com/)Link text
  • Github-flavor Markdown extensions:
    • Tables
    • Strikethrough: ~~example~~example
  • Subscript/Superscript:
    • Sub: example~sub~ → examplesub
    • Super: example^super^ → examplesuper
  • Footnotes:
    • Inline part: example[^notename or a number] → example[^1]
    • Bottom part: [^1]: My reference (must be placed at VERY end of post to work.)
  • Ruby Text: {example base text|example ruby text} → {example base text|example ruby text}
    • “Ruby” is an html-ism for special pronunciation aids which frequently appear within young person’s media where the language includes non-phonetic characters (e.g.: Chinese characters)
    • Japanese Furigana example: {凄|すご}い!→ 凄い!
  • Spoilers:
 
    
    :::spoiler visible text
    hidden part example
    :::


  
  • Code blocks:

inline codeinline code

code block:

 
         
     println(“Hello World!”)
     println("Line 2")
     


  

becomes

 
    
println(“Hello World!”)
println("Line 2")


  

OR

4 spaces at beginning of each line to be included in the code block becomes

 
        this is a code block
    line 2


  

Code Block Syntax Highlighting!

When after using the three backticks to start a code block, specify the language.

Rust:

  text
    
     rust
    // This is the main function
    fn main() {
        // Print text to the console
        println!("Hello World!");
    }
    


  

becomes:

  rust
    
// This is the main function
fn main() {
    // Print text to the console
    println!("Hello World!");
}

  

No language specified, defaults to "C" language:

 
    
// This is the main function
fn main() {
    // Print text to the console
    println!("Hello World!");
}

  

Text:

  text
    
     text
    // This is the main function
    fn main() {
        // Print text to the console
        println!("Hello World!");
    }
    


  

becomes:

  text
    
// This is the main function
fn main() {
    // Print text to the console
    println!("Hello World!");
}

  

Python:

  text
    
     python
    // This is the main function
    fn main() {
        // Print text to the console
        println!("Hello World!");
    }
    


  

becomes:

  python
    
// This is the main function
fn main() {
    // Print text to the console
    println!("Hello World!");
}

  

Finally:

If I want to write a character that will normally be interpreted as any of the above, I can escape the character with a backslash → \ ... So you can write something like \^thisthis

[1]: To make this footnote, I used the formatting defined above, preceding this text with "`[1]:`"

You're viewing a single thread.

6 comments
  • Some suggestions for things to add to this guide:

    1. For italics, in addition to a pair of asterisks, you can instead use a pair of underscores: _italics_italics
    2. A heading requires a number sign and a space. Your explanation is not wrong in any way, but it may be helpful to also specify that
    3. Code blocks can be done in two ways: three backticks above/below the code block (as you explained) or starting every line of the code with four spaces.
    4. Going off my last point, you may also want to utilize that four-space technique for demonstrating the three-backtick technique. The way you are currently demonstrating that using backslashes is not rendering it how I think you want it to
    5. In the footnote section, you do demonstrate how to create a footnote reference, but not the actual footnote itself
    6. I am not sure what your ruby example is trying to do, but I think you meant: {凄|すご}い! → {凄|すご}い!
    • Thank you for the suggestions! I've updated the post with your recommendations and tried to make things more clear. If there's anything else you find is wrong or should be included, please let me know!

      • Code block syntax highlighting! Without specifying the language, I think Lemmy treats all code blocks a C and applies syntax highlighting as such. Even when the code is obviously not C, or not even code at all, for that matter. Use text to explicitly not apply any highlighting.

         
                 rust
            // This is the main function
            fn main() {
                // Print text to the console
                println!("Hello World!");
            }
            
        
        
          
          rust
            
        // This is the main function
        fn main() {
            // Print text to the console
            println!("Hello World!");
        }
        
          

        No language specified:

         
            
        // This is the main function
        fn main() {
            // Print text to the console
            println!("Hello World!");
        }
        
          

        text:

          text
            
        // This is the main function
        fn main() {
            // Print text to the console
            println!("Hello World!");
        }
        
          

        python:

          python
            
        // This is the main function
        fn main() {
            // Print text to the console
            println!("Hello World!");
        }
        
          
        • Thanks for this! I wasn't aware of this and appears that it was added because another popular instance had it but went down and never came back, leaving a massive gap in functionality.

          • What do you mean by that? Not all Lemmy instances support it?

            • So I was trying to get the syntax highlighting correct and when googling I came across a GitHub issue where someone said an old Lenny instance had syntax highlighting but it was a custom theme or something and Lenny at the time didn’t support it.

              Then about a year and half ago the Lenny devs added native support for syntax highlighting.

              References:

              https://lemmy.ml/post/305136

              Well, I can’t seem to find the original GitHub request for Lenny but the requester referenced either heapoverflow.info or heapoverflow.ml

6 comments