Printing Code Blocks with Word Wrap

Adam's Avatar

Adam

26 Feb, 2019 03:24 PM

Hello,

Is there a way to print from Marked with word wrap enabled for words inside code blocks? Currently, I use the GitHub template 90% of the time.

Adam

  1. Support Staff 1 Posted by Brett on 26 Feb, 2019 03:30 PM

    Brett's Avatar

    Do you have this option set?

  2. 2 Posted by Adam on 26 Feb, 2019 06:35 PM

    Adam's Avatar

    Thanks for pointing that out and yes I do (see screenshot). It looks like it doesn't work on GitHub. Also, I'm using Markdown in a unique way for note taking with Sublime Text.

    ```
    Test
    ```
    (blank line)
    ```
    Test
    ```

    For the GitHub preview, it merges the two code blocks and ignores the blank line (see attachment).

  3. Support Staff 3 Posted by Brett on 26 Feb, 2019 06:59 PM

    Brett's Avatar

    Just for clarity, is it significant that you have 4 backticks at the end
    of the first block, or just an error in typing it out here?

    -Brett

  4. Support Staff 4 Posted by Brett on 26 Feb, 2019 07:08 PM

    Brett's Avatar

    So the "allow themes to wrap" option only offers the option to the theme. The GitHub theme does not wrap code by default (though it does in export). If you want to force wrapping in the preview, you can use the Preferences->Style->Additional CSS box to add:

    .github #wrapper pre {
      word-break: break-word;
      white-space: pre-line;
      margin: 10px 0;
    }
    

    I also included a margin in there to give you the space between blocks I think you're looking for.

    -Brett

  5. 5 Posted by Adam on 03 Mar, 2019 05:36 PM

    Adam's Avatar

    Thanks for taking the time to help me with this minor request. I'm not using four backticks in the code block example. Only three. I edited that post, so it may had a typo.

    Where are your CSS Themes in the Library? I can't find them. I want to copy the GitHub theme and make a custom one with the code you provided.

  6. Support Staff 6 Posted by Brett on 03 Mar, 2019 05:44 PM

    Brett's Avatar

    You can download (mostly up-to-date) copies of the default CSS files at
    https://github.com/ttscoff/MarkedCustomStyles/tree/master/default_styles

    -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