Single-quotes are transformed to ' inside code-blocks on export to markdown from preview

Chris Sederqvist's Avatar

Chris Sederqvist

10 Jan, 2019 06:00 PM

// Please enter a detailed description of the issue // Description of the issue:

When exporting from Marked 2 preview to Markdown, all my single-quotes inside code blocks
are transformed to apostrophes (') in the resulting markdown file.

Single quotes in paragraphs are not transformed, only inside code blocks!

This happens both when using the MultiMarkdown processor and with Discount.

THINGS I TRIED:
I've tried turning "Smart Quotes" both on and off in the Text Preferences in OS X and
restarted all apps, but the result is the same.

I've unchecked the option for "generate correct quotation setting" in Marked 2
when using MMD, but still my single-quotes are transformed into ' in the resulting
markdown file's code blocks.

I've tried preview in Marked from both BearNotes and Ulysses, and the same shit happens
when I export from Marked 2 -> Markdown file.

I can do a "Copy as Markdown" in both BearNotes and Ulysses and paste the contents into
a new file in SublimeText without the single quotes being altered, and the Markdown
is kept intact, but when previewing and exporting from Marked 2, saving as a markdown file,
this conversion occurs inside the code blocks.

NOTE: I see that the config output below indicates:

codeIsPoetry: TRUE

This is strange, as I have that unchecked in Marked 2's preferences.

// Please enter a list of steps required to reproduce the issue // Steps to reproduce:

  1. Preview the attached file (error_when_preview_and_export.md) in Marked 2
  2. Export from preview to markdown file and check the resulting .md file's single-quotes
    inside the code blocks.

// If applicable please attach a sample document that causes the issue for you.

I've attached a file that produces this behavior when exported and the resulting .md file.

// Configuration (do not edit) Marked 2 968 (Direct)

macOS Version: 10.14.2

additionalMathJaxConfig:
allowPageBreakInCode: TRUE
bookTxtIsLeanpub: TRUE
summaryMdIsGitBook: TRUE
codeIsPoetry: TRUE // THIS IS UNCHECKED IN MY PREFERENCES, SO WHY IS IT ENABLED???
codeCanWrap: TRUE
collapsibleHeadlines: TRUE
convertGithubCheckboxes: TRUE
convertYAMLToMMD: TRUE
defaultMathJaxConfig: TeX-AMS-MML_HTMLorMML
defaultPreviewStyle: 0
defaultProcessor: Discount (GFM)
enableMiniMap: TRUE
excludeBlockQuotesFromCounts: TRUE
excludeFootnotesFromCounts: TRUE
excludeVerbatimFromCounts: TRUE
excludeCaptionsFromCounts: TRUE
folderPreviewExtensionsArray: md, markdown, txt, mdown, html, opml
githubNewlines: TRUE
h1IsPageBreak: TRUE
h2IsPageBreak: TRUE
hrIsPageBreak: TRUE
includeMathJax: TRUE
limitTextWidth: TRUE
minimalJavaScript: TRUE
outlineModeExtensions:
permissionGranted: TRUE
printHeaderBottomLeft:
printHeaderBottomRight:
printHeaderFirstPage: TRUE
printFooterFirstPage: TRUE
printHeaderTopLeft:
printHeaderTopRight:
processHTMLFiles: TRUE
removeMetadataForPreview: TRUE
removeYAMLHeaders: TRUE
scrollToEdit: TRUE
shouldDetectCritic: TRUE
shouldHighlightMarkupErrors: TRUE
shouldLoadCritic: TRUE
syntaxHighlight: TRUE
syntaxHighlightOnlyLang: TRUE

  1. 1 Posted by Chris Sederqvis... on 10 Jan, 2019 06:10 PM

    Chris Sederqvist's Avatar

    In the post, the &apos is rendered as ' because it's HTML of course (I'm an idiot), but in the resulting markdown file it looks like:
    (trying to wrap it in a <pre>tag</pre>:

    <pre>
    ```dart
    var s1 = &apos;Single quotes work well for string literals.&apos;;
    var s2 = &quot;Double quotes work just as well.&quot;;
    var s3 = &apos;It\&apos;s easy to escape the string delimiter.&apos;;
    var s4 = &quot;It&apos;s even easier to use the other delimiter.&quot;;
    ```
    </pre>

    While it should look like this:

    <pre>
    ```dart
    var s1 = 'Single quotes work well for string literals.';
    var s2 = "Double quotes work just as well.";
    var s3 = 'It\'s easy to escape the string delimiter.';
    var s4 = "It's even easier to use the other delimiter.";
    ```
    </pre>

  2. Support Staff 2 Posted by Brett on 10 Jan, 2019 06:59 PM

    Brett's Avatar

    Escaping characters available as entities is standard behavior for Markdown. I understand that it's not great for legibility and you'd like the original formatting preserved in the Markdown export, but at the point where the export is created the escaping has already taken place in the code blocks. It's something I can look into avoiding, but it's more complex than it seems on the surface.

  3. 3 Posted by Chris Sederqvis... on 10 Jan, 2019 07:23 PM

    Chris Sederqvist's Avatar

    Well, I've used Marked2 and Bear Notes before without having any trouble with the resulting export.
    What usually has been the result is exactly what I want:
    Quotes (single and double) are converted to typographically correct quotes in paragraph text but inside triple-quoted code-blocks, they're left as is and not converted or altered in any way.
    Something must have changed in either my settings, OS or apps that cause this conversion within code-blocks to happen...

  4. Support Staff 4 Posted by Brett on 10 Jan, 2019 09:04 PM

    Brett's Avatar

    It may have been something that changed in Marked over time, but it's not something that should be affected by any available settings. I'll look into it, but there's nothing on your end that you can control on this one.

  5. Support Staff 5 Posted by Brett on 15 Jan, 2019 05:08 PM

    Brett's Avatar

    Ok, I have this issue fixed for the next update. It's actually going in and unescaping all entities in the code, which means it might be a bit hyper and remove intentional entities, so I'll need to figure out if I've only made the problem worse or not.

    I've also fixed the issue where the feedback reporter was basically reporting everything as true even when it wasn't (e.g. code as poetry).

    Thanks for the reports.

  6. Brett closed this discussion on 15 Jan, 2019 05:08 PM.

  7. Chris Sederqvist re-opened this discussion on 16 Jan, 2019 12:38 AM

  8. 6 Posted by Chris Sederqvis... on 16 Jan, 2019 12:38 AM

    Chris Sederqvist's Avatar

    No, problem Brett.
    I appreciate the follow-up and dedication for solving the issue!

    I'm a software developer myself, and I respect your work.
    I'm also a follower of your blog and you seem like a great guy.
    Don't mean to sound like a fanboi or anything, but I admire your work! :)

    I've also struggled with bipolar depression and ADD for many years, so I was surprised to read about your "issues" regarding ADHD and mental barriers.
    But it also gave me hope, sometimes I feel like just giving up my dreams of mastering the craft of software development, it's a never ending learning race.

    But, I'm a hardcore learning addict, so I need input to stay afloat, and reading stories from talented people like yourself and guys like Jeff Atwood gives me motivation to push on and don't give up!

    Well, probably TL; DR. but thanks anyways!

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