Word count appears to be run on custom processor input, not output

Keith B.'s Avatar

Keith B.

08 Oct, 2021 02:40 AM

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

If you have a custom processor enabled, it appears that the wordcount in the status bar when no text is selected is being calculated against the file on disk, rather than the output received from the custom processor.

A real-world case where this is a problem is a custom processor which processes includes.

Marked's native includes (<<[file.md]) do not exhibit this bug, but are not always a usable substitute (e.g. in a pandoc workflow where you need multiple output formats).

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

  1. Make a markdown file with a known wordcount.

    This document contains five words!
    
  2. Make a custom processor script which does something obvious to the wordcount:

    #!/bin/sh
    cat 100words.md
    
  3. Preview the known-wordcount document in Marked.

Expected result: The wordcount in the status bar says "100 words".
Observed result: The wordcount in the status bar says "5 words".

If you click on the wordcount to get the extended stats, they all also match the input document.

On the other hand, actually selecting text in Marked's preview pane gives you the correct wordcount in both the hover balloon and the status bar. (See attached image.)

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

macOS Version: 11.6

additionalMathJaxConfig:
allowPageBreakInCode: YES
bookTxtIsLeanpub: NO
summaryMdIsGitBook: NO
codeIsPoetry: NO
codeCanWrap: YES
collapsibleHeadlines: NO
convertGithubCheckboxes: YES
convertGithubEmoji: YES
convertYAMLToMMD: NO
defaultMathJaxConfig: TeX-AMS-MML_HTMLorMML
defaultPreviewStyle: 0
defaultProcessor: MultiMarkdown
enableMiniMap: NO
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: YES
mathNumberEquations: NO
mathNumberEquationsSide: 0
mathNumberEquationsAMSOnly: NO
minimalJavaScript: NO
outlineModeExtensions:
permissionGranted: YES
printHeaderBottomLeft:
printHeaderBottomRight:
printHeaderFirstPage: NO
printFooterFirstPage: NO
printHeaderTopLeft:
printHeaderTopRight:
processHTMLFiles: YES
removeMetadataForPreview: NO
removeYAMLHeaders: NO
scrollToEdit: YES
shouldDetectCritic: YES
shouldHighlightMarkupErrors: NO
shouldLoadCritic: NO
syntaxHighlight: YES
syntaxHighlightOnlyLang: NO
useCustomMarkdownProcessor: YES
customMarkdownProcessor: ~/.local/share/pandoc/marked-wrapper.sh
useCustomPreprocessor: NO
customPreprocessor:
useFirstH1AsPrintTitle: YES

Reply to this discussion

Internal reply

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

Attaching KB article:

»

Already uploaded files

  • Screen_Shot_2021-10-08_at_13.33.41.png 870 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

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