# marked 2 hangs when file is saved twice quickly

#### Count of San Francisco

01 Oct, 2019 07:50 PM

Hi,

When I edit my markdown (MD) text in my favorite text editor, I noticed marked 2 hangs when i do a "double" save quickly one after another. I think it hangs when it is not done rendering, visually, the first save.

For example, I might write a new paragraph in a MD document. When I am done, I save it. Then, I noticed a typo (like a missing period). I quickly fix it and then save it. I think if the MD document is "big" and marked 2 is taking a little extra time rendering the first save and a 2nd save comes in, marked 2 hangs indefinitely (or rather I run out of patience). I close the document in Marked 2. Then, I try to quit/exit/close the Marked 2 app. At that point, my Mac tells me it is not responding and I will have to do a force quit.

I am using MacOS Mojave version 10.14.6.

Thanks

1. Support Staff Posted by Brett on 02 Oct, 2019 04:52 PM

If you could please open Marked and select Help->Report an Issue from
the menu bar, pasting the results of that into this thread will help me
simulate your environment for testing. If possible, please also attach a
file that causes the behavior for you. You can set this thread to
private if you're willing to share with me but not publicly.

-Brett

2. Posted by Count of San Fr... on 02 Oct, 2019 11:56 PM

// Configuration (do not edit) Marked 2 976 (Mac App Store)

## macOS Version: 10.14.6

allowPageBreakInCode: YES
bookTxtIsLeanpub: NO
summaryMdIsGitBook: NO
codeIsPoetry: NO
codeCanWrap: YES
convertGithubCheckboxes: YES
convertYAMLToMMD: NO
defaultMathJaxConfig: TeX-AMS-MML_HTMLorMML
defaultPreviewStyle: 3
defaultProcessor: Discount (GFM)
enableMiniMap: YES
excludeBlockQuotesFromCounts: NO
excludeFootnotesFromCounts: NO
excludeVerbatimFromCounts: NO
excludeCaptionsFromCounts: NO
folderPreviewExtensionsArray: md, markdown, txt, mdown, html, opml
githubNewlines: YES
h1IsPageBreak: NO
h2IsPageBreak: NO
hrIsPageBreak: NO
includeMathJax: YES
includeKatex: NO
limitTextWidth: NO
minimalJavaScript: NO
outlineModeExtensions:
permissionGranted: NO
printFooterFirstPage: NO
processHTMLFiles: YES
scrollToEdit: YES
shouldDetectCritic: YES
shouldHighlightMarkupErrors: YES
syntaxHighlight: YES
syntaxHighlightOnlyLang: NO
useCustomMarkdownProcessor: NO
customMarkdownProcessor:
useCustomPreprocessor: NO
customPreprocessor:
useFirstH1AsPrintTitle: YES

3. Posted by Count of San Fr... on 03 Oct, 2019 12:04 AM

I cannot share the document, unfortunately.

Also, I noticed this is becoming more frequent. The initial save does not present any issues. But a subsequent save can cause Marked 2 to show a "blank" and completely white window. The time between each subsequent save makes a difference in how easily reproducible this is but I do notice as well that even if the time delta is long, marked 2 can get into this funky mode. It is easy to reproduce if the time delta is small.

When I get into this situation, my MacBook's fan grows louder as that indicates that perhaps the Marked 2 code is in a tight loop which is heating up the CPU. I have to force quit that app.

I use MacVIM as my editor. Just FYI.

4. Support Staff Posted by Brett on 03 Oct, 2019 04:05 PM

It's possible that something specific in the document is throwing Marked
for a loop. Does this happen with any document?

-Brett

5. Posted by Count of San Fr... on 05 Oct, 2019 12:32 AM

I don't know if this happens with other documents as I have only one document to edit at this time.

Is there a way to isolate where in the document this problem is occurring? I can then go see that section. A document containing over thousands of line can be hard to figure out which line that is causing the problem.

Thanks!

6. Posted by Count of San Fr... on 07 Oct, 2019 11:10 PM

Hi,

To help debug this problem, I did an "strace" or rather in MacOS lingo, dtruss, of the active process and capture that output into a file. I like to deliver the files to you in a private manner with some description of it. I see an "attach file" button below but I am not sure that is private. How do I deliver files to you in a private manner? The files are in plain text.

Also, I went through the HTML generated form of the MD and used an HTML syntax analyzer on it. There were lots of warnings and some errors like duplicate ids and some minor typos. I fixed those but the problem still occurs.

Thanks!

7. Support Staff Posted by Brett on 08 Oct, 2019 03:28 PM

If you set this conversation to "Private", any attachment will only be
seen by me and never indexed in search. If you need an alternate method,
you can send it directly to [email blocked], but I'd ask that the
conversation remain here and not in an email exchange.

I don't think the issue will be cleared up by any process trace, nor
would it be anything to do with the output markup. The easiest way to
test with your large file is to create a copy and delete half the text.
Test with that file and see if the issue persists. If not, you can try
testing with the other half. If the issue then shows up, you know it's
something in that half of the file and can start removing parts from
there. If it doesn't, then it's likely being caused just by the size of
the file, which would be odd but not unheard of and we could debug from
there.

-Brett

8. Posted by Count of San Fr... on 08 Oct, 2019 05:57 PM

Hi Brett,

Okay. Thanks. Let me do that. The MD file is 101,389 bytes in size.
However, our MD file contains a lot of HTML tags as well such as tables
(where markdown cannot address), <p>, <a>. Mostly they are <p>'s and <a>'s.

I am not sure that makes a difference.

I will do your suggestion and try to isolate the problem by removing
text. Please give me a few days to see if this method helps isolate the
problem further.

Thanks!!

9. Posted by Count of San Fr... on 20 Oct, 2019 06:13 PM

Hi Brett,

I found the problem. Since our MD file has lots of HTML tags as well, I found what was causing the issue.

If I do this:

blahblahblah

and there are many of this in the MD text, Marked 2 will "hang".

The solution is this:

blahblahblah

That is add the corresponding

.

However, I do noticed that

just like that (i.e. without the id=id_name) seems to work without Marked 2 hanging.

Once I fixed this, the problem was pretty much not reproducible.

It would be nice for Marked 2 to not "crash" when this happens and to assume that the

without a

acts like an anchor instead. If Marked 2 needs the end tag, please raise a fault or notice to the user.

Also, I noticed that Marked 2 generates a non-compliant HTML when a

HTML tag follows immediately after a MD header (i.e. the # symbols). It wraps a "

" and a corresponding "

" around the HTML tags. Just to be clear, the table in the MD text uses the HTML tag and not the MD method of describing tables.

For example, the following causes wrong HTML:

# My Header Text

....
10. Posted by Count of San Fr... on 20 Oct, 2019 06:16 PM

Forgot to move my comment to plain text. Here it is again:

Hi Brett,

I found the problem. Since our MD file has lots of HTML tags as well, I found what was causing the issue.

If I do this:
<p id=some_name_i_choose>blahblahblah

and there are many of this in the MD text, Marked 2 will "hang".

The solution is this:
<p id=some_name_i_choose>blahblahblah</p>

That is add the corresponding </p>.

However, I do noticed that <p> just like that (i.e. without the id=id_name) seems to work without Marked 2 hanging.

Once I fixed this, the problem was pretty much not reproducible.

It would be nice for Marked 2 to not "crash" when this happens and to assume that the <p id=whatever> without a </p> acts like an anchor instead. If Marked 2 needs the </p> end tag, please raise a fault or notice to the user.

Also, I noticed that Marked 2 generates a non-compliant HTML when a <table> HTML tag follows immediately after a MD header (i.e. the # symbols). It wraps a "<p>" and a corresponding "</p>" around the <table> HTML tags. Just to be clear, the table in the MD text uses the HTML <table> tag and not the MD method of describing tables.

For example, the following causes wrong HTML:

# My Header Text
<table> .... </table>

11. Support Staff Posted by Brett on 20 Oct, 2019 08:46 PM

Marked can not be an html linter, that’s way beyond its scope. If you’re going to use html in your markdown, it needs to be valid. A p tag always requires a closing tag. The better option for anchors is an <a> tag, but even better is using headers, which get ids automatically and can be linked to with markdown syntax.

Thanks,
Brett

12. Posted by Count of San Fr... on 31 Oct, 2019 07:24 PM

That is fine if Marked 2 doesn't want to be an HTML linter. But I think basic syntax checking should be do-able. But fine, if you don't want to even do that.

But I don't think Marked 2 should be going into a "hung" scenario due to bad HTML. If you don't want to offer basic HTML syntax checking, then at least don't going into a tight loop where I need to force quit Marked 2 or where my laptop's fans start to spin like crazy.

I think you have enough information to know what the problem is now. So, I am fine if you want to close this issue and bring the information to your internal teams.

13. Support Staff Posted by Brett on 31 Oct, 2019 07:48 PM

I appreciate that you think I have internal teams, but the entire
operation is just me. Which is why requests like HTML linting take a
back burner to actual Markdown-related requests.

-Brett

14. Posted by Count of San Fr... on 31 Oct, 2019 07:51 PM

Oh, I see. You are a one man show. Okay. Understood. Keep up the good work!

## Reply to this discussion

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

 03 Jun, 2020 09:06 PM Ink 02 Jun, 2020 02:11 AM "Cross Grade" my App Store License 29 May, 2020 01:52 AM Sharing a simple fix for path issues with pandoc-citeproc 27 May, 2020 02:40 PM Outline Numbering OK in Preview But Heading 3, 4 Not Honoured in Export as PDF 25 May, 2020 06:32 PM Marked 2 crashes when I try to "Copy Rich Text"

## Recent Articles

 Fenced code blocks inside indented code blocks 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