Marked is wrongfully interpreting text as code blocks

Adi's Avatar

Adi

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.

Heading 1

Heading 2

  • ### Sub-heading 3 Text explaining sub-heading 3
  1. Support Staff 1 Posted by Brett on 02 Mar, 2019 12:53 PM

    Brett's Avatar

    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. 2 Posted by Adi on 03 Mar, 2019 01:13 AM

    Adi's Avatar

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

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

    Adi's Avatar

    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 4 Posted by Brett on 12 Mar, 2019 12:38 AM

    Brett's Avatar

    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. 5 Posted by Adi on 12 Mar, 2019 01:52 PM

    Adi's Avatar

    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 6 Posted by Brett on 12 Mar, 2019 01:55 PM

    Brett's Avatar

    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. 7 Posted by Adi on 12 Mar, 2019 02:51 PM

    Adi's Avatar

    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 8 Posted by Brett on 12 Mar, 2019 03:01 PM

    Brett's Avatar

    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:
    
    - First sub-heading
    
        This is a description of the first sub-heading.
    
    - Second sub-heading
    
        This is a description of the second sub-heading. This has an additional sub-heading like so:
    
        - Second sub-heading's sub-heading
    
            Description followed by a code block.
    
    
                public static void main(String[] args){
                //blah
                }
    
  9. 9 Posted by Adi on 13 Mar, 2019 02:41 PM

    Adi's Avatar

    That explains it. Thanks Brett.

Reply to this discussion

Internal reply

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

Attaching KB article:

»

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
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac