# Marked is wrongfully interpreting text as code blocks

02 Mar, 2019 07:16 AM

Marked 2 (Setapp version 2.5.31 (971)) seems to interpret textual content as code blocks in some cases. For e.g., in the markdown content specified below, the text "Text explaining sub-heading 3" is rendered as a code block, complete with code theming.

1. Support Staff Posted by Brett on 02 Mar, 2019 12:53 PM

Text indented 4 spaces or one tab is code, that's universal Markdown syntax. Remove the leading spaces and it will function as you're expecting.

- Brett

2. Posted by Adi on 03 Mar, 2019 01:13 AM

Thanks! I was not aware of that. I was under the impression code blocks were the only way to express code.

3. Posted by Adi on 11 Mar, 2019 11:39 PM

A follow up. Please see attached file for context. Is there any way to get indentation in Markdown given that text indented by a tab or 4 spaces is code? The attached file is rendered "correctly" by Ulysses's HTML preview but is rendered differently by Marked.

4. Support Staff Posted by Brett on 12 Mar, 2019 12:38 AM

You have double indentations on all of those list items. They should
only be indented one tab unless you actually want them to be code. I
have no idea why Ulysses is allowing that, but doing it correctly should
work in both cases.

- Brett

5. Posted by Adi on 12 Mar, 2019 01:52 PM

Thanks Brett.
Just to clarify, those double indentations are a result of having nested lists. They are not put in by me but rather an artifact of creating nested lists in Ulysses.

Even though Ulysses is not following Markdown spec, it's rendering is more intuitive IMO. Although, I figure it severely impacts the portability of the Markdown document itself.

6. Support Staff Posted by Brett on 12 Mar, 2019 01:55 PM

What method are you using to preview? Creating an indented list in
Ulysses follows standard Markdown rules for me (and works perfectly with
Marked).

- Brett

7. Posted by Adi on 12 Mar, 2019 02:51 PM

I am use the shortcut within Ulysses to generate a HTML preview: apple + shift + P

Re-reading my previous post, I think I might have misspoke. To create an indented list, I do use the Tab key. However, I do not use the Tab key for the first level list.

For e.g., in the file attached previously (Demo.md), I only use the Tab key to indent the second level list item that says "Second sub-heading's sub-heading" .

As the previews shows, Ulysses interprets it as per my intention: a 3rd level heading and a second level list item. Marked, however, interprets it as a code block.

8. Support Staff Posted by Brett on 12 Mar, 2019 03:01 PM

Ok, I take back my comment about double-indentation, the preview I was looking at was displaying tabs double-width, your syntax for that was actually fine. The problem is that Markdown doesn't allow headings within list items. Ulysses might, but that's never going to be interpreted correctly in most Markdown applications.

You also need to make a habit of putting a blank line between paragraphs within a list item. As you'll see below, the right whitespace provides the correct result, sans the headings. I'm not sure why you need indented headings, but you might consider just using bold text instead. In my experience outlines in list format don't have embedded headings, but either way, it's not something regular Markdown is going to allow.

Here's a revision of your text that works:

# Main heading

I have 3 sub-headings that I want to indent. They are:

This is a description of the first sub-heading.

Description followed by a code block.

public static void main(String[] args){
//blah
}

9. Posted by Adi on 13 Mar, 2019 02:41 PM

That explains it. Thanks Brett.

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

### »

#### Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

# Keyboard shortcuts

### Generic

? Show this help Blurs the current field

### Comment Form

r Focus the comment reply box Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

## Recent Discussions

 13 Feb, 2020 09:22 PM Markdown Formatting 11 Feb, 2020 11:53 AM Custom themes not working 10 Feb, 2020 06:48 PM KaTex Preview Update 06 Feb, 2020 04:32 PM Using mermaid in Marked 2 29 Jan, 2020 12:45 AM MathJax rendering errors - Scrivener

## Recent Articles

 Using JavaScript in Marked Custom CSS: Writing custom CSS for Marked License code has already been utilized Highlight sentences longer than a certain number of words How do I retrieve a lost license (direct version)