constants.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * This module is compiled away!
  3. *
  4. * Parsing markdown comes with a couple of constants, such as minimum or maximum
  5. * sizes of certain sequences.
  6. * Additionally, there are a couple symbols used inside micromark.
  7. * These are all defined here, but compiled away by scripts.
  8. */
  9. export const constants = /** @type {const} */ ({
  10. attentionSideBefore: 1, // Symbol to mark an attention sequence as before content: `*a`
  11. attentionSideAfter: 2, // Symbol to mark an attention sequence as after content: `a*`
  12. atxHeadingOpeningFenceSizeMax: 6, // 6 number signs is fine, 7 isn’t.
  13. autolinkDomainSizeMax: 63, // 63 characters is fine, 64 is too many.
  14. autolinkSchemeSizeMax: 32, // 32 characters is fine, 33 is too many.
  15. cdataOpeningString: 'CDATA[', // And preceded by `<![`.
  16. characterGroupWhitespace: 1, // Symbol used to indicate a character is whitespace
  17. characterGroupPunctuation: 2, // Symbol used to indicate a character is punctuation
  18. characterReferenceDecimalSizeMax: 7, // `&#9999999;`.
  19. characterReferenceHexadecimalSizeMax: 6, // `&#xff9999;`.
  20. characterReferenceNamedSizeMax: 31, // `&CounterClockwiseContourIntegral;`.
  21. codeFencedSequenceSizeMin: 3, // At least 3 ticks or tildes are needed.
  22. contentTypeDocument: 'document',
  23. contentTypeFlow: 'flow',
  24. contentTypeContent: 'content',
  25. contentTypeString: 'string',
  26. contentTypeText: 'text',
  27. hardBreakPrefixSizeMin: 2, // At least 2 trailing spaces are needed.
  28. htmlRaw: 1, // Symbol for `<script>`
  29. htmlComment: 2, // Symbol for `<!---->`
  30. htmlInstruction: 3, // Symbol for `<?php?>`
  31. htmlDeclaration: 4, // Symbol for `<!doctype>`
  32. htmlCdata: 5, // Symbol for `<![CDATA[]]>`
  33. htmlBasic: 6, // Symbol for `<div`
  34. htmlComplete: 7, // Symbol for `<x>`
  35. htmlRawSizeMax: 8, // Length of `textarea`.
  36. linkResourceDestinationBalanceMax: 32, // See: <https://spec.commonmark.org/0.30/#link-destination>, <https://github.com/remarkjs/react-markdown/issues/658#issuecomment-984345577>
  37. linkReferenceSizeMax: 999, // See: <https://spec.commonmark.org/0.30/#link-label>
  38. listItemValueSizeMax: 10, // See: <https://spec.commonmark.org/0.30/#ordered-list-marker>
  39. numericBaseDecimal: 10,
  40. numericBaseHexadecimal: 0x10,
  41. tabSize: 4, // Tabs have a hard-coded size of 4, per CommonMark.
  42. thematicBreakMarkerCountMin: 3, // At least 3 asterisks, dashes, or underscores are needed.
  43. v8MaxSafeChunkSize: 10000 // V8 (and potentially others) have problems injecting giant arrays into other arrays, hence we operate in chunks.
  44. })