Normal javascript functions are not available with the console reporting errors

Larry Pesce's Avatar

Larry Pesce

14 Aug, 2018 02:29 PM

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

Normal javascript functions are not available with the console reporting these errors:

[Warning] Unexpected CSS token: !important (tocstyle.css, line 4068) [Warning] Unexpected CSS token: . (tocstyle.css, line 5307) [Error] SyntaxError: Unexpected identifier 'parsed' (anonymous function) (marked.min.js:5) [Error] ReferenceError: Can't find variable: hasHeaders global code ( [Error] ReferenceError: Can't find variable: Marked global code ( [Error] ReferenceError: Can't find variable: Marked global code (

Selected Element <

= $1

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

  1. Create this basic file:

2. Open with Marked 2 version 2.5.21 (956) on macOS version 10.11.6

3. View Marked 2 console.

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

// Configuration (do not edit)
Marked 2 956 (Direct)
macOS Version: 10.11.6
allowPageBreakInCode: TRUE
bookTxtIsLeanpub: TRUE
summaryMdIsGitBook: TRUE
codeIsPoetry: TRUE
codeCanWrap: TRUE
collapsibleHeadlines: TRUE
convertGithubCheckboxes: TRUE
defaultMathJaxConfig: TeX-AMS-MML_HTMLorMML
defaultPreviewStyle: 3
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
permissionGranted: TRUE
printHeaderFirstPage: TRUE
printFooterFirstPage: TRUE
processHTMLFiles: TRUE
removeMetadataForPreview: TRUE
removeYAMLHeaders: TRUE
scrollToEdit: TRUE
shouldDetectCritic: TRUE
shouldHighlightMarkupErrors: TRUE
shouldLoadCritic: TRUE
syntaxHighlight: TRUE
syntaxHighlightOnlyLang: NO</code>
  1. Support Staff 1 Posted by Brett on 14 Aug, 2018 04:39 PM

    Brett's Avatar

    I've had a couple other reports this morning, I'm a bit concerned that
    this is a 10.11 issue, which I don't currently have a test machine for.
    I'm working to track something down right now.


  2. Support Staff 2 Posted by Brett on 14 Aug, 2018 07:25 PM

    Brett's Avatar

    I found the issue. I'll have an update posted later today (MAS version
    will take time for review but you're on direct so you'll have access to
    the Marked->Check for Updates automatic updater).

    Thanks for reporting this,

  3. Support Staff 3 Posted by Brett on 14 Aug, 2018 08:28 PM

    Brett's Avatar

    The update is out for direct customers (Marked 2->Check for Updates).
    Let me know if it doesn't fix the issue for you.

  4. 4 Posted by Larry Pesce on 15 Aug, 2018 08:14 PM

    Larry Pesce's Avatar

    Thanks. I just updated and now have additional errors when referencing an external JavaScript file (which was the start of the adventure for all of this). Using and sample.js (attached) the following errors are displayed in the console:

    [Error] TypeError: codeTags.forEach is not a function. (In 'codeTags.forEach(updateTag)', 'codeTags.forEach' is undefined) (anonymous function)

    Same OS and system configuration aside from the updated version, now 2.5.22 (957).

  5. Support Staff 5 Posted by Brett on 15 Aug, 2018 08:31 PM

    Brett's Avatar

    You're actually running into the same problem that was causing the errors in my JavaScript: the version of macOS you're running doesn't process ECMA 6, so your const keyword is breaking your script. Change it to var and it should work fine.

    P.S. The script as is should run fine on macOS 10.12 and newer. I can only verify it works fine on 10.14 and doesn't work on 10.11 at the moment, though.

  6. 6 Posted by Larry Pesce on 15 Aug, 2018 09:31 PM

    Larry Pesce's Avatar

    changing this:

    document.addEventListener("DOMContentLoaded", function(event) {
    const codeTags = document.querySelectorAll('code.text'); codeTags.forEach(updateTag);

    to this exhibits the same errors:

    document.addEventListener("DOMContentLoaded", function(event) {
    var codeTags = document.querySelectorAll('code.text'); codeTags.forEach(updateTag);

    I expect document.querySelector('code.text') to identify all of the code text blocks, but it returns an empty set. The const/var change doesn't address the issue with Marked2 on Mac OS 10.11.

    A perfectly reasonable answer here is "Upgrade to an OS that supports an non-stone age ECMA".

    Thanks for all of your help.

  7. Support Staff 7 Posted by Brett on 15 Aug, 2018 11:33 PM

    Brett's Avatar

    Well, both .querySelectorAll() and .forEach() are available in ECMA 5.
    If the query is returning an empty set, you might want to examine the
    actual contents of the DOM to see what's there. You can test things out
    in the console (REPL), too. Just hit ctrl-opt-i in Marked or right click
    in the preview and choose Inspect.


Reply to this discussion

Internal reply

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

Attaching KB article:


Already uploaded files

  • 16 Bytes

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