Incorrect word count when there are weird HTML comments in the source

Alex Chan's Avatar

Alex Chan

12 Apr, 2021 10:48 PM

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

If I open the attached file in Marked 2, it displays a word count at the bottom of the window "10 words". But only 5 words are visible – the rest are hidden by the (admittedly unusual) HTML comment in the source.

I've attached a screenshot of what Marked looks like with this document open.

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

  1. Open the attached document.
  2. Look at the word count from Marked 2.
  3. Count the words with your eyes.

This is a reduced example from a larger document, when the word count was misreported by almost 800 words due to commented-out parts.

This is definitely a bit of a weird HTML comment (two opening <!--) – I'm not sure if this is well-defined behaviour in the HTML spec, but if Marked is going to exclude these words from the output, it feels like they should also be excluded from the word count.

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

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

macOS Version: 10.15.7

allowPageBreakInCode: YES
bookTxtIsLeanpub: NO
summaryMdIsGitBook: NO
codeIsPoetry: NO
codeCanWrap: YES
collapsibleHeadlines: NO
convertGithubCheckboxes: YES
convertGithubEmoji: YES
convertYAMLToMMD: NO
defaultMathJaxConfig: TeX-AMS-MML_HTMLorMML
defaultPreviewStyle: 3
defaultProcessor: MultiMarkdown
enableMiniMap: NO
excludeBlockQuotesFromCounts: NO
excludeFootnotesFromCounts: NO
excludeVerbatimFromCounts: NO
excludeCaptionsFromCounts: NO
folderPreviewExtensionsArray: md, markdown, txt, mdown, html, opml
githubNewlines: NO
h1IsPageBreak: NO
h2IsPageBreak: NO
hrIsPageBreak: NO
includeMathJax: NO
includeKatex: NO
limitTextWidth: NO
mathNumberEquations: NO
mathNumberEquationsSide: 0
mathNumberEquationsAMSOnly: NO
minimalJavaScript: NO
permissionGranted: NO
printHeaderFirstPage: NO
printFooterFirstPage: NO
processHTMLFiles: YES
removeMetadataForPreview: NO
removeYAMLHeaders: NO
scrollToEdit: YES
shouldDetectCritic: YES
shouldHighlightMarkupErrors: NO
shouldLoadCritic: NO
syntaxHighlight: YES
syntaxHighlightOnlyLang: NO
useCustomMarkdownProcessor: NO
useCustomPreprocessor: NO
useFirstH1AsPrintTitle: YES

  1. Support Staff 1 Posted by Brett on 13 Apr, 2021 10:49 AM

    Brett's Avatar

    Interestingly it's not the double opening syntax that throw it off, it's
    the extra right angle bracket. If I remove that, it still gets the word
    count right, even with the `<!--` in there. I should be able to fix


  2. Support Staff 2 Posted by Brett on 13 Apr, 2021 11:05 AM

    Brett's Avatar

    Yep, I have this fixed for the next update. Thanks for the detailed


Reply to this discussion

Internal reply

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

Attaching KB article:


Already uploaded files

  • 64 Bytes
  • Screenshot_2021-04-12_at_23.43.40.png 453 KB

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


? 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