版博士V2.0程序
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

attribute-value-bare.js 1013 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. const {
  2. calculateTokenCharactersRange,
  3. isWhitespace
  4. } = require('../helpers')
  5. const { TOKEN_ATTRIBUTE_VALUE } = require('../constants/token-types')
  6. const { ATTRIBUTES_CONTEXT } = require('../constants/tokenizer-contexts')
  7. function valueEnd (state, tokens) {
  8. const range = calculateTokenCharactersRange(state, { keepBuffer: false })
  9. tokens.push({
  10. type: TOKEN_ATTRIBUTE_VALUE,
  11. content: state.accumulatedContent,
  12. startPosition: range.startPosition,
  13. endPosition: range.endPosition
  14. })
  15. state.accumulatedContent = ''
  16. state.decisionBuffer = ''
  17. state.currentContext = ATTRIBUTES_CONTEXT
  18. }
  19. function parseSyntax (chars, state, tokens) {
  20. if (
  21. (!state.accumulatedContent.match('{{') || state.accumulatedContent.match('}}')) &&
  22. (isWhitespace(chars)
  23. || chars === '>'
  24. || chars === '/')
  25. ) {
  26. return valueEnd(state, tokens)
  27. }
  28. state.accumulatedContent += state.decisionBuffer
  29. state.decisionBuffer = ''
  30. state.caretPosition++
  31. }
  32. module.exports = {
  33. parseSyntax
  34. }