aleclarson / markdown-ast

Tiny markdown parser
MIT License
40 stars 2 forks source link

Arbitrary JS errors on build if .md files are in CRLF format #8

Open space-dweeb opened 1 year ago

space-dweeb commented 1 year ago

Steps to reproduce:

  1. An .md file in CRLF format with these contents is error-free:
    
    > hello

abc

---
title: Platform Features
desc: We've organized features into categories and subcategories in order to help explain what our platform can do.
keys: platform-features
---

> hello

abc

* abcd

Build error:

/Users/asteele/Projects/operations/docs-public/node_modules/markdown-ast/index.js:157
          '\n' + line.match(isQuote ? /^\s*>?\s*(.*)$/ : /^\s*(.*)$/)[1]
                                                                     ^

TypeError: Cannot read properties of null (reading '1')
    at parse (/Users/asteele/Projects/operations/docs-public/node_modules/markdown-ast/index.js:157:70)
    at processPage (/Users/asteele/Projects/operations/docs-public/build/search/index.js:226:15)
    at /Users/asteele/Projects/operations/docs-public/build/search/index.js:251:11
    at Array.forEach (<anonymous>)
    at processChildren (/Users/asteele/Projects/operations/docs-public/build/search/index.js:235:21)
    at processMenuItem (/Users/asteele/Projects/operations/docs-public/build/search/index.js:270:7)
    at /Users/asteele/Projects/operations/docs-public/build/search/index.js:293:5
    at Array.forEach (<anonymous>)
    at run (/Users/asteele/Projects/operations/docs-public/build/search/index.js:292:8)
    at Object.<anonymous> (/Users/asteele/Projects/operations/docs-public/build/search/index.js:308:1)
  1. An .md file in LF format with the same contents as either Step 1 or Step 2 is error-free.